Repository navigation
New
- More usages of classes, interfaces, enums and traits disallowed with
disallowedClassesordisallowedNamespacesare reported:instanceof, first-class callables likeFoo::bar(...), DNF types like(A&B)|null, types of class constants, and interfaces extended by interfaces or implemented by enums (#444) - Disallowed names are labelled by what they are,
Class,Interface(with the newdisallowed.interfaceidentifier),EnumorTrait, also in static calls,extendsandimplements, which saidNamespacebefore; onlyuseimports keepNamespacebecause they can also import a namespace (#440, #443 - possible BC break) - Property hooks are treated like methods by the attribute-based directives: an attribute placed on a hook counts as used in the hook, and
allowInClassWithMethodAttributessees attributes on hooks; matching hooks by name likeFoo::$bar::get()inallowInMethodsis now documented (#441, #445)
Bugfixes
- A disallowed enum case or constant like
Suit::Heartswas reported twice, as a class and as an enum, now it's reported once asEnum(#440) - A disallowed item used in a property hook crashed the analysis with
ReflectionExceptionwhen the config hadallowInMethodsWithAttributes,allowExceptInMethodsWithAttributesor their aliases (#441) - A disallowed item used in a named function declared inside another function or method caused "Reflection error" with the same directives, and the rest of the file wasn't analysed (#442)
self::,static::andparent::calls aren't reported asNamespace self is forbidden.anymore when a wildcard pattern happens to match them (#443)str_contains()isn't used anymore, it doesn't exist on PHP 7.4 (#436)
Internal changes
- No errors with PHPStan 2.3, which analyses for the lowest PHP version in
composer.json(#439) - Testing on PHP 8.6 (#438)
PHPStan1Compatibilityrenamed toPHPStanCompatibility, because it covers older PHPStan 2.x versions too (#441)- The e2e workflow follows the moved monorepo dev tools (#437)
Possible BC break note: messages and identifiers changed for static calls, extends and implements (Namespace/disallowed.namespace is now Class, Interface, Enum or Trait), for interfaces and traits anywhere else (Class/disallowed.class is now Interface/disallowed.interface or Trait/disallowed.trait), and for enums in type declarations (Class is now Enum). The duplicate Class error for enum cases and constants is gone. If you match these errors in ignoreErrors or a baseline, they may need updating, and the newly reported usages can add errors.