NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
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.
False negative accessCheck failure on non-chained entity queries by @Boegie in https://github.com/mglaman/phpstan-drupal/pull/497
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.27...1.1.28
False negative accessCheck failure on entity queries with entity type coming from parameter by @Boegie in https://github.com/mglaman/phpstan-drupal/pu
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.26...1.1.27
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Replace deprecated PHPStan\Type\Constant\ConstantArrayType::findTypeAndMethodName() call by @mxr576 in https://github.com/mglaman/phpstan-drupal/pull/…
PHPStan\Type\Constant\ConstantArrayType::findTypeAndMethodName() call by @mxr576 in https://github.com/mglaman/phpstan-drupal/pull/485EntityReferenceFieldItemListInterface::referencedEntities to work with generic by @dpi in https://github.com/mglaman/phpstan-drupal/pull/478EntityQueryWithoutAccessRule rule message to use full Drupal message by @goba in https://github.com/mglaman/phpstan-drupal/pull/469REQUEST_TIME pushed to 11.0.0 removal by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/491Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.25...1.1.26
This reduces the noise by only reporting an error when using the method deprecated in Symfony 5 and removed in Symfony 6.
Quick patch release following up on the RequestStack forward compatibility shim work in https://github.com/mglaman/phpstan-drupal/pull/446. This reduces the noise by only reporting an error when using the method deprecated in Symfony 5 and removed in Symfony 6.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.24...1.1.25
Add generic callable check for RenderCallbackRule by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/453
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.23...1.1.24
Includes a hotfix for 1.1.22 to fix SymfonyCmfRoutingInClassMethodSignatureRule
Includes a hotfix for 1.1.22 to fix SymfonyCmfRoutingInClassMethodSignatureRule
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.22...1.1.23
add support for class string service ids by @laytan in https://github.com/mglaman/phpstan-drupal/pull/434
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.21...1.1.22
Allow PHPStan 1.6 by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/435
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.20...1.1.21
Add missing stub dependency stubs by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/430
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.19...1.1.20
Replace AccessibleReturnTypeExtension with stub for AccessibleInterface by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/419
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.18...1.1.19
Add stubs for ContentEntityInterface and FieldableEntityInterface by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/413
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.17...1.1.18
Fixes with #409 allow using PHPStan without the rich node parser.
Fixes with #409 allow using PHPStan without the rich node parser.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.16...1.1.17
Entity query count and accessCheck order should not matter by @brambaud in https://github.com/mglaman/phpstan-drupal/pull/382
rules.neon by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/389Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.15...1.1.16
Report missing explicit access check on entity queries by @brambaud in https://github.com/mglaman/phpstan-drupal/pull/378
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.14...1.1.15
Move getQuery method return type to own extension by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/372
rules out of services by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/375Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.13...1.1.14
Add field type stubs for file module by @xendk in https://github.com/mglaman/phpstan-drupal/pull/354
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.12...1.1.13
FIXUP: Perform \Drupal::VERSION check for deprecated constants by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/350
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.11...1.1.12
Drupal 9.3.x and 9.4.x deprecated more global constants. The rule to check for these has been updated.
Field types provided by Drupal core have been stubbed to provide @property annotations. If you have a field value and it has been type hinted, PHPStan will not complain about accessing a non-existent property.
Example:
// EntityReferenceItem.
$entity_reference_field = $node->get('field_entity_reference')->first();
assert($entity_reference_field instanceof EntityReferenceItem);
assertType(EntityReferenceItem::class, $entity_reference_field);
assertType('int|string', $entity_reference_field->target_id);
assertType('Drupal\Core\Entity\EntityInterface', $entity_reference_field->entity);
Drupal 9.3.x and 9.4.x deprecated more global constants. The rule to check for these has been updated.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.10...1.1.11
Proper return type for config entity queries by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/309
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.9...1.1.10
This relaxes the constraints so that phpstan-drupal can be installed on the Drupal 10.0.x branch.
This relaxes the constraints so that phpstan-drupal can be installed on the Drupal 10.0.x branch.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.8...1.1.9
The RenderCallbackRule added in 1.1.5 had various flaws. This release should fix them:
The RenderCallbackRule added in 1.1.5 had various flaws. This release should fix them:
#access_callback – not an array, single callable.#lazy_builder – an array, but of call_user_func_array values ([callable, args])service_name:method style callbacks were not parsed, now they areFull Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.7...1.1.8
Remove nette/finder for symfony/finder (reusing Drupal dependencies) by @alexpott in https://github.com/mglaman/phpstan-drupal/pull/297
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.6...1.1.7
Fix/render callback by @alexpott in https://github.com/mglaman/phpstan-drupal/pull/292
Hotfix.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.5...1.1.6
Require PHP ^7.4 by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/290
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.4...1.1.5
Add phpstan prophecy suggestion by @ptt-homme in https://github.com/mglaman/phpstan-drupal/pull/282
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.3...1.1.4
Expand list of entity type storages by @ptt-homme in https://github.com/mglaman/phpstan-drupal/pull/277
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.2...1.1.3
With #264 we have added the ability to look up discovered extensions, which should greatly improve the rules which load files called by module_load_in
With #264 we have added the ability to look up discovered extensions, which should greatly improve the rules which load files called by module_load_include and ModuleHandlerInterface::loadInclude. Previously these two rules had to re-scan for extensions whenever the function or method was analyzed.
@internal by @brambaud in https://github.com/mglaman/phpstan-drupal/pull/248@property annotations on Entity classes by @jacktonkin in https://github.com/mglaman/phpstan-drupal/pull/268Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.1...1.1.2
This release includes fixes for Class PHPUnit\Framework\TestCase not found. errors!
drupal/core-devThis release includes fixes for Class PHPUnit\Framework\TestCase not found. errors!
Note you must have this in your phpstan.neon if drupal/core-dev is missing:
excludePaths:
- */tests/src/*/*.php
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.1.0...1.1.1
1.1.0 has introduced a breaking change in the configuration schema. See below for more information.
1.1.0 has introduced a breaking change in the configuration schema. See below for more information.
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.0.3...1.1.0
The drupal.entityTypeStorageMapping allowed specifying what storage classes were used for different entity types. With #239, support was added to specify what entity class an entity type uses. With #250 the way entity type information is configured has been changed.
Previously:
parameters:
drupal:
entityTypeStorageMapping:
node: Drupal\node\NodeStorage
taxonomy_term: Drupal\taxonomy\TermStorage
user: Drupal\user\UserStorage
Now there is an entityMapping property so that we can handle future enhancements with entity type static analysis.
parameters:
drupal:
entityMapping:
node:
class: Drupal\node\Entity\Node
storage: Drupal\node\NodeStorage
taxonomy_term:
class: Drupal\taxonomy\Entity\Term
storage: Drupal\taxonomy\TermStorage
user:
class: Drupal\user\Entity\User
storage: Drupal\user\UserStorage
block:
class: Drupal\block\Entity\Block
Use isSuperTypeOf to detect if module handler by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/233
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.0.2...1.0.3
Ignore defaultTheme on abstract test classes by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/230
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.0.1...1.0.2
Fix remaining test and analysis errors by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/219
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/1.0.0...1.0.1
🥳 PHPStan 1.0 by @mglaman in https://github.com/mglaman/phpstan-drupal/pull/214
Full Changelog: https://github.com/mglaman/phpstan-drupal/compare/0.12.15...1.0.0
Dynamic return type extension for \Drupal::service #190
🥳 Features:
Detect when deprecated services are fetched from the container #205
🥳 Features:
🛠 Task:
Update ConfigEntityConfigExportRule to only run if the ConfigEntity class is annotated (not just with a phpDoc present) #200
🐞 Bug fix:
Verify that BrowserTestBase::$defaultTheme is populated by child class #191
🥳 Features:
🐞 Bug fix:
This patch release adds new rules to help catch deprecations from Drupal 8 to Drupal 9 in context-aware plugins and config entities. See https://www.d…
This patch release adds new rules to help catch deprecations from Drupal 8 to Drupal 9 in context-aware plugins and config entities. See https://www.drupal.org/project/upgrade_status/issues/3161052
🥳 Features:
🐞 Bug fixes: * #175: Fixes crashes on GlobalDrupalDependencyInjectionRule and autoloading when PHPUnit does not exist. *Note*: PHPStan still warns abo
🐞 Bug fixes:
GlobalDrupalDependencyInjectionRule and autoloading when PHPUnit does not exist. Note: PHPStan still warns about autoloading and symbol discovery, still, but not crash.🥳 Features:
Thank you to my sponsors that make these releases possible:
Use PHPUnit\Framework\Test interface instead of TestCase class [#160]
Use PHPUnit\Framework\Test interface instead of TestCase class [#160]
Releases PHPStan ^0.12.64, which includes a fix in PHP-Parser for optional attributes in traits.
Releases PHPStan ^0.12.64, which includes a fix in PHP-Parser for optional attributes in traits.
See https://github.com/mglaman/phpstan-drupal/issues/152 for details.
Update list of deprecated Drupal constants
#128 Adds a rule that fixes loading modules via \Drupal\Core\Extension\ModuleHandlerInterface::loadInclude, which are normally skipped (as PHPStan onl
#128 Adds a rule that fixes loading modules via \Drupal\Core\Extension\ModuleHandlerInterface::loadInclude, which are normally skipped (as PHPStan only handles require, etc.)
Fix #129 for phpstan 0.12.26. Fix #125, #112
Fix #129 for phpstan 0.12.26. Fix #125, #112
Fix for "Move deprecation of REQUEST_TIME to Drupal 10", https://www.drupal.org/node/3113284
Fix for "Move deprecation of REQUEST_TIME to Drupal 10", https://www.drupal.org/node/3113284
#106: Fix default drupal.drupal_root parameter value #107: PHPUnit tests run at PHPStan config level 4 #110: Fix type union for app.root #111: Fix aut
#106: Fix default drupal.drupal_root parameter value
#107: PHPUnit tests run at PHPStan config level 4
#110: Fix type union for app.root
#111: Fix autoloading theme-settings.php files
Use the %currentWorkingDirectory% container parameter to default the location detection of Drupal for the drupal.drupal_root parameter, fixing #104
Use the %currentWorkingDirectory% container parameter to default the location detection of Drupal for the drupal.drupal_root parameter, fixing #104
Nothing published for this version
@goba added all deprecated constants for detection!
Discover deprecations on constants, based on hardcoded mappings.
Drupal 8.8 build test analysis support
Drupal 8.8 build test analysis support
Nothing published for this version
Support phpstan/extension-installer, thanks @drupol!
Support phpstan/extension-installer, thanks @drupol!
Fix double loading of files which broke upgrade_status
Add compatibility for Drush 8.x version
Gracefully handle ContainerNotInitializedException errors or other errors when loading the following files for an extension:
Gracefully handle ContainerNotInitializedException errors or other errors when loading the following files for an extension:
.theme, .module, .profile.install.post_update.php*.incEntities: Allow FieldItemList access through magic __get/__set methods
Fix autoloading of test base classes
Fix autoloading of test base classes (#60)
Add drupal_root parameter support
drupal_root parameter supportOne column per quarter.