I believe a false positive is being matched in tpl.php template files due to the use of alternate code structures, for example:
<?php if (mystatement() == TRUE): ?>
This produces the following warning: "phpcs: There must be a single space before an operator statement."
Is it possible to detect these control structures an not error on these?

Comments

das-peter’s picture

Status: Active » Postponed (maintainer needs more info)

Hmm, I can't reproduce the issue with the latest dev.
A construct like the following passes without any notices / errors:

<?php if (mystatement() == TRUE): ?>
<?php endif; ?>

Could you provide the exact code that produces the error for you?

tanc’s picture

Thanks for your quick reply!

A sample of offending code would be:

<?php if (business_section_has_blog()): ?>
<li><a href="#blog">Blog</a></li>
<?php endif; ?>

I'm using this phpcs definition with PHPStorm. I wonder if that is a factor? I'm using the 7.x-1.x branch from git.

tanc’s picture

Confirmed that running drush drupalcs on the tpl file didn't trigger those warnings. So its something in the way PHPStorm is using the files. Any ideas?

das-peter’s picture

I use it with phpStorm, but not the built in inspection. In the versions I've tested this was a horrible performance slowdown.
So I configured dupalcs as an External Tool - not as convenient as the built-in inspection but still better than nothing.
However, I've no clue why the inspection does something extra :|

Btw. thanks for remembering of the performance problem - I finally created an issue in the phpStorm Issue queue: http://youtrack.jetbrains.com/issue/WI-12097

tanc’s picture

Hmm... Thats weird as I don't notice the performance issue, there is a little slow down as the file is again scanned and the warnings added but it hasn't been too slow for me. I am running some serious hardware (latest MBP) including an SSD though.

As for this issue, I'll try digging a little more and report back if I find anything.

klausi’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Reopen if this is still an issue.