NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #724 most downloaded on Packagist
Drupal extension and rules for PHPStan
Latest stable
2.4.0
Last release 13 days ago
09 Nov 2026
Release timing varies
gaps range from 8 days to 4 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
125 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Drupal 12 throws an exception for plugin managers that only support annotation discovery. Drupal 11.2 deprecated them with @trigger_error(), so no @de…
This release reports new errors by default. Expect them in modules with annotation-only plugin managers, and in code that calls \Drupal::entityQueryAggregate() without accessCheck().
Drupal 12 throws an exception for plugin managers that only support annotation discovery. Drupal 11.2 deprecated them with @trigger_error(), so no @deprecated tag reported them until now. phpstan-drupal reports a DefaultPluginManager subclass that passes an annotation class as the fifth argument to parent::__construct():
parent::__construct(
'Plugin/Example',
$namespaces,
$module_handler,
ExampleInterface::class,
Example::class, // An annotation class: reported.
);
To fix it, pass the attribute class as the fifth argument and keep the annotation class as the sixth. This works on Drupal 10.2 and later.
| Identifier | Reported when |
|---|---|
pluginManager.attributeDiscoveryMissing |
The argument is a ::class constant, a string, or a local variable holding one |
pluginManager.attributeDiscoveryMissingDefault |
The argument comes from a static property or a constructor parameter default |
Managers that pick the class at runtime, like class_exists(Attr::class) ? Attr::class : Annotation::class, are reported too, even though they work on Drupal 12. Ignore them by identifier. The README has an example.
phpstan-drupal's own deprecation rules now run only when phpstan/phpstan-deprecation-rules is loaded. That covers the plugin manager rules above, and the rules for deprecated services and the context plugin annotation key. They're still on by default, because phpstan-drupal requires phpstan-deprecation-rules.
If you turn off deprecation checks with the extension-installer ignore setting, these rules now turn off too. They have no drupal.rules.* parameters. To ignore one, use its identifier.
execute() on an aggregate query now returns list<array<string, string|null>>, one array per result row. It returned the entity ID type, array<int, string>, so code like array_column($rows, 'type') was reported as always empty.
\Drupal::entityQueryAggregate() gets the same type, and a missing accessCheck() on it is now reported, like on \Drupal::entityQuery().
bleedingEdge.neon now enables configGetUnknownKeyRule, which reports Config::get() calls with a key that isn't in the config schema.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.3.0...2.4.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
phpstan-drupal 2.3.0 requires phpstan/phpstan: ^2.3. If you're on an older PHPStan, Composer keeps you on phpstan-drupal 2.2.x until you upgrade PHPSt
phpstan-drupal 2.3.0 requires phpstan/phpstan: ^2.3. If you're on an older PHPStan, Composer keeps you on phpstan-drupal 2.2.x until you upgrade PHPStan.
On PHPStan 2.3, phpstan-drupal 2.2.x and earlier never invalidate the result cache when the Drupal site changes. After a services.yml change, a schema change, or adding or removing a module, PHPStan could keep reporting old results until the cache was cleared. If you're on PHPStan 2.3, upgrade to this release.
Changes to your Drupal site now re-analyze only the files they affect:
| Change | Files re-analyzed |
|---|---|
| A service definition | Files using that service |
A service's arguments or tags, or a new service nothing uses |
None |
| A schema file | Files reading config schema |
An .info.yml edit |
None |
A loadInclude() file created or changed |
Files loading it |
| A module or theme added, removed, or moved | All |
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.2.3...2.3.0
Ignore ResultCacheMetaExtension deprecation in our own analysis by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/1065
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.2.2...2.2.3
Do not report inherited entity storage constructor parameters (#1039) by @pfrenssen in https://github.com/mglaman/phpstan-drupal/pull/1055
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.2.1...2.2.2
Resolve every constant entity type ID in getStorage() return type by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/1045
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.2.0...2.2.1
Remove dead code and fix exception messages in legacy rules by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/1042
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.1.2...2.2.0
Ignore environment-dependent instanceof.alwaysTrue in getChildren() by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/1033
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.18...2.1.2
Add PathItem field type stub by @oiahoon in https://github.com/mglaman/phpstan-drupal/pull/1007
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.1.0...2.1.1
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 cha
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.
testClassSuffixNameRule, dependencySerializationTraitPropertyRule, accessResultConditionRule, cacheableDependencyRule, hookFormAlterRule, loggerFromFactoryPropertyAssignmentRule, entityStorageDirectInjectionRule, symfonyYamlParseRule, and entityOperationsCacheabilityRule no longer require opt-in. Disable any of them individually:
parameters:
drupal:
rules:
cacheableDependencyRule: false
See the README for what each rule reports.
hookRules renamed to hookFormAlterRuleIf your configuration referenced hookRules, rename the key. The old name is no longer recognized.
ContainerInterface::has() returns bool for known servicescontainerHasAlwaysTrue 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: true
loadInclude() checks now apply to concrete ModuleHandler receiversAn 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!
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: false
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.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.17...2.1.0
Add PathItem field type stub by @oiahoon in https://github.com/mglaman/phpstan-drupal/pull/1007
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.1.0...2.0.18
Config::get return type extension by @mstrelan in https://github.com/mglaman/phpstan-drupal/pull/993
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.16...2.0.17
Fix false positive when deprecation helper is inside functioncall by @bbrala in https://github.com/mglaman/phpstan-drupal/pull/989
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.15...2.0.16
Fix wrongly deprecated method RevisionableStorageInterface::loadRevision by @TheFakeCake in https://github.com/mglaman/phpstan-drupal/pull/980
2.1.0 is coming soon, which will enable some rules that are currently disabled by default. The rules can still be turned off. If you're worried about disruptions, change your Composer constraint to ~2.0.14 to avoid minor version bumps.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.14...2.0.15
2.1.0 is coming soon, which will enable some rules that are currently disabled by default. The rules can still be turned off. If you're worried about
2.1.0 is coming soon, which will enable some rules that are currently disabled by default. The rules can still be turned off. If you're worried about disruptions, change your Composer constraint to ~2.0.14 to avoid minor version bumps.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.13...2.0.14
Avoid marking scope deprecated if #[IgnoreDeprecations] has arguments by @mondrake in https://github.com/mglaman/phpstan-drupal/pull/926
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.12...2.0.13
Make FieldItemListPropertyReflection entity property nullable by @Niklan in https://github.com/mglaman/phpstan-drupal/pull/950
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.11...2.0.12
Add check for isPropertyHook method in IgnoreDeprecationsScope by @mondrake in https://github.com/mglaman/phpstan-drupal/pull/935
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.10...2.0.11
TimestamItem value is int by @znerol in https://github.com/mglaman/phpstan-drupal/pull/891
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.9...2.0.10
🐛 Narrow only by existing return types by @dpi in https://github.com/mglaman/phpstan-drupal/pull/903
RevisionableStorageInterface::deleteRevision should accept string ids by @dpi in https://github.com/mglaman/phpstan-drupal/pull/904getLinkTemplate by whether hasLinkTemplate was called beforehand by @dpi in https://github.com/mglaman/phpstan-drupal/pull/906getKey by whether hasKey was called beforehand by @dpi in https://github.com/mglaman/phpstan-drupal/pull/905Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.8...2.0.9
Add RevisionableStorageInterface::createRevision generic for return type by @dpi in https://github.com/mglaman/phpstan-drupal/pull/894
RevisionableStorageInterface::createRevision generic for return type by @dpi in https://github.com/mglaman/phpstan-drupal/pull/894Url::access return type changes depending on a parameter by @dpi in https://github.com/mglaman/phpstan-drupal/pull/896RevisionableStorageInterface::loadRevision should accept string ids by @dpi in https://github.com/mglaman/phpstan-drupal/pull/895Url::access and add tests by @dpi in https://github.com/mglaman/phpstan-drupal/pull/898EntityInterface->id() by previous calls to isNew on an instance of EntityInterface by @dpi in https://github.com/mglaman/phpstan-drupal/pull/900Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.7...2.0.8
Overridden EntityReferenceFieldItemListInterface::referencedEntities generics error by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/881
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.6...2.0.7
fix removal of CallToDeprecatedMethodRule in tests by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/875
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.5...2.0.6
2.x: Fix negation types for Inspector by @Niklan in https://github.com/mglaman/phpstan-drupal/pull/860
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.4...2.0.5
Fix 1.x branch support message by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/851
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.3...2.0.4
Remove pluginManagerSetsCacheBackend.unclearCacheTag error by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/841
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.2...2.0.3
ClassReflection deprecation fix by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/829
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.1...2.0.2
Add support for shorthand service definition syntax by @Niklan in https://github.com/mglaman/phpstan-drupal/pull/817
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/2.0.0...2.0.1
Improve error message for alterInfo in PluginManagerInspectionRule by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/799
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.1...2.0.0
Overridden EntityReferenceFieldItemListInterface::referencedEntities generics error by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/879
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.8...1.3.9
Stub ItemList::getIterator return type (1.x) by @Niklan in https://github.com/mglaman/phpstan-drupal/pull/869
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.7...1.3.8
1.x: Fix negation types for Inspector by @Niklan in https://github.com/mglaman/phpstan-drupal/pull/861
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.6...1.3.7
Fixes for InspectorTypeExtension by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/855
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.5...1.3.6
Remove pluginManagerSetsCacheBackend.unclearCacheTag error by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/843
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.4...1.3.5
Fix AccessCheckImpossibleTypeCallRuleTest rule setup by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/833
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.3...1.3.4
Add support for shorthand service definition syntax by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/819
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.2...1.3.3
Improve error message for alterInfo in PluginManagerInspectionRule by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/799
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.1...1.3.2
~ is not null in Neon by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/800
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.3.0...1.3.1
The drupal_root parameter is now unused and deprecated; if you are using it, you may remove it from your phpstan.neon. The web flow/drupal-finder pack…
The drupal_root parameter is now unused and deprecated; if you are using it, you may remove it from your phpstan.neon. The web flow/drupal-finder package has been updated to 1.3, removing the need for the drupal_root parameter.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.12...1.3.0
New bleeding edge toggles for checking deprecated hooks:
New bleeding edge toggles for checking deprecated hooks:
Use the following to check your code for usage of deprecated hooks in Drupal core
parameters:
drupal:
bleedingEdge:
checkCoreDeprecatedHooksInApiFiles: true
checkContribDeprecatedHooksInApiFiles: false
Use the following to also check for usage of deprecated hooks in contributed modules (may break if they have malformed .api.php files)
parameters:
drupal:
bleedingEdge:
checkCoreDeprecatedHooksInApiFiles: true
checkContribDeprecatedHooksInApiFiles: true
The previous toggle checkDeprecatedHooksInApiFiles is deprecated.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.11...1.2.12
Accept deprecations from webflo/drupal-finder 1.3 by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/758
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.10...1.2.11
Allow services.yml to contain custom tags by @longwave in https://github.com/mglaman/phpstan-drupal/pull/743
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.9...1.2.10
Add EntityRepositoryInterface return type extension by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/739
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.8...1.2.9
Add DependencySerializationTraitPropertyRule by @MakerTim in https://github.com/mglaman/phpstan-drupal/pull/731
Enable these rules by turning them on in your phpstan.neon:
parameters:
drupal:
dependencySerializationTraitPropertyRule: true
accessResultConditionRule: true
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.7...1.2.8
TestClassSuffixNameRule by @Boegie in https://github.com/mglaman/phpstan-drupal/pull/609
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.6...1.2.7
…parameters from the analyzer scope, enabling a DeprecationHelper deprecated scope resolver.
PHPStan requirement has been bumped to 1.10.56 for accessing the function stack with parameters from the analyzer scope, enabling a DeprecationHelper deprecated scope resolver.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.5...1.2.6
Deprecation fixed for loadRevison on RevisionableStorageInterface by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/712
The phpstan-drupal playground code has been moved to https://github.com/mglaman/phpstan-drupal-playground/
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.4...1.2.5
The deprecated hook implementation rule (https://github.com/mglaman/phpstan-drupal/pull/634) is now behind a bleeding edge flag, resolving errors user…
The deprecated hook implementation rule (https://github.com/mglaman/phpstan-drupal/pull/634) is now behind a bleeding edge flag, resolving errors users experienced with the last release.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.3...1.2.4
Implement a rule to check deprecated hook implementations by @Kingdutch in https://github.com/mglaman/phpstan-drupal/pull/634
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.2...1.2.3
This patch release fixes some issues caused by service decoration support
This patch release fixes some issues caused by service decoration support (https://github.com/mglaman/phpstan-drupal/pull/615)
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.1...1.2.2
Detect public static $modules when it should be protected static $modules in tests by @Boegie in https://github.com/mglaman/phpstan-drupal/pull/597
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.2.0...1.2.1
Adds phpstan/phpstan-deprecation-rules as a direct dependency and minimum version of 1.1.4. This allows ignoring deprecation warnings inside PHPUnit t…
Adds phpstan/phpstan-deprecation-rules as a direct dependency and minimum version of 1.1.4. This allows ignoring deprecation warnings inside PHPUnit tests using @group legacy for the Symfony PHPUnit Bridge.
@group legacy deprecated scope resolver by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/595Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.37...1.2.0
Add translatable interface stub for content entities by @simonbaese in https://github.com/mglaman/phpstan-drupal/pull/588
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.36...1.1.37
RenderCallbackRule should use ObjectType for service class instance by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/582
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.35...1.1.36
Support RevisionableStorageInterface and methods ::loadRevision() and ::deleteRevision() deprecation by @mglaman in https://github.com/mglaman/phpstan…
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.34...1.1.35
This release fixes `EntityFieldReflection` from causing stub files with `@property` annotations on entity type classes from being ignored!
This release fixes EntityFieldReflection from causing stub files with @property annotations on entity type classes from being ignored!
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.33...1.1.34
Add Drupal core baseline check by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/554
set-output commands by @Boegie in https://github.com/mglaman/phpstan-drupal/pull/567Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.32...1.1.33
Support concatenated callables in RenderCallbackRule by @Boegie in https://github.com/mglaman/phpstan-drupal/pull/544
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.31...1.1.32
Update to "actions/checkout@v3" and thus node.js 16 by @Boegie in https://github.com/mglaman/phpstan-drupal/pull/537
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.30...1.1.31
Add baseline for PHPStan 1.10 new deprecations by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/518
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.29...1.1.30
Add stub validation test, fix stubs by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/511
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.28...1.1.29
One column per quarter.