Skip to content

Conversation

@herndlm
Copy link
Contributor

@herndlm herndlm commented Mar 21, 2022

Closes phpstan/phpstan#6872

The problem is

  1. It all starts with a UnionType::accepts with a CompoundType like e.g. TemplateObjectWithoutClassType
  2. UnionType::accepts calls accepts on all inner types via https://github.com/phpstan/phpstan-src/blob/1.4.7/src/Type/UnionType.php#L104
  3. If there is a FloatType in the union, then it would call CompoundType::isAcceptedBy with a newly created float|int union
  4. the changes introduced in 35606f9 would call UnionType::accepts (the new float|int one) via 35606f9#diff-9085cfd032ca2e4178b6ba4ba9815c7bfffba6f2d5c0cfd06e29d3cb75fa0ecfR123
  5. it starts from 1. again

I digged some more, apparently this was introduced in adb4fdd together with tests. And those tests are still there and green, see https://github.com/phpstan/phpstan-src/blob/1.4.x/tests/PHPStan/Type/FloatTypeTest.php. So the FloatType still accepts int and float and int|float. I think this should be fine then.

@herndlm herndlm marked this pull request as ready for review March 21, 2022 21:30
@herndlm
Copy link
Contributor Author

herndlm commented Mar 22, 2022

Should this target 1.5.x instead Ondrej? Sorry, I was not entirely sure if 1.4 releases are still a thing or how long that branch lives.

@ondrejmirtes
Copy link
Member

Thank you, perfect. I rebased it on 1.5.x myself: c564943

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