phpstan-drupal 2.1.0 graduates a set of opt-in rules and bleeding-edge behavior to the defaults. Expect new reported errors after upgrading — each change below includes the configuration to restore the old behavior.
Upgrading from 2.0
Nine rules are now enabled by default
testClassSuffixNameRule, dependencySerializationTraitPropertyRule, accessResultConditionRule, cacheableDependencyRule, hookFormAlterRule, loggerFromFactoryPropertyAssignmentRule, entityStorageDirectInjectionRule, symfonyYamlParseRule, and entityOperationsCacheabilityRule no longer require opt-in. Disable any of them individually:
parameters:
drupal:
rules:
cacheableDependencyRule: falseSee the README for what each rule reports.
hookRules renamed to hookFormAlterRule
If your configuration referenced hookRules, rename the key. The old name is no longer recognized.
ContainerInterface::has() returns bool for known services
containerHasAlwaysTrue now defaults to false, so conditional service guards are no longer reported as always-true. This graduated from bleedingEdge.neon. Restore the old inference:
parameters:
drupal:
bleedingEdge:
containerHasAlwaysTrue: trueloadInclude() checks now apply to concrete ModuleHandler receivers
An inverted type check made the LoadIncludes rule silently skip receivers typed as the concrete ModuleHandler class and fire on plain object/mixed receivers. Both directions are fixed, which may surface new loadIncludes.* errors in code that was previously skipped. Thanks @donquixote!
New
Opt out of class resolver return type narrowing
getInstanceFromDefinition() narrows to the passed class name, but the container can substitute a different class at runtime. Set classResolverReturnType: false to fall back to the declared object return type and keep instanceof assertions meaningful:
parameters:
drupal:
classResolverReturnType: falsedrupal-finder constraint widened
The webflo/drupal-finder constraint is now ^1.3.1 || ^2.0, so projects pick up drupal-finder 2.0 as soon as it releases. Nothing changes today — 1.3.1 remains the latest published version.
What's Changed
- Widen drupal-finder constraint and drop stale baseline entries by @mglaman in #999
- Promote 9 opt-in rules to default; rename hookRules to hookFormAlterRule by @mglaman in #1000
- Fix supertype condition in LoadIncludes. by @donquixote in #587
- Run CI on 2.0.x maintenance branch by @mglaman in #1002
- Allow disabling class resolver return type narrowing by @mglaman in #1003
- Make containerHasAlwaysTrue false by default by @mglaman in #1005
New Contributors
- @donquixote made their first contribution in #587
Full Changelog: 2.0.17...2.1.0