Skip to content

Improve laziness of container XML parsing#487

Draft
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
xificurk:lazy-dic
Draft

Improve laziness of container XML parsing#487
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
xificurk:lazy-dic

Conversation

@xificurk
Copy link
Copy Markdown
Contributor

@xificurk xificurk commented May 8, 2026

Parsing the XML into the DTOs is a costly operation on large Kernels. This PR defers the ServiceMap and ParameterMap initialization until the first use of their content.

Comment thread src/Symfony/ServiceMap.php Outdated
public function getService(string $id): ?ServiceDefinition;

public static function getServiceIdFromNode(Expr $node, Scope $scope): ?string;
public function getServiceIdFromNode(Expr $node, Scope $scope): ?string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a BC break, given the fact that the interface has @api. If someone implements the interface his code will break.

Same exist for ParameterMap ; so I'll need @ondrejmirtes review.

@ondrejmirtes
Copy link
Copy Markdown
Member

Yeah, removing the static keyword is a BC break. For 3.0 we could add @api-do-not-implement there (many PHPStan core interface already have it) and make the interface nicer. But I think this improvement could still be implemented without changing the interfaces?

@xificurk
Copy link
Copy Markdown
Contributor Author

xificurk commented May 9, 2026

@ondrejmirtes Yes, I'll rework this to maintain BC.

Removing the static would make sense for 3.0 - all the existing calls are on a dynamically resolved instance. No true static calls exist and given the implemented logic, they should not exist.

@xificurk xificurk marked this pull request as draft May 9, 2026 08:40
@staabm
Copy link
Copy Markdown
Contributor

staabm commented May 9, 2026

@xificurk please also provide a profiler screenshot / hyperfine perf numbers so we can see the impact of this PR

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants