You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
treatPhpDocTypesAsCertain: false apparently only works for the first level of param type hints,
the following code-snippet produces an error message for the second if clause, since it is assumed to be always false (i.e. array_key_exists is always true). for libraries that's not true.
Code snippet that reproduces the problem
<?php/** * @param array{key: array{inner: mixed}} $arr */functionarrayHint(array$arr): void
{
// this respects treatPhpDocTypesAsCertain: falseif (!array_key_exists('key', $arr)) {
thrownew \Exception('no key "key" found.');
}
// this DOES NOT respect treatPhpDocTypesAsCertain: falseif (!array_key_exists('inner', $arr['key'])) {
thrownew \Exception('need key.inner');
}
}
Bug report
treatPhpDocTypesAsCertain: false apparently only works for the first level of param type hints,
the following code-snippet produces an error message for the second if clause, since it is assumed to be always false (i.e.
array_key_exists
is always true). for libraries that's not true.Code snippet that reproduces the problem
https://phpstan.org/r/5d56ccbf-0ad7-4390-8077-c68d30a10af7
Expected output
nothing.
The text was updated successfully, but these errors were encountered: