Simplify FloatType::accepts handling of CompoundTypes #1097
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes phpstan/phpstan#6872
The problem is
UnionType::acceptswith aCompoundTypelike e.g.TemplateObjectWithoutClassTypeUnionType::acceptscallsacceptson all inner types via https://github.com/phpstan/phpstan-src/blob/1.4.7/src/Type/UnionType.php#L104FloatTypein the union, then it would callCompoundType::isAcceptedBywith a newly createdfloat|intunionUnionType::accepts(the new float|int one) via 35606f9#diff-9085cfd032ca2e4178b6ba4ba9815c7bfffba6f2d5c0cfd06e29d3cb75fa0ecfR123I 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
FloatTypestill acceptsintandfloatandint|float. I think this should be fine then.