Why mysqli functions are indicated as errors/warnings?
Hello,
I have a few mysqli function calls in my code, such as:
mysqli_connect()
mysqli_query()
mysqli_fetch_array()
PhpStorm underlines mysqli_fetch_array as error, the rest as warnings. When I disable all inspections in the settings, then obviously I don't get any errors/warnings. But I don't understand why am I getting these? These functions are not only valid but they execute just fine. I just would like to know why PS considers these errors/warnings when the inspections are enabled?
Thanks!
PS 5.0.4
W7 x64
Please sign in to leave a comment.
Please provide some code exampe to reproduce (and screenshot with error message)
Here's a screenshot of the indicated warnings and errors.

For 'mysqli_query' I get: 'void' function 'mysqli_query' result used. According to the docs, mysqli_query is not a void function.
For 'mysqli_fetch_array' I get: Required parameter $result_type missing. According to the docs, $result_type is optional parameter.
The stubs are incorrect:
/**
* @param mysqli $link Procedural style only: A link identifier returned by mysqli_connect() or mysqli_init()
* @param $query
*/
function mysqli_query ($link, $query) {}
It's missing the return type.
/**
* @param mysqli_result $result Procedural style only: A result set identifier returned by mysqli_query(),
* mysqli_store_result() or mysqli_use_result().
* @param mysqli_result $result Procedural style only: A result set identifier returned by mysqli_query(),
* mysqli_store_result() or mysqli_use_result(). _type [optional]
*/
function mysqli_fetch_array ($result, $result_type) {}
Even shows a warning in the stub document (it's just plain wrong.)
Stubs are wrong -- those are not the only functions that have them wrong.
http://youtrack.jetbrains.com/issues/WI?q=mysqli+%23{PHP+lib+stubs}
Some tickets are already fixed (v6 EAP), some are not yet.
Good to know, thanks!