Running CodeSniffer PHP style tests gave me the following error:
The use of function is_null() is forbidden
Squiz.PHP.ForbiddenFunctions.Found
Why would use of is_null() be forbidden?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
We implemented this rule in the Squiz standard for consistency.
Another part of the standard forbids implied expressions, for example
if ($var) {.... So you need to writeif ($var === TRUE) {....Due to this, a comparison of a NULL value would look like this:
Given the fact you already have to write the second half of the comparison, it is easier to just write:
The code is simpler this way, but also (and more importantly) more consistent with the way we do things.
That’s the only reason. We weren’t concerned about performance and didn’t have any issues with the
is_null()function itself. It works fine as far as I know.