Replace static state on ServiceMap, ExtensionMap, and ConfigSchemaData

Open
#1,051 0 comments 0 reactions 0 assignees View on GitHub

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

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

enhancement

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 BootstrapResultCacheMetaExtensionTest runs 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mglaman/phpstan-drupal

All issues in mglaman/phpstan-drupal

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.