Bug #19421 [Opn->Csd]: phpcs doesn't recognize ${x} as equivalent to $x

From: Date: Fri, 18 May 2012 06:51:50 +0000
Subject: Bug #19421 [Opn->Csd]: phpcs doesn't recognize ${x} as equivalent to $x
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-8670@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19421&edit=1 ID: 19421 Updated by: gsherwood@squiz.net Reported By: andy at petdance dot com Summary: phpcs doesn't recognize ${x} as equivalent to $x -Status: Open +Status: Closed Type: Bug Package: PHP_CodeSniffer Package Version: 1.3.3 PHP Version: 5.3.13 -Assigned To: +Assigned To: squiz Roadmap Versions: New Comment: -Status: Open +Status: Closed -Assigned To: +Assigned To: squiz Fixed in github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/c79233f37925872d1f1a9b08a 2cf091a72794d66 Previous Comments: ------------------------------------------------------------------------ [2012-05-16 16:44:39] petdance 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 -------------------------------------------------------------------------------- ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19421&edit=1

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