-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Description
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
<?php
/**
* @param array{key: array{inner: mixed}} $arr
*/
function arrayHint(array $arr): void
{
// this respects treatPhpDocTypesAsCertain: false
if (!array_key_exists('key', $arr)) {
throw new \Exception('no key "key" found.');
}
// this DOES NOT respect treatPhpDocTypesAsCertain: false
if (!array_key_exists('inner', $arr['key'])) {
throw new \Exception('need key.inner');
}
}https://phpstan.org/r/5d56ccbf-0ad7-4390-8077-c68d30a10af7
Expected output
nothing.
Reactions are currently unavailable