Skip to content

chore(quality): add PHPStan level 6 and php-cs-fixer, fix all findings#78

Merged
paullla merged 4 commits into
Locastic:masterfrom
paullla:chore/quality-gates
Jul 6, 2026
Merged

chore(quality): add PHPStan level 6 and php-cs-fixer, fix all findings#78
paullla merged 4 commits into
Locastic:masterfrom
paullla:chore/quality-gates

Conversation

@paullla

@paullla paullla commented Jul 6, 2026

Copy link
Copy Markdown
Member
Q A
Bug fix? no
New feature? no
BC breaks? yes (signature tightening, see UPGRADE-2.0.md)
Deprecations? no
Issues -
License MIT

Problem

The bundle has no static analysis or code-style enforcement. PHPStan at level 6 finds 40 issues, two of them real defects: AssignLocaleListener type-hints Doctrine\Common\EventArgs, which has no getObject() method (it only works because Doctrine passes a subclass), and Translator::setLocale() delegates to a method that TranslatorInterface does not declare.

Changes

  • php-cs-fixer with @Symfony + declare_strict_types (every file already declares it; the rule keeps it that way); mechanical fixes applied across all files.
  • PHPStan level 6 with the symfony and doctrine extensions, zero errors: listener signatures moved to Doctrine\Persistence\Event\LifecycleEventArgs (the type Doctrine actually dispatches), Translator now implements LocaleAwareInterface and requires a TranslatorInterface&LocaleAwareInterface wrapped translator (the default translator service qualifies), parameter types from the contracts on trans()/setLocale(), generics annotations on the Model relation and fixtures, and typed data-provider test methods.
  • Two scoped, counted PHPStan ignores where generics invariance rejects fixture specialization in the bidirectional translatable/translation relation.
  • New UPGRADE-2.0.md documenting the signature changes, plus the 2.0 constraint and enabled_locales changes already on master.
  • CI: new quality job (PHPStan + php-cs-fixer check) alongside the test matrix.

Verification

All three gates pass locally: bin/phpunit 45/45 on both highest and lowest resolved dependencies, bin/phpstan analyse reports zero errors, bin/php-cs-fixer check is clean.

paullla added 4 commits July 6, 2026 14:26
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.
@paullla paullla merged commit 8bc246c into Locastic:master Jul 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant