Repository navigation
Know that numeric-string and decimal-int-string are non-empty-string - #6959
Merged
Merged
Conversation
AccessoryNumericStringType::isSubTypeOf() and AccessoryDecimalIntegerStringType::isSubTypeOf() answered Maybe for AccessoryNonEmptyStringType, although '' is neither numeric nor a decimal integer. So non-empty-string|numeric-string stayed a union, and non-empty-string&numeric-string kept the redundant non-empty-string. Loose comparison narrowing now produces such unions, e.g. $string == $nonEmptyString gave non-empty-string|numeric-string. This mirrors AccessoryNonFalsyStringType, which already answers Yes for AccessoryNonEmptyStringType. Amp-Thread-ID: https://ampcode.com/threads/T-01a1ad71-9d5a-7120-9844-bfb0954d122f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
AccessoryNumericStringType::isSubTypeOf()andAccessoryDecimalIntegerStringType::isSubTypeOf()answered Maybe forAccessoryNonEmptyStringType, although''is neither numeric nor a decimal integer. So:non-empty-string|numeric-stringstayed a union instead ofnon-empty-string,non-empty-string&numeric-stringkept the redundantnon-empty-string,decimal-int-string|(non-empty-string&uppercase-string)((string) int|float) stayed a union.The loose comparison narrowing from #6938 now produces such unions:
$string == $nonEmptyStringnarrows$stringtonon-empty-string|numeric-string, which fails phpstan/phpstan-webmozart-assert'sAssert::eq()test.This mirrors
AccessoryNonFalsyStringType, which already answers Yes forAccessoryNonEmptyStringType. The C++ mirrors inturbo-extget the same change.Updated expectations are the same sets, written without the redundant parts.
mixed~non-empty-stringis now not a numeric string (only''and non-strings are left).Found while probing, not fixed here
non-empty-string&non-decimal-int-stringis a subtype ofnon-falsy-string('0'is the only non-empty falsy string, and it is a decimal-int string), butisSuperTypeOf()answers Maybe because neither accessory alone implies non-falsy. The same goes fornumeric-string&non-decimal-int-string. Fixing it needsIntersectionTypeto reason over its members together.The new float range types came out clean: no subset or membership gaps across
float,float<min, max>,finite-float, the signed float types, bounded ranges and theINF/-INF/NAN/zero constants.