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
Type lost on str_starts_with() invoke #9593
Comments
I found these snippets: https://psalm.dev/r/b5e0e01fa3<?php
/**
* @return string|null
*/
function getStr() {
return rand() > 5 ? '' : null;
}
$b = getStr();
$c = getStr();
if (!is_string($b) || !str_starts_with($b, 'prefix') || strlen($b) > 4) {
throw new \Exception('Assert');
}
/** @psalm-trace $b */;
if (!is_string($c) || strlen($c) > 4) {
throw new \Exception('Assert');
}
|
@fluffycondor , could you please step in, if possible? |
Looks like #9575 causes it :( |
I found these snippets: https://psalm.dev/r/8745d43ac6<?php
/**
* @return string|null
*/
function getStr() {
return rand() > 5 ? '' : null;
}
$b = getStr();
if (is_string($b) && str_starts_with($b, 'prefix') && strlen($b) > 4) {
/** @psalm-trace $b */;
} else {
throw new \Exception('Assert');
}
https://psalm.dev/r/f8959696d0<?php
/**
* @return string|null
*/
function getStr() {
return rand() > 5 ? '' : null;
}
$b = getStr();
if (!is_string($b)) {
throw new \Exception('Assert');
}
if (!str_starts_with($b, 'prefix') || strlen($b) > 4) {
throw new \Exception('Assert');
}
/** @psalm-trace $b */;
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/b5e0e01fa3
Probably introduced some side-effect in #9534 but not sure tbh. I checked PR's content and it does look correct to me, so don't have idea how to fix that.
The text was updated successfully, but these errors were encountered: