Skip to content

Use container to resolve PHPStan built-in rules in tests#954

Merged
mglaman merged 2 commits intomainfrom
fix/use-container-for-impossible-check-type-rules
Mar 20, 2026
Merged

Use container to resolve PHPStan built-in rules in tests#954
mglaman merged 2 commits intomainfrom
fix/use-container-for-impossible-check-type-rules

Conversation

@mglaman
Copy link
Copy Markdown
Owner

@mglaman mglaman commented Mar 20, 2026

Summary

Replaces manual construction of PHPStan internal rules in three test files with self::getContainer()->getByType(...) lookups, following the pattern already established in Bug825Test.

  • AccessCheckImpossibleTypeCallRuleTest: ImpossibleCheckTypeMethodCallRule
  • ImpossibleCheckTypeStaticMethodCallRuleTest: ImpossibleCheckTypeStaticMethodCallRule
  • EntityParameterTypehintRuleTest: MissingFunctionParameterTypehintRule

This avoids arguments.count / argument.type PHPStan errors when PHPStan adds new required constructor parameters (as happened with PossiblyImpureTipHelper).

Test plan

  • php vendor/bin/phpunit --filter=AccessCheckImpossibleTypeCallRuleTest passes
  • php vendor/bin/phpunit --filter=ImpossibleCheckTypeStaticMethodCallRuleTest passes
  • php vendor/bin/phpunit --filter=EntityParameterTypehintRuleTest passes
  • php vendor/bin/phpstan analyze tests/src/Rules/AccessCheckImpossibleTypeCallRuleTest.php tests/src/Rules/ImpossibleCheckTypeStaticMethodCallRuleTest.php tests/src/Rules/EntityParameterTypehintRuleTest.php reports no errors

🤖 Generated with Claude Code

mglaman and others added 2 commits March 20, 2026 14:57
Replaces manual construction of ImpossibleCheckTypeMethodCallRule and
ImpossibleCheckTypeStaticMethodCallRule with container lookups, avoiding
breakage when PHPStan adds new required constructor parameters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Same pattern as the previous fixes: avoids breakage from PHPStan
constructor signature changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mglaman mglaman merged commit fdf91d3 into main Mar 20, 2026
14 of 15 checks passed
@mglaman mglaman deleted the fix/use-container-for-impossible-check-type-rules branch March 20, 2026 20:05
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.

1 participant