This is a Zend Studio warning that has been bugging me lately.
The culprit is the file dummy.php, distributed with Zend Debugger. As per the installation instructions provided by the README file, one should “4. Copy the dummy.php file to your document root directory.” but the project I’m currently reviewing (FengOffice 1.7.3.1) has three copies of that file in three different folders. So a build in Zend Studio always gives that warning three times.
I know that in this particular case, I could simply erase all the dummy.php copies in the project, and forget the issue. And that’s exactly what I’m going to do.
But the issue is caused by a common programming idiom in PHP.
{[ .dummy | 1.hilite(=php,ln-1=) ]}
The code calls a contextual function only if it exists (@3-5). This is certainly correct, but fools up the simple Zend Studio validator.
It would be better if the code defined the expected contextual function if it didn’t exist, and called the function in any case (@3-6).
{[ .smarter_dummy | 1.hilite(=php,ln-1=) ]}
This makes Zend Studio give no more warnings.
Anyway, all in all, I think that Zend Studio could be a little smarter and don’t give warnings for function calls inside function_exists blocks.
I know that this could be quite difficult to implement, so an alternative workaround could be an option for telling Zend Studio not to show a specific warning, specific up to the file and line, i.e. up to a single issue in the problems panel.
This seems to no longer work in Zend Studio 9… I’m in a very similar situation and it’s bugging the crap out of me that I have this one single warning in my whole project which is perfectly good and valid code, but Zend Studio keeps barking at me about it. Declaring the function if function_exists fails doesn’t suppress the warning in ZS 9.0.3