Commit 9fd35df
authored
Modernize for PHP 8.4+, Symfony 6.4/7.4/8.1+, PHPUnit 12 (#238)
* Modernize for PHP 8.4+, Symfony 6.4/7.4/8.1+, PHPUnit 12
- composer.json: require php ^8.4, symfony/process ^6.4 || ^7.4 || ^8.1,
bump phpunit/phpunit to ^12.0 and psr/log to ^3.0, drop
phpspec/prophecy-phpunit (its one use site now uses native PHPUnit mocks)
- CI matrix now runs PHP 8.4/8.5 plus a prefer-lowest job; phpunit.xml.dist
rewritten for the PHPUnit 12 schema
- README/CONTRIBUTING updated for the new PHP baseline and a couple of
stale references
- Full property/parameter/return type coverage across src/, with readonly
applied wherever a property is genuinely write-once (mostly via
constructor promotion)
- Classes marked final wherever nothing extends them, and final readonly
where every property is readonly; left plain where they're actually
extended or inherit mutable state (Revision, Reference, ParserBase,
CommitParser, Exception\RuntimeException)
- Tests converted from doc-comment metadata (@dataProvider/@before/@after)
to PHPUnit 12 attributes, since PHPUnit 12 no longer reads the old
annotations; AbstractTest renamed to AbstractTestCase so PHPUnit doesn't
mistake it for a test case via the *Test.php glob
- Fixed bugs surfaced along the way: Log's ReferenceNotFoundException call
silently dropped the previous exception (constructor didn't accept it);
DiffTest called restore_exception_handler() instead of
restore_error_handler(), leaking handlers between tests; a dead
@dataProvider on ReferenceTest::testIsBranchMergedToMaster wastefully
cloned repos it never used
* Drop StyleCI references and README badges
StyleCI never had a .styleci.yml or a workflow step in this repo — it only
ran as a separate GitHub App integration. Removing it here means dropping
every textual reference; actually uninstalling the app is a repo-settings
action outside of this checkout.
* Add php-cs-fixer, PHPStan and Castor tooling
Mirrors JoliCode's own JoliNotif project setup:
- php-cs-fixer and phpstan each live in tools/<name>/ with their own
isolated composer.json/lock (avoids dependency conflicts with the
library's own require-dev), wired together via a root castor.php that
imports each tool's own castor.php. `castor install`, `castor cs`,
`castor phpstan` and `castor phpunit` all work end to end.
- .php-cs-fixer.php: @PHP84Migration + @PhpCsFixer + @symfony(:risky),
gitlib's own license header enforced via header_comment. Ran it for
real across the codebase (58 files reformatted, all mechanical); it
also filled in the license header on two files that were missing it
entirely (RuntimeException.php, tests/bootstrap.php).
- phpstan.neon: level 9 on src/. Fixed the ~20 findings that were real
bugs or design smells rather than annotation gaps:
- Reference\Tag::getCommit() could pass an undefined $commitHash
to getCommit() when show-ref returned no matching row
- Repository::getDiff(null) and Log::getCommits()'s catch block
would fatal-error calling a method on null on a reachable path
(a Log built with no revision filter)
- Repository's $gitDir/$workingDir were readonly-assigned outside
the constructor; moved to a static resolveDir() helper
- Repository's single $objects cache (typed Commit|Tree|Blob) split
into three properly-typed caches
- RevisionList/Tree array-shape narrowing fixed by restructuring
the loops that build them
- ReferenceBag::update() and a new getAs() helper made generic so
createBranch()/getTag()/etc. return their real narrow type
- CommitReference was missing a getHash() getter entirely
- Blob::getMimetype() honestly typed string|false (finfo::buffer()
can fail)
The remaining ~94 findings are baselined in phpstan-baseline.neon:
mostly Commit/Reference\Tag's untyped getData(): mixed internals, and
Repository::run()'s ?string return propagating into code that assumes
a string. Fixing those properly means redesigning that data-caching
layer or auditing every run() call site for the debug=false null case,
which is bigger than "add phpstan".
- CI: check-cs and phpstan jobs pinned to PHP 8.4 (our floor) using
castor-php/setup-castor@v1.1.0.
- CONTRIBUTING.md: Castor install step, "Standard code" and "Static
analysis" sections.
* Remove redundant readonly on properties of readonly classes
A class-level `readonly` modifier already makes every declared property
readonly, so repeating the keyword on each promoted constructor property
was dead weight.1 parent c1476cb commit 9fd35df
72 files changed
Lines changed: 5067 additions & 1996 deletions
File tree
- .github
- workflows
- src/Gitonomy/Git
- Blame
- Diff
- Exception
- Parser
- Reference
- Util
- tests
- Gitonomy/Git/Tests
- tools
- php-cs-fixer
- phpstan
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
16 | 26 | | |
17 | 27 | | |
18 | 28 | | |
| |||
27 | 37 | | |
28 | 38 | | |
29 | 39 | | |
30 | | - | |
| 40 | + | |
31 | 41 | | |
32 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
9 | 48 | | |
10 | 49 | | |
11 | 50 | | |
12 | 51 | | |
13 | 52 | | |
14 | 53 | | |
15 | | - | |
| 54 | + | |
16 | 55 | | |
17 | 56 | | |
18 | 57 | | |
19 | | - | |
| 58 | + | |
20 | 59 | | |
21 | 60 | | |
22 | 61 | | |
| |||
32 | 71 | | |
33 | 72 | | |
34 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
35 | 77 | | |
36 | 78 | | |
37 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
| 6 | + | |
4 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 4 | + | |
10 | 5 | | |
11 | 6 | | |
12 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 45 | + | |
| 46 | + | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| |||
0 commit comments