Hard to understand XHTML validation errors

In the following, please use lowercase tags (uppercase used for clarity)

  • No DIV allowed in A
    do not write <A><DIV>Hello</DIV></A>
    write instead <A><SPAN>Hello</SPAN></A>
  • No INPUT allowed in FORM
    do not write <FORM><INPUT /></FORM>
    write instead <FORM><DIV><INPUT /></DIV></FORM>

Dealing with Zend Studio validations

I’ve been struggling quite a while this afternoon for making Zend Studio behave as expected, and I got it!

Zend Studio was marking many warnings in WSDL files that it wrongfully interpreted as HTML rather than XML.

I wanted to disable validation only for those files and couldn’t find out how. I had already excluded their parent folder from the Build Path, but it didn’t work for warnings of this kind.

Those files have a php extension, and HTML validation is twofold: one for HTML files and one for PHP files.

So I changed the settings for the line reading HTML Syntax Validator (for PHP Files) from

to

and after a clean build I got

Call to undefined function ‘output_cache_disable’

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.