Skip to content

Fix ObjectType::equals#5399

Merged
VincentLanglet merged 6 commits intophpstan:2.1.xfrom
VincentLanglet:fix14429
Apr 5, 2026
Merged

Fix ObjectType::equals#5399
VincentLanglet merged 6 commits intophpstan:2.1.xfrom
VincentLanglet:fix14429

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

@VincentLanglet VincentLanglet commented Apr 4, 2026

#5398 shows the behavior before

Closes phpstan/phpstan#3028
Closes phpstan/phpstan#14429
Closes phpstan/phpstan#5298

Failures:

I reported the issue on rector side rectorphp/rector#9729

@VincentLanglet VincentLanglet force-pushed the fix14429 branch 2 times, most recently from b99915e to 820fe14 Compare April 4, 2026 12:49
@VincentLanglet
Copy link
Copy Markdown
Contributor Author

I'm breaking rector because they have multiple class extending the ObjectType like https://github.com/rectorphp/rector/blob/8e733dbcc4fe72493e533d354e195d77c7baee07/src/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php#L15

Which rely on the ObjectType::equals method.

And some rules from rector are relying on the fact that ObjectType::equals(FullyQualifiedObjectType) is true for instance.

@ondrejmirtes
Copy link
Copy Markdown
Member

Yes, don't worry about it

This reverts commit aa95f94.
@VincentLanglet
Copy link
Copy Markdown
Contributor Author

Yes, don't worry about it

@ondrejmirtes Does it means we prefer the "right" fix get_class($type) !== static::class, and we'll ask rector to update their implementation
Or should we choose the instanceof checks (aa95f94) to imply as few change as possible in rector codebase.

I do understand you prefer the get_class($type) !== static::class ?

@VincentLanglet
Copy link
Copy Markdown
Contributor Author

VincentLanglet commented Apr 4, 2026

TODO:

@ondrejmirtes
Copy link
Copy Markdown
Member

Yes, I prefer get_class($type) !== static::class. Rector's code is just wrong.

@VincentLanglet VincentLanglet marked this pull request as ready for review April 4, 2026 21:05
@VincentLanglet VincentLanglet requested a review from staabm April 4, 2026 21:05
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

Copy link
Copy Markdown
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

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

I think we did a similar fix in MixedType/ErrorType in the past.

ed7eb47

@VincentLanglet VincentLanglet merged commit 19baaf4 into phpstan:2.1.x Apr 5, 2026
651 of 656 checks passed
phpstan-bot pushed a commit to phpstan-bot/phpstan-src that referenced this pull request Apr 7, 2026
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.

4 participants