Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix generic-object false positive#73

Merged
TomasVotruba merged 1 commit into
rectorphp:mainfrom
staabm:same-generic
Apr 17, 2026
Merged

Fix generic-object false positive#73
TomasVotruba merged 1 commit into
rectorphp:mainfrom
staabm:same-generic

Conversation

@staabm

@staabm staabm commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

prevent false-positives like

grafik

@samsonasik samsonasik requested a review from TomasVotruba April 17, 2026 09:02
}

if ($argType instanceof IntersectionType) {
if ($argType instanceof IntersectionType || $argType instanceof GenericObjectType) {

@staabm staabm Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this false positives occur, because of the recent changes in ObjectType->equals() in PHPStan and the non-public-api compilant use of the PHPStan Type system ins this package (using instanceof on Type objects).

I don't think its worth our time to make this rule print meaningful results for generic objects. it would involve a very different approach to what this rule is doing today.

therefore I think just skipping generics is the way to go

@TomasVotruba

Copy link
Copy Markdown
Member

Let's ship it, thank you 👍

@TomasVotruba TomasVotruba merged commit 620a995 into rectorphp:main Apr 17, 2026
6 checks passed
@staabm staabm deleted the same-generic branch April 17, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants