Bug #19775 [Opn]: Problems Squiz.PHP.NonExecutableCode.Unreachable rule when unused {}

From: Date: Fri, 04 Jan 2013 21:21:29 +0000
Subject: Bug #19775 [Opn]: Problems Squiz.PHP.NonExecutableCode.Unreachable rule when unused {}
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9453@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19775&edit=1 ID: 19775 Updated by: contato@bernardosilva.com.br Reported By: diou at vetorial dot net Summary: Problems Squiz.PHP.NonExecutableCode.Unreachable rule when unused {} Status: Open Type: Bug Package: PHP_CodeSniffer Operating System: All Package Version: 1.4.3 PHP Version: 5.3.6 Roadmap Versions: New Comment: There is also no problems in else without {} <?php function teste($a){ if (empty($a)) echo '1'; else return 0; echo "oi"; } ?> Previous Comments: ------------------------------------------------------------------------ [2013-01-04 21:12:15] dioubernardo Description: ------------ The rule identifies problems below if no {}, I believe it is because you are inside switch. There's something in this latest version corrected about that, I had noticed that in the earlier version just had not reported. In the function "teste" is identified a problem in the first break, after putting in {} in if "teste2" the error is not identified. Test script: --------------- function teste($a, $b){ switch($a){ case 1: if (empty($b)) return 0; break; default: return 2; } return 1; } function teste2($a, $b){ switch($a){ case 1: if (empty($b)){ return 0; } break; default: return 2; } return 1; } ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19775&edit=1

« previous php.pear.bugs (#9453) next »