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

Bug #18964 "$stackPtr must be of type T_VARIABLE" on heredocs and nowdocs
Submitted: 2011-11-07 02:06 UTC
From: bkendig Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.1)
PHP Version: 5.3.8 OS: Mac OS X 10.6.8
Roadmaps: (Not assigned)    
Subscription  


 [2011-11-07 02:06 UTC] bkendig (Brian Kendig)
Description: ------------ On several files in my project which contain heredocs or nowdocs, phpcs fails with this error: error - An error occurred during processing; checking has been aborted. The error message was: $stackPtr must be of type T_VARIABLE If I simply remove the heredoc/nowdoc from my file, phpcs passes it successfully. Test script: --------------- $x = <<<M foo M; Expected result: ---------------- Nothing Actual result: -------------- error - An error occurred during processing; checking has been aborted. The error message was: $stackPtr must be of type T_VARIABLE

Comments

 [2011-11-07 04:47 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Feedback
I'm not getting any errors with your test script. Maybe you need to include some code surrounding the heredoc to make the error occur. The error occurs when getting member properties, so you may need to include a whole class to get it working. I've tried with some sample code and still can't get it to fail, so it might be specific to your code structure. Can you please try putting some sample code into a test script and see if you can get PHPCS to fail when just checking that script.
 [2011-11-07 21:15 UTC] bkendig (Brian Kendig)
Here's a reproducible test case: $ cat foo.php <?php class foo { const bar = <<<BAZ qux BAZ; } $ phpcs foo.php FILE: /Users/brkendig/foo.php -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 1 | ERROR | An error occurred during processing; checking has been aborted. | | The error message was: $stackPtr must be of type T_VARIABLE -------------------------------------------------------------------------------- Time: 0 seconds, Memory: 3.00Mb
 [2011-11-07 21:28 UTC] bkendig (Brian Kendig)
And, if it helps: $ php -v PHP 5.3.8 (cli) (built: Oct 21 2011 10:14:14) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies $ pear list -a Installed packages, channel __uri: ================================== (no packages installed) Installed packages, channel components.ez.no: ============================================= Package Version State Base 1.8 stable ConsoleTools 1.6.1 stable Installed packages, channel doc.php.net: ======================================== (no packages installed) Installed packages, channel pear.pdepend.org: ============================================= Package Version State PHP_Depend 0.10.6 stable Installed packages, channel pear.php.net: ========================================= Package Version State Archive_Tar 1.3.8 stable Console_Getopt 1.3.1 stable PEAR 1.9.4 stable PHP_CodeSniffer 1.3.1 stable PhpDocumentor 1.4.3 stable Structures_Graph 1.0.4 stable XML_Beautifier 1.2.2 stable XML_Parser 1.3.4 stable XML_Util 1.2.1 stable Installed packages, channel pear.phpunit.de: ============================================ Package Version State DbUnit 1.0.3 stable File_Iterator 1.2.6 stable PHPUnit 3.5.15 stable PHPUnit_MockObject 1.0.9 stable PHPUnit_Selenium 1.0.3 stable PHP_CodeCoverage 1.0.5 stable PHP_Timer 1.0.2 stable PHP_TokenStream 1.0.1 stable Text_Template 1.1.1 beta Installed packages, channel pear.symfony-project.com: ===================================================== Package Version State YAML 1.0.6 stable Installed packages, channel pecl.php.net: ========================================= Package Version State xdebug 2.1.2 stable
 [2011-11-08 04:32 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Thanks a lot for getting back to me. Allowed me to track down the error and fix it. You can grab the latest code from: https://github.com/squizlabs/PHP_CodeSniffer
 [2011-11-09 00:13 UTC] bkendig (Brian Kendig)
Thank you for your prompt action! I got the latest code from github, and my first example is indeed working now, but it's still failing if I specify standard=Zend. $ cat foo.php <?php class foo { const bar = <<<BAZ qux BAZ; } or-brkendig-mb1:~ brkendig$ php PHP_CodeSniffer/scripts/phpcs -- foo.php FILE: /Users/brkendig/foo.php -------------------------------------------------------------------------------- FOUND 4 ERROR(S) AFFECTING 2 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 2 | ERROR | Missing class doc comment 2 | ERROR | Class name must begin with a capital letter 4 | ERROR | Class constants must be uppercase; expected BAR but found bar -------------------------------------------------------------------------------- or-brkendig-mb1:~ brkendig$ php PHP_CodeSniffer/scripts/phpcs -- foo.php --standard=Zend FILE: /Users/brkendig/foo.php -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 1 | ERROR | An error occurred during processing; checking has been aborted. | | The error message was: $stackPtr must be of type T_VARIABLE --------------------------------------------------------------------------------
 [2011-11-09 23:29 UTC] bkendig (Brian Kendig)
-Status: Closed +Status: Open
 [2011-11-11 04:11 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Thanks. I forgot the Zend one. Committed now.
 [2011-11-15 23:02 UTC] bkendig (Brian Kendig)
I have another example of the error; it still happens in the version in git today. If you set a class property to a heredoc which is not empty, phpcs aborts with an error. $ cat ~/main/foo.php <?php class Foo { public function one() { // this is fine $a = <<<A aaa A; } // this is fine $b = <<<B B; // this causes an error $c = <<<C ccc C; } $ php scripts/phpcs ~/main/foo.php FILE: /p4-wdpro/Projects/NGE/Sites/pep/main/foo.php -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 1 | ERROR | An error occurred during processing; checking has been aborted. | | The error message was: $stackPtr must be of type T_VARIABLE -------------------------------------------------------------------------------- Remove 'ccc' and it will no longer abort.
 [2011-11-15 23:02 UTC] bkendig (Brian Kendig)
-Status: Closed +Status: Open
 [2011-11-21 10:56 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Feedback
I've redone the fix and put it somewhere else as I found there was something wrong with an abstract class. Try the latest code again please and let me know if it is working for you.
 [2011-11-23 02:11 UTC] bkendig (Brian Kendig)
Yes, this test case works for me now. Thanks!
 [2011-11-23 03:07 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Good news. Thanks a lot for getting back to me.