-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More precise implode() return type #3774
base: 1.12.x
Are you sure you want to change the base?
Conversation
//cc @VincentLanglet since its string accessory business :) |
@@ -80,22 +80,23 @@ private function implode(Type $arrayType, Type $separatorType): Type | |||
} | |||
|
|||
$accessoryTypes = []; | |||
$valueTypeAsString = $arrayType->getIterableValueType()->toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the actual change is here: we use toString
as the implode
function internally casts everything.
that way the string types detection also works for unions of strings and non-strings (e.g. 2|'a'
) and so we get more precise results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome
b1fb846
to
fe52c9e
Compare
@@ -212,7 +212,7 @@ public function sayHello(int $i): void | |||
// coming from issue #5291 | |||
$s = array(1, $i); | |||
|
|||
assertType('non-falsy-string', implode("a", $s)); | |||
assertType('lowercase-string&non-falsy-string', implode("a", $s)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertType('lowercase-string&non-falsy-string', implode("a", $s)); | |
assertType('lowercase-string&non-falsy-string', implode("a", $s)); | |
assertType('uppercase-string&non-falsy-string', implode("A", $s)); |
No description provided.