Wondering if this is a bug, or if parameter type checking is not working as expectedin PhpStorm
I thought this worked in the past but now I'm not sure. I have the PHP->Type Compatibility->Parameter type inspection turned on at the error level. PhpStorm does not seem to take my PHPDoc @param annotations into consideration when doing parameter type checking. I can do this and it doesn't complain, but I expected it would underline the 45 and say it should be an array, not an integer:
------------------------------------------------
/**
* @param array $bar
* @return string
*/
function foo($bar) {
return $bar[0];
}
foo(45);
------------------------------------------------
It doesn't seem to be looking at the @param types at all. Only if I use a PHP array hint does it begin to complain in the scenario above. Another thing I notice is that when I hold the mouse over the call to foo and hold control, it pops up the function signature for foo. But it doesn't show the param type of $bar. It only only shows the string return type, but doesn't mention that @bar is supposed to be an array.
Am I expecting more than I should, or is it possible something is broken? I tried both 5.0.1 and 5.0.2 and get the same behavior in both.
Please sign in to leave a comment.
Another example that doesn't raise any errors:
/**
* @param int $bar
*/
function foo($bar = 3) {
}
foo('abc');
This is a bug in phpStorm. Please vote for it so it will be resolved quickly http://youtrack.jetbrains.com/issue/WI-10904