Replace static state on ServiceMap, ExtensionMap, and ConfigSchemaData
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- drupal, php
- Domain
- developer-experience, testing
Research direction
Read the implementations of ServiceMap, ExtensionMap, and ConfigSchemaData, then trace how DrupalAutoloader populates them from PHPStan's bootstrap and how the container creates their services. Explore how bootstrap data could reach container instances or be registered through a service factory; done means the maps hold instance state, bootstrap populates those instances, and tests can reset or isolate state without separate processes. The issue says this is design work intended for discussion before implementation.
Written by the indexing model from the issue text.
Description
ServiceMap, ExtensionMap, and ConfigSchemaData hold their data in static properties, populated once by DrupalAutoloader from PHPStan's bootstrap file. The container services are stateless shells over global state.
Consequences today:
- Tests are order-dependent. Any test that seeds one of these maps clobbers the bootstrap-populated state other test classes rely on, so
BootstrapResultCacheMetaExtensionTestruns every method in a separate process. - Nothing can hold two sites' data at once, and there is no way to reset between analyses inside one process.
Direction: make the maps instance state and have the autoloader populate the container's instances instead of static properties. The static properties exist because the bootstrap file runs before the container hands out instances, so the fix has to find a clean way for the bootstrap to reach the container's services or to register itself as a service factory.
This is a large refactor with no user-facing payoff on its own. Filed so the reason for the separate-process tests is recorded and so the design can be discussed before anyone starts.
Found during the 2026 legacy-code audit.
- Dominant language
- PHP
- Stars
- 208
- Forks
- 88
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 15
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mglaman/phpstan-drupal
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mglaman/phpstan-drupal#1078 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
mglaman/phpstan-drupal#1079 ·
Maintainers usually reply within 1 day
-
Report constraint plugins that break on Drupal 12 because they have no named-arguments constructorPossibly taken @goba claimed this 1 day ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
mglaman/phpstan-drupal#1075 ·
Maintainers usually reply within 1 day
-
Magic properties: original on entities, name on UserSession and password on User are not reported as deprecatedPossibly taken @goba claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
mglaman/phpstan-drupal#1074 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
mglaman/phpstan-drupal#1047 ·
Maintainers usually reply within 1 day
All issues in mglaman/phpstan-drupal
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-sitemap#125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nikic/PHP-Parser#1184 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
api-platform/core#8835 ·
Maintainers usually reply within 2 days
-
14.3.x
Difficulty 1/5 1-3 hours Newbie friendliness 82/100