Repository navigation
Restore ORM 2 compatibility and fix the pipeline - #323
Merged
Merged
Conversation
PR Happyr#322 replaced the ORM constraint instead of widening it, which turned an additive feature into a BC break and would have forced a major release. Doctrine ORM 3 support is additive instead, matching how Symfony 7 support shipped in v2.1.0. All three src changes from Happyr#322 are already BC: - Type::hasType() available since DBAL 2.9.0 - enableResultCache() available since ORM 2.8.0 - toIterable() available since ORM 2.8.0 The ORM floor is ^2.17 rather than ^2.5 because the specs now double Doctrine\ORM\Query, which was final up to and including ORM 2.16 and only became non-final in 2.17.0. symfony/polyfill-php80 has to come back: src/Filter/Like.php calls str_starts_with(), str_ends_with() and str_contains(), which only exist on PHP 7.x through that polyfill. Also fixes the three failing test jobs: - PHP 8.4 (highest and lowest) could not resolve at all, since PHP 8.4 support only landed in phpspec ^8.0. - PHP 8.1 + lowest died with "'\static' is an invalid class name", because --prefer-lowest resolved prophecy 1.14.0 while support for the static return type only arrived in 1.15.0, and ORM 3 uses static on its fluent setters. phpspec 7.x only requires prophecy ^1.9, so the constraint has to be explicit. Restoring the PHP 7.2-8.0 matrix rows is also required for the 2.x branch protection to stay satisfiable: "PHP 7.4 + highest + normal" and "PHP 8.0 + highest + normal" are required status checks, and Happyr#322 deleted the jobs that report them.
These are pre-existing and unrelated to ORM 3: the QA job installs whatever phpstan is current, so the analysis got stricter over time while the code stood still. On a clean 2.x, phpstan 1.12 reported 3 errors and phpstan 2.2 reported 8. - EntityRepository declares @template T of object, so passing it an unbounded T resolved to mixed. Bounding both templates fixes all three generics errors at once. - explode() never returns an empty array, so array_pop() always yields a string and the null check was dead. - substr() does not return false on PHP 8. Only the PHPDoc is narrowed; adding ": string" to the signature would break subclasses by covariance. - treatPhpDocTypesAsCertain: false silences two instanceof.alwaysTrue reports in QueryModifierCollection and ResultModifierCollection. Those guards are real - they catch untyped callers and throw InvalidArgumentException - so the check stays and the report goes. phpstan 2.2 now reports no errors against ORM 3.6.7 and ORM 2.20.13. It still reports one generics error against ORM 2.17-2.19, where getClassMetadata() is annotated with @psalm-return and @psalm-template that PHPStan does not read; ORM 2.20 changed those to @template and @return. The QA job analyses the highest dependency set, so this does not affect CI.
Also pre-existing and unrelated to ORM 3. The QA job installs whatever php-cs-fixer is current, and the @PhpCsFixer ruleset has grown rules since the last sweep: static_lambda, single_line_empty_body, no_extra_blank_lines, whitespace_after_comma_in_array, ordered_imports, phpdoc_separation and a few more. On a clean 2.x this reported 40 files; Happyr#322 had already brought that down to 31 by reformatting the tests it touched. No behaviour change. The specs still pass 527/527 and phpstan is still clean. Running the fixer a second time reports nothing, so the tree is now a fixed point of the current ruleset.
Records which two reports the setting silences, why the guards they point at are load-bearing rather than dead code, and that replacing the setting with a native variadic type changes InvalidArgumentException into TypeError and so needs a major release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #322. Three separate concerns, one commit each — reviewing commit by commit is easier than reading the combined diff, since the CS Fixer sweep touches 31 files.
1. Restore backward compatibility with Doctrine ORM 2 (
db48196)#322 replaced the ORM constraint instead of widening it, which turned an additive feature into a BC break and would have forced a major release. This makes ORM 3 support additive, matching how Symfony 7 support shipped in v2.1.0:
All three
src/changes from #322 turned out to be BC already:Type::hasType()enableResultCache()toIterable()(dropping themethod_existsshim)Two things worth calling out:
^2.17, not^2.5. Upgraded to Doctrine ORM 3 #322 changed the specs to doubleDoctrine\ORM\Query(necessary, since ORM 3 declaresQueryBuilder::getQuery(): Query). That class wasfinalup to and including ORM 2.16 and only became non-final in 2.17.0 — on ORM 2.8.0 the suite gives 15 broken examples withcould not reflect class Doctrine\ORM\Query as it is marked final.symfony/polyfill-php80has to come back.src/Filter/Like.phpcallsstr_starts_with(),str_ends_with()andstr_contains(), which only exist on PHP 7.x through that polyfill.The same commit fixes the three failing test jobs:
PHP 8.4 + highest/PHP 8.4 + lowestcould not resolve at all — PHP 8.4 support only landed in phpspec^8.0.PHP 8.1 + lowestdied withPHP Fatal error: '\static' is an invalid class name, because--prefer-lowestresolved prophecy 1.14.0 while support for thestaticreturn type only arrived in 1.15.0, and ORM 3 usesstaticon its fluent setters. phpspec 7.x only requiresprophecy ^1.9, so the constraint has to be explicit.Restoring the PHP 7.2–8.0 matrix rows is also required for this branch's protection to stay satisfiable —
PHP 7.4 + highest + normalandPHP 8.0 + highest + normalare required status checks, and #322 deleted the jobs that report them.2. Fix PHPStan findings (
355c0b8)Pre-existing and unrelated to ORM 3. The QA job installs whatever phpstan is current, so the analysis got stricter over time while the code stood still — on a clean
2.x, phpstan 1.12 reported 3 errors and phpstan 2.2 reported 8.EntityRepositorydeclares@template T of object, so passing it an unboundedTresolved tomixed. Bounding both templates fixes all three generics errors at once.explode()never returns an empty array, soarray_pop()always yields a string and the null check was dead.substr()does not returnfalseon PHP 8. Only the PHPDoc is narrowed — adding: stringto the signature would break subclasses by covariance.treatPhpDocTypesAsCertain: falsesilences twoinstanceof.alwaysTruereports. Those guards are real — they catch untyped callers and throwInvalidArgumentException— so the check stays and the report goes.One residual: phpstan still reports one generics error against ORM 2.17–2.19, where
getClassMetadata()is annotated with@psalm-returnand@psalm-templatethat PHPStan does not read (ORM 2.20 changed those to@templateand@return). The QA job analyses the highest dependency set, so CI is unaffected.3. Apply PHP CS Fixer (
41eb296)Also pre-existing. The
@PhpCsFixerruleset has grown rules since the last sweep:static_lambda,single_line_empty_body,no_extra_blank_lines,whitespace_after_comma_in_array,ordered_imports,phpdoc_separationand a few more. On a clean2.xthis reported 40 files; #322 had already brought it down to 31 by reformatting the tests it touched. No behaviour change, and running the fixer again reports nothing.Verification
Ran locally on PHP 8.3:
include:variants.With this in, the branch should be fully green and ORM 3 support can ship as v2.2.0 rather than a major.