Skip to content

Conversation

schlndh
Copy link
Contributor

@schlndh schlndh commented Jan 21, 2024

This PR fixes a false positive encountered by #2885 . I simplified it to smaller example: https://phpstan.org/r/892eed14-49b8-4a98-b591-90cf5741a99e

This scenario only happens with bleeding edge enabled. Without it the constant union doesn't make it into getSpaceshipType due to

if (!BleedingEdgeToggle::isBleedingEdge() && $this->shouldGeneralizeInferredType()) {

As far as I can tell, the spaceship operator should always return -1, 0, or 1: https://3v4l.org/FVeq7

@ondrejmirtes ondrejmirtes merged commit b60d12c into phpstan:1.10.x Jan 21, 2024
@ondrejmirtes
Copy link
Member

Thank you!

@schlndh schlndh deleted the fix-spaceshipTypeForLargeConstantUnions branch January 21, 2024 20:40
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