Skip to content

Test generated subclass scopes in closure-this extensions - #6884

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
MrPunyapal:tests/generated-closure-subclass-scope
Oct 30, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
MrPunyapal:tests/generated-closure-subclass-scope

Conversation

@MrPunyapal

Copy link
Copy Markdown
Contributor

Add a CallMethodsRule test with a custom closure-this extension that registers an anonymous subclass through ReflectionProvider.

The test covers private base methods being rejected and protected/public methods remaining accessible in closures and arrow functions. It also checks direct base-class binding and ordinary calls outside a closure.

Requested in phpstan/phpstan#15598 (comment). Related to phpstan/phpstan#15361.

Validation:

  • 250 tests across the new test, CallMethodsRuleTest and ParameterClosureThisExtensionTest: 247 assertions, 3 skips.
  • PHPStan analysis and coding standards pass for the new test and extension.
  • Returning only ObjectType(BaseTestCase::class) makes the regression test fail because the private calls go unreported.

@ondrejmirtes
ondrejmirtes merged commit 6ebd2d7 into phpstan:2.3.x Oct 30, 2026
722 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Perfect, thank you.

@MrPunyapal

MrPunyapal commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

LG!

@MrPunyapal
MrPunyapal deleted the tests/generated-closure-subclass-scope branch October 30, 2026 09:55
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