Skip to content

PHPStan Rules 14.18

Choose a tag to compare

@TomasVotruba TomasVotruba released this 09 Oct 09:36
· 30 commits to main since this release
707cdfd

Rules now run on PHP 7.4+, dependencies trimmed down, ForbiddenNodeRule split into dedicated rules, plus a batch of Symfony false-positive fixes.

New features 🎉

Run on PHP 7.4 and up

The ruleset now supports PHP 7.4 as minimum version, so it runs on legacy projects too - PHPStan itself supports 7.4+ (#338):

"require": {
    "php": ">=7.4"
}

Source is downgraded to 7.4 syntax; dev tooling stays on 8.x.

Dedicated ForbiddenTraitRule and ForbiddenSwitchRule

The generic ForbiddenNodeRule is replaced with two focused rules - ForbiddenTraitRule and ForbiddenSwitchRule (#342).

Fewer dependencies

nette/utils and webmozart/assert are replaced with entropy and native PHP (#337).


Bugfixes 🐛

  • [symfony] Skip data holders with public properties in NoNullableServiceInConstructorRule (#335)
  • [symfony] Skip enums, closures and exception classes in NoNullableServiceInConstructorRule (#333)
  • [symfony] Skip the Dto namespace in NoNullableServiceInConstructorRule (#325)
  • [symfony] Accept inherited contracts and method attributes in NoListenerWithoutContractRule (#334)
  • [symfony] Cover variable and new 2nd arg in SingleArgEventDispatchRule (#323)
  • [symfony] Skip Symfony-only rules that would misfire on Laravel projects (#331)
  • Allow plural Attributes namespace in RequireAttributeNamespaceRule (#329)
  • Widen accepted namespaces in CheckRequiredInterfaceInContractNamespaceRule (#328)
  • Skip abstract classes in ForbiddenStaticClassConstFetchRule (#324)
  • Allow multiple class-likes in test case file in ForbiddenMultipleClassLikeInOneFileRule (#322)

Removed 💀

  • Remove too strict PreferInlineTraitRule and its collectors (#344)
  • Remove too strict and unregistered NoProtectedClassStmtRule (#343)