Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.4.2

Bug #19421 phpcs doesn't recognize ${x} as equivalent to $x
Submitted: 2012-05-16 20:44 UTC
From: petdance Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.3)
PHP Version: 5.3.13 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2012-05-16 20:44 UTC] petdance (Andy Lester)
Description: ------------ ${x} is valid as an expression of $x. It's often used in interpolation, but is valid outside of strings as well. Test script: --------------- <?php // Variable $x can be expressed as ${x} but phpcs doesn't detect that. function foo( $bar ) { print "${bar} things\n"; } function bar( $x ) { return 2 * ${x}; } print 'Should say "14 things"' . "\n"; $fourteen = bar( 7 ); foo( $fourteen ); ?> Expected result: ---------------- When I run phpcs against that, there should be no errors. Actual result: -------------- FILE: /home/alester/scraps/sniffbugs.php -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AND 2 WARNING(S) AFFECTING 3 LINE(S) -------------------------------------------------------------------------------- 5 | WARNING | The method parameter $bar is never used 9 | WARNING | The method parameter $x is never used 10 | ERROR | Constants must be uppercase; expected X but found x --------------------------------------------------------------------------------

Comments

 [2012-05-18 11:51 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fixed in github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/c79233f37925872d1f1a9b08a 2cf091a72794d66