-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Labels
Description
Consider the following code to be part of some template, where variable $block
originates from somewhere else. Its defined somewhere else, before include
was called so it indeed is available in the template:
<?php
$block->doSomething();
if (3 < 5) {
$block->doThis();
} else {
$block-doThat();
}
If you format ruelset to look like following:
<rule ref="VariableAnalysis">
<properties>
<property name="validUndefinedVariableNames" value="block"/>
</properties>
</rule>
the output would be:
php,phtml test.phtml
FILE: /project/test.phtml
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
8 | WARNING | Variable $block is undefined.
----------------------------------------------------------------------
Time: 85ms; Memory: 8MB
Which is not the desired behavior.
Else statement requires special attention, but current implementation leads to false positives.