chore(quality): add PHPStan level 6 and php-cs-fixer, fix all findings#78
Merged
Conversation
Config is @symfony plus declare_strict_types (every file already declares it; the rule keeps it that way). All changes are mechanical.
Type fixes surfaced by the analysis, no behavior changes: - AssignLocaleListener signatures move from Doctrine\Common\EventArgs (which has no getObject()) to Doctrine\Persistence\Event\ LifecycleEventArgs, the type Doctrine actually dispatches. - Translator now implements LocaleAwareInterface and requires the wrapped translator to be TranslatorInterface&LocaleAwareInterface: setLocale() delegated to a method TranslatorInterface does not declare. trans() and setLocale() get their parameter types from the contracts. - Generics annotations on the translatable <-> translation relation and the test fixtures; parameter types on all data-provider test methods. - Two scoped ignores where generics invariance rejects fixture specialization; both signature changes are recorded in UPGRADE-2.0.md.
New quality job on PHP 8.4 alongside the test matrix. The lowest-deps leg does not run the tools: their floor is only exercised where it is actually used.
The cache file was staged by accident before it was gitignored; the ignore entry alone does not untrack it.
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.
Problem
The bundle has no static analysis or code-style enforcement. PHPStan at level 6 finds 40 issues, two of them real defects:
AssignLocaleListenertype-hintsDoctrine\Common\EventArgs, which has nogetObject()method (it only works because Doctrine passes a subclass), andTranslator::setLocale()delegates to a method thatTranslatorInterfacedoes not declare.Changes
@Symfony+declare_strict_types(every file already declares it; the rule keeps it that way); mechanical fixes applied across all files.Doctrine\Persistence\Event\LifecycleEventArgs(the type Doctrine actually dispatches),Translatornow implementsLocaleAwareInterfaceand requires aTranslatorInterface&LocaleAwareInterfacewrapped translator (the defaulttranslatorservice qualifies), parameter types from the contracts ontrans()/setLocale(), generics annotations on the Model relation and fixtures, and typed data-provider test methods.UPGRADE-2.0.mddocumenting the signature changes, plus the 2.0 constraint and enabled_locales changes already on master.qualityjob (PHPStan +php-cs-fixer check) alongside the test matrix.Verification
All three gates pass locally:
bin/phpunit45/45 on both highest and lowest resolved dependencies,bin/phpstan analysereports zero errors,bin/php-cs-fixer checkis clean.