mglaman/phpstan-drupal
Drupal extension and rules for PHPStan
2.1.2
33M downloads/mo
#736 most downloaded on Packagist
mglaman/phpstan-drupal
What this package is like to depend on
Last release 10 days ago
13 Aug 2026
Release timing varies
gaps range from 2 weeks to 4 months
Rarely documented
notes for 10 of 119 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
119 releases · first in 2019
12 releases in the last 12 months
see the full history below
Release timeline
119 releases · Jan 2019 to Aug 2026Releases
latest 60 of 119-
2.1.213 Aug 2026Release notes
Open source →What's Changed
- Ignore environment-dependent instanceof.alwaysTrue in getChildren() by @mglaman in #1033
- Do not crash on first-class callables or missing args in getStorage() by @mglaman in #1026
- Harden include-loading rules against masked failures by @mglaman in #1034
- Do not fatal when a shorthand service class cannot be loaded by @mglaman in #1023
Full Changelog: 2.0.18...2.1.2
-
2.1.117 Jul 2026Release notes
Open source →What's Changed
- Add PathItem field type stub by @oiahoon in #1007
- Fix readonly false positive in DependencySerializationTraitPropertyRule by @mglaman in #1010
- Test against Drupal 11.4 and PHP 8.5, drop EOL 11.2 by @mglaman in #1011
- Fix never type for dynamic container service IDs by @mglaman in #1014
New Contributors
Full Changelog: 2.1.0...2.1.1
-
2.1.014 Jul 2026Release notes
Open source →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, andentityOperationsCacheabilityRuleno longer require opt-in. Disable any of them individually:parameters: drupal: rules: cacheableDependencyRule: false
See the README for what each rule reports.
hookRulesrenamed tohookFormAlterRuleIf your configuration referenced
hookRules, rename the key. The old name is no longer recognized.ContainerInterface::has()returnsboolfor known servicescontainerHasAlwaysTruenow defaults tofalse, so conditional service guards are no longer reported as always-true. This graduated frombleedingEdge.neon. Restore the old inference:parameters: drupal: bleedingEdge: containerHasAlwaysTrue: true
loadInclude()checks now apply to concreteModuleHandlerreceiversAn inverted type check made the
LoadIncludesrule silently skip receivers typed as the concreteModuleHandlerclass and fire on plainobject/mixedreceivers. Both directions are fixed, which may surface newloadIncludes.*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. SetclassResolverReturnType: falseto fall back to the declaredobjectreturn type and keepinstanceofassertions meaningful:parameters: drupal: classResolverReturnType: false
drupal-finder constraint widened
The
webflo/drupal-finderconstraint 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
-
2.0.1817 Jul 2026Release notes
Open source →What's Changed
- Add PathItem field type stub by @oiahoon in #1007
- Fix readonly false positive in DependencySerializationTraitPropertyRule by @mglaman in #1010
- Test against Drupal 11.4 and PHP 8.5, drop EOL 11.2 by @mglaman in #1011
- Fix never type for dynamic container service IDs by @mglaman in #1014
New Contributors
Full Changelog: 2.1.0...2.0.18
-
2.0.1713 Jul 2026 -
2.0.1630 Jun 2026Release notes
Open source →What's Changed
- Fix InspectorTypeExtensionTest failure with PHPStan HEAD by @mglaman in #991
- Allow symfony/runtime plugin to be blocked in composer config by @mglaman in #990
- Fix false positive when deprecation helper is inside functioncall by @bbrala in #989
- Bump actions/checkout from 6 to 7 by @dependabot[bot] in #994
- Bump actions/cache from 5 to 6 by @dependabot[bot] in #997
Full Changelog: 2.0.15...2.0.16
-
2.0.1524 Apr 2026Release notes
Open source →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.14to avoid minor version bumps.What's Changed
- Fix hook_entity_operation cacheability parameter should not be nullable by @mglaman in #985
- Fix false positive in entityStoragePropertyAssignment rule when assigning null by @mglaman in #986
- Fix ContainerInterface::has() returning always-true for known services by @mglaman in #987
- Fix wrongly deprecated method RevisionableStorageInterface::loadRevision by @TheFakeCake in #980
New Contributors
- @TheFakeCake made their first contribution in #980
Full Changelog: 2.0.14...2.0.15
-
2.0.1422 Apr 2026Release notes
Open source →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.14to avoid minor version bumps.What's Changed
- Fix multisite extension discovery by scanning all sites/*/ directories by @dpagini in #956
- Add stubs for daterange field type by @ceesgeene in #786
- Infer return type from class-string in ClassResolver extensions by @mglaman in #965
- Fix inverted isCount cache key logic in EntityQueryType by @mglaman in #966
- Add LoggerFromFactoryPropertyAssignmentRule by @mglaman in #968
- Add EntityStorageDirectInjectionRule by @mglaman in #969
- Document opt-in rules and bleedingEdge parameters by @mglaman in #970
- Add entity-type-id custom PHPDoc type by @mglaman in #972
- Allow \Drupal usage check on render elements by @mglaman in #973
- Fix InspectorTypeExtension compatibility with PHPStan 2.1.47 mixed~null type by @mglaman in #976
- Move phpstan_fixtures test data to tests/src/Rules/data by @mglaman in #974
- Add rule to detect Symfony\Component\Yaml\Yaml::parse() usage by @mglaman in #978
- Add rules to detect missing CacheableMetadata parameter in entity operation methods and hooks by @mglaman in #979
New Contributors
Full Changelog: 2.0.13...2.0.14
-
2.0.1307 Apr 2026Release notes
Open source →What's Changed
- Fix FormatterInterfaceGenericTest assertions for unparameterized formatter by @marklabrecque-ab in #959
- Allow all magic properties on FieldItemListInterface by @marklabrecque-ab in #958
- Avoid marking scope deprecated if #[IgnoreDeprecations] has arguments by @mondrake in #926
- Bump ramsey/composer-install from 3 to 4 by @dependabot[bot] in #949
- Specify generic type on $list by @mxr576 in #948
- Fix $offset type in ItemList::offsetExists by @mstrelan in #914
New Contributors
- @marklabrecque-ab made their first contribution in #959
- @mstrelan made their first contribution in #914
Full Changelog: 2.0.12...2.0.13
-
2.0.1220 Mar 2026Release notes
Open source →What's Changed
- Make FieldItemListPropertyReflection entity property nullable by @Niklan in #950
- Fix method.alreadyNarrowedType from all QueryInterface::accessCheck()s (#825) by @travis-bradbury in #951
- Use container to resolve PHPStan built-in rules in tests by @mglaman in #954
- Add TodoCommentWithIssueUrlRule to flag @todo comments referencing the current issue by @mglaman in #953
New Contributors
- @travis-bradbury made their first contribution in #951
Full Changelog: 2.0.11...2.0.12
-
2.0.1125 Feb 2026Nothing published for this version
-
2.0.1022 Oct 2025Nothing published for this version
-
2.0.905 Aug 2025Nothing published for this version
-
2.0.804 Aug 2025Nothing published for this version
-
2.0.722 May 2025Nothing published for this version
-
2.0.620 May 2025Nothing published for this version
-
2.0.515 Apr 2025Nothing published for this version
-
2.0.410 Apr 2025Nothing published for this version
-
2.0.303 Apr 2025Nothing published for this version
-
2.0.227 Mar 2025Nothing published for this version
-
2.0.117 Jan 2025Nothing published for this version
-
2.0.011 Dec 2024Nothing published for this version
-
1.3.922 May 2025Nothing published for this version
-
1.3.820 May 2025Nothing published for this version
-
1.3.715 Apr 2025Nothing published for this version
-
1.3.610 Apr 2025Nothing published for this version
-
1.3.503 Apr 2025Nothing published for this version
-
1.3.427 Mar 2025Nothing published for this version
-
1.3.323 Jan 2025Nothing published for this version
-
1.3.219 Nov 2024Nothing published for this version
-
1.3.127 Sep 2024Nothing published for this version
-
1.3.027 Sep 2024Nothing published for this version
-
1.2.1207 Aug 2024Nothing published for this version
-
1.2.1110 May 2024Nothing published for this version
-
1.2.1002 Apr 2024Nothing published for this version
-
1.2.922 Mar 2024Nothing published for this version
-
1.2.821 Mar 2024Nothing published for this version
-
1.2.714 Feb 2024Nothing published for this version
-
1.2.616 Jan 2024Nothing published for this version
-
1.2.510 Jan 2024Nothing published for this version
-
1.2.414 Nov 2023Nothing published for this version
-
1.2.313 Nov 2023Nothing published for this version
-
1.2.209 Nov 2023Nothing published for this version
-
1.2.103 Nov 2023Nothing published for this version
-
1.2.024 Aug 2023Nothing published for this version
-
1.1.3725 Jul 2023Nothing published for this version
-
1.1.3628 Jun 2023Nothing published for this version
-
1.1.3514 Jun 2023Nothing published for this version
-
1.1.3424 May 2023Nothing published for this version
-
1.1.3317 May 2023Nothing published for this version
-
1.1.3210 May 2023Nothing published for this version
-
1.1.3127 Apr 2023Nothing published for this version
-
1.1.3007 Apr 2023Nothing published for this version
-
1.1.2908 Feb 2023Nothing published for this version
-
1.1.2801 Feb 2023Nothing published for this version
-
1.1.2725 Jan 2023Nothing published for this version
-
1.1.2622 Dec 2022Nothing published for this version
-
1.1.2518 Jul 2022Nothing published for this version
-
1.1.2414 Jul 2022Nothing published for this version
-
1.1.2314 Jul 2022Nothing published for this version