Problem/Motivation
The phpstan-drupal package update on 2026-07-14 introduced new lint rules that flag 32 pre-existing code patterns in Patternkit. The 9.1.x branch passed PHPStan on 2026-07-13 and now fails with 32 errors. None of the violations were introduced by any recent code change to 9.1.x.
This is a contributor-facing regression: any MR opened against 9.1.x will fail PHPStan CI until this issue is resolved.
The phpstan-drupal package update introduced rules in the following categories:
drupal.entityStoragePropertyAssignment(17 occurrences): entity storage stored as a class property instead of resolved at call sitedrupal.entityStorageDirectInjection(5 occurrences): entity storage injected directly instead of via EntityTypeManagermethod.deprecatedClass/classConstant.deprecatedClass(14 occurrences): references toReusableBlockHooks, deprecated in 9.1.2return.type(4 occurrences): return type mismatches inPatternUsageManagerdependencySerializationTraitProperty.unsupportedReadOnlyProperty(1 occurrence):readonlyproperty incompatible withDependencySerializationTraitdependencySerializationTraitProperty.unsupportedPrivateProperty(1 occurrence): private property incompatible withDependencySerializationTraitnonAbstractTestClass.NameNoSuffixTest(1 occurrence): test base class name lacks aTestsuffix and is not abstract- Other (3 occurrences):
staticMethod.deprecated,globalDrupalDependencyInjection.useDependencyInjection,encapsedStringPart.nonString
The affected files span the main module and the patternkit_usage_tracking submodule. All violations are pre-existing. The new rules expose long-standing patterns rather than any new code.
Proposed resolution
Each violation category requires individual assessment before deciding between an inline fix or a justified baseline entry.
The recommended approach:
- Fix violations that are safe and low-risk to correct inline. The deprecated
ReusableBlockHooksreferences and the test class naming issue are good candidates. - Baseline violations where the fix requires architectural changes that are outside the scope of a CI hotfix. The
entityStoragePropertyAssignmentpatterns across 17 locations fall into this category. - Document the rationale for each baseline entry in the phpstan baseline file so future contributors understand why the suppression exists.
- Open follow-up issues for baselined violations that represent real improvement opportunities.
This keeps the CI unblocked while avoiding untested architectural changes being bundled into a hotfix.
Remaining tasks
- Assess each of the 32 violations and decide: fix inline or baseline with rationale
- Update the phpstan baseline file
- Verify PHPStan CI passes on 9.1.x
- Open follow-up issues for any baselined violations that warrant separate tracking
- Link any follow-up issues to this issue
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
PHPStan CI now passes on 9.1.x after updating the phpstan baseline to account for new rules introduced by the phpstan-drupal package update. Violations safe to fix inline were corrected; remaining violations were baselined with documented rationale and tracked in follow-up issues.
Issue fork patternkit-3612106
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
yusuf_khan commentedi'm working on this
Comment #5
yusuf_khan commented@slucero I have applied the Proposed resolution and Fixed PHPStan failures caused by phpstan-drupal update .Please review the MR.
Comment #6
yusuf_khan commented@slucero Please advise on the failing php unit , i try to fix but its still failing
Comment #7
slucero@yusuf_khan, thank you for your work on this! The MR looks great so far. I've noted a few minor revisions to make throughout if you don't mind. For the PHPUnit failures, I believe that will be fixed by the suggestion changing the test's URL target.
I also created and linked the two follow-up issues for the items being baselined if you wouldn't mind including reference to those in the doc block for it:
Comment #9
slucero@yusuf_khan, since this was blocking CI on other open MRs I've opted to go ahead and implement the changes directly on top of the work you've already completed. Everything seems to be working now and I greatly appreciate your contribution! Thank you.
This has now been merged into 9.1.x for inclusion in the 9.1.3 release.
See #3542304: Patternkit 9.1.3 Release Plan.