@@ -42,10 +42,7 @@ public function getPrintfPlaceholderAcceptingTypes(string $format): array
4242 {
4343 $ placeholders = $ this ->parsePlaceholders (self ::PRINTF_SPECIFIER_PATTERN , $ format );
4444 $ result = [];
45- // int can go into float, string and mixed as well.
46- // float can't go into int, but it can go to string/mixed.
47- // string can go into mixed, but not into int/float.
48- // mixed can only go into mixed.
45+ // Type on the left can go to the type on the right, but not vice versa.
4946 $ typeSequenceMap = array_flip (['int ' , 'float ' , 'string ' , 'mixed ' ]);
5047
5148 foreach ($ placeholders as $ position => $ types ) {
@@ -69,11 +66,10 @@ static function (Type $t) use ($types): bool {
6966 foreach ($ types as $ acceptingType ) {
7067 $ subresult = match ($ acceptingType ) {
7168 'strict-int ' => (new IntegerType ())->accepts ($ t , true )->yes (),
72- // This allows float, constant non-numeric string, ...
7369 'int ' => ! $ t ->toInteger () instanceof ErrorType,
7470 'float ' => ! $ t ->toFloat () instanceof ErrorType,
7571 // The function signature already limits the parameters to stringable types, so there's
76- // no point in checking it again here.
72+ // no point in checking string again here.
7773 'string ' , 'mixed ' => true ,
7874 };
7975
0 commit comments