Originally created by: Daniel...@gmail.com
Test code:
<?php
function unusedCodeProblem1() {
echo "1";
return;
echo "2";
}
function unusedCodeProblem2($a) {
if ($a) return;
echo "3";
echo "4";
}
?>
Actual output (I removed docBlocks warnings from the output):
$ php run.php --src test.php --format console
test.php WARNING Line:8 - The statement 'if' must contain its code within a {} block.
test.php WARNING Line:8 - function '%s' has unused code after the return.
Expected output 1:
There should be a warning "WARNING Line:4 ... unused code after return". (echo "2" is unused.)
Expected output 2:
There should NOT be a warning "WARNING Line:8 ... unused code after return". (echo "3" is used.)
SVN [r96]
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: tch...@hotmail.com
(No comment was entered for this change.)
Status: Accepted
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: tch...@hotmail.com
Correction committed on SVN, can you test with the version from the trunk ?
Thanks a lot.
Status: Fixed
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: Daniel...@gmail.com
[r101]
current output is:
$ php run.php --src test.php --format console
test.php WARNING Line:4 - function 'unusedCodeProblem1' has unused code after RETURN.
test.php WARNING Line:8 - The statement 'if' must contain its code within a {} block.
test.php WARNING Line:8 - function 'unusedCodeProblem2' has unused code after RETURN.
The first part is OK, line 4 is unused.
But is still says "Line:8 ... unnused code...", but it is not true.
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: tch...@hotmail.com
(No comment was entered for this change.)
Status: Accepted
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: tch...@hotmail.com
OK, this is more complicated than I tought. The problem is I don't dectect correctly the statement after IF because there is no curly opening.
I should improve the detection of the statement for all control statements. The line between the control statement and the next ";" should be considered as the statement.
But the conditional part should be ignored which is difficult. I think I need to count the parenthesis openings and closing.
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: tch...@hotmail.com
OK, new try.
Returns and Throws are taking into account only when they are at level 0 of a function. When they are in a statement they are ignored.
Can you retry ?
Thanks,
Status: Fixed
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: Daniel...@gmail.com
Yes it works, thank you.