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

Bug #20043 Mis-interpretation of Foo::class
Submitted: 2013-08-19 14:38 UTC
From: pschultz Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.0RC3)
PHP Version: 5.5.1 OS: Linux
Roadmaps: (Not assigned)    

 [2013-08-19 14:38 UTC] pschultz (Peter Schultz)
Description: ------------ phpcs seems to mis-interpret the new static `::class` constant (new in PHP 5.5 [1]). In my case this manifests as several "Undefined index" notices when running phpcs on code like class Foo { public function bar() { return Bar::class; } } We are using the PSR2 standard but I suppose that applies to others as well. Test script: --------------- class Foo { public function bar() { return Bar::class; } } Expected result: ---------------- No notices being reported. Actual result: -------------- Several notices like this (paths shortened to the relevant part) PHP Notice: Undefined index: scope_opener in [...]/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards /PSR2/Sniffs/Classes/ClassDeclarationSniff.php on line 108 PHP Stack trace: PHP 1. {main}() [...]/vendor/squizlabs/php_codesniffer/scripts/phpcs:0 PHP 2. PHP_CodeSniffer_CLI->process() [...]/vendor/squizlabs/php_codesniffer/scripts/phpcs:37 PHP 3. PHP_CodeSniffer->process() [...]/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php:6 15 PHP 4. PHP_CodeSniffer->processFile() [...]/vendor/squizlabs/php_codesniffer/CodeSniffer.php:467 PHP 5. PHP_CodeSniffer->_processFile() [...]/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1285 PHP 6. PHP_CodeSniffer_File->start() [...]/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1401 PHP 7. PSR2_Sniffs_Classes_ClassDeclarationSniff- >process() [...]/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php:4 92 PHP 8. PSR2_Sniffs_Classes_ClassDeclarationSniff- >processOpen() [...]/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards /PSR2/Sniffs/Classes/ClassDeclarationSniff.php:50 More examples attached


 [2013-08-19 14:42 UTC] pschultz (Peter Schultz)
I don't want to disguise the promised attached notices as a patch, so I pasted them here:
 [2013-09-05 07:00 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: 5938869263c9a9