Skip to content

PHPStan Rules 14.16

Choose a tag to compare

@TomasVotruba TomasVotruba released this 24 Sep 12:20
· 52 commits to main since this release
de06599

Rule sets are now toggleable from a single symplify parameter, 4 too-narrow Symfony rules are gone, and a batch of false positives is fixed across Symfony, Doctrine, PHPUnit and the ctor rules.

New features 🎉

Toggle whole rule sets on/off

Naming, complexity, configurable and static sets are now auto-loaded via phpstan/extension-installer and gated by a parameter - all on by default, so no behavior change on upgrade (#301, #304):

parameters:
    symplify:
        naming: false
        complexity: false
        configurable: false
        static: false

RequireExceptionNamespaceRule, RequireAttributeNamespaceRule and CheckRequiredInterfaceInContractNamespaceRule moved from static-rules.neon to naming-rules.neon.

⚠️ naming-rules.neon is auto-loaded now - drop its manual include from your phpstan.neon to avoid double registration.


Bugfixes 🐛

  • [symfony] Make NoFindTaggedServiceIdsCallRule context-aware - skip when foreach reads tag attributes, e.g. $tags[0]['alias'] (#317)
  • [symfony] Skip NoFindTaggedServiceIdsCallRule in test classes (#309)
  • [symfony] Allow 2nd dynamic arg in SingleArgEventDispatchRule (#310)
  • [doctrine] Skip #[AsDoctrineListener] attribute in NoDoctrineListenerWithoutContractRule (#318)
  • [doctrine] Scope RequireQueryBuilderOnRepositoryRule to repository classes only (#306)
  • [doctrine] Skip unconvertible builders in RequireQueryBuilderOnRepositoryRule (#312)
  • [doctrine] Suggest fetching repository from test container in test classes (#305)
  • [phpunit] Skip variable-callable in NoAssertFuncCallInTestsRule (#311)
  • [ctor] NewOverSettersRule - skip Doctrine entities with #[ORM\Entity] (#307), controllers (#313) and test classes (#314), add regression test for setter in loop (#316)
  • Fix NoReferenceRule false positive when parent class is not first in its file (#292), thanks @SanderMuller

Removed 💀

  • [symfony] Remove NoRequiredOutsideClassRule, too narrow (#315)
  • [symfony] Remove RequiredOnlyInAbstractRule, does not fit project context (#308)
  • [symfony] Remove PreferAutowireAttributeOverConfigParamRule, too opinionated (#303)
  • [symfony] Remove NoAbstractControllerConstructorRule, too strict (#302)