Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Oct 27, 2025

shuffling the initial if-checks so the cheapest ones get called first.

AssertRuleHelper::isMethodOrStaticCallOnAssert internally uses new ObjectType('PHPUnit\Framework\Assert') which triggers reflection logic and file parsing

see

grafik

refs phpstan/build-infection#16

@staabm staabm marked this pull request as ready for review October 27, 2025 17:54

public function processNode(Node $node, Scope $scope): array
{
if (!AssertRuleHelper::isMethodOrStaticCallOnAssert($node, $scope)) {
Copy link
Contributor Author

@staabm staabm Oct 27, 2025

Choose a reason for hiding this comment

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

before this PR, any CallLike triggered autoloading of the PHPUnit classes via reflection (no matter whether it actually contained the assert prefix in the method name or no matter whether the CallLike was related to PHPUnit at all)

@ondrejmirtes ondrejmirtes merged commit dd87f2e into phpstan:2.0.x Oct 28, 2025
70 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the re-order branch October 28, 2025 06:33
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.

2 participants