Skip to content

Add regression test for #12882 - #6748

Merged
staabm merged 1 commit into
phpstan:2.3.xfrom
HawkForge:test/bug-12882
Oct 15, 2026
Merged

staabm merged 1 commit into
phpstan:2.3.xfrom
HawkForge:test/bug-12882

Conversation

@HawkForge

@HawkForge HawkForge commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Adds the match (get_class($foo)) case from #12882 to the existing bug-12241.php test. The $foo::class case there already covers the other form. With the sealed handling in GenericClassStringType::tryRemove() disabled, the new block fails with Match expression does not handle remaining value: class-string<Bug12241\Foo> (line 23).

Closes phpstan/phpstan#12882

@staabm

staabm commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

how is your newly added test different from the one which was committed with the fix in 4cbde15...e38383a ?

@HawkForge

Copy link
Copy Markdown
Contributor Author

The $object::class match is the same case bug-12241.php already covers. The new part is the match (get_class($object)) form from #12882, which no existing test covers. With the sealed handling in GenericClassStringType::tryRemove() reverted, it fails with Match expression does not handle remaining value: class-string<Bug12882\BaseClass>.

I can trim the data file down to the get_class() case, or close this if you'd rather not have it.

@staabm

staabm commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

please append your case in tests/PHPStan/Rules/Comparison/data/bug-12241.php adopted to the pre-existing code in it

@HawkForge

Copy link
Copy Markdown
Contributor Author

Done. The get_class() case is now appended to bug-12241.php, and the separate file and test method are gone.

@staabm

staabm commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

thank you

@staabm
staabm merged commit c9e29a4 into phpstan:2.3.x Oct 15, 2026
521 of 576 checks passed
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.

PHPStan incorrectly reports unhandled match cases when using ::class or get_class on a polymorphic variable

2 participants