FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18190&edit=1

ID: 18190
Updated by: gsherwood@squiz.net
Reported By: ty_c at cybozu dot co dot jp
Summary: Analysis crashes on switch containing long sequence
of empty cases
-Status: Open
+Status: Feedback
Type: Bug
Package: PHP_CodeSniffer
Operating System: CentOS 5.5 x86_64
Package Version: 1.3.0RC1
PHP Version: 5.3.5
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
Any chance you can provide sample code because I cannot replicate this.
It's quite possible that your write case statements differently to me.


Previous Comments:
------------------------------------------------------------------------

[2011-01-13 08:50:02] ty_cybozu

Description:
------------
While analyzing production source code in conjunction with
Sonar, a PHP fatal error occurs reporting
that the maximum function nesting level of '100' has been
reached.

Running phpcs -vv on the offending source file revealed that
phpcs was barfing on a switch statement
containing several hundred empty case clauses in sequence.

Test script:
---------------
(attached)

Expected result:
----------------
I expect PHP_CodeSniffer will process such code segments
without trouble.

Actual result:
--------------
Registering sniffs in PEAR standard... DONE (26 sniffs
registered)
Processing system.php PHP Fatal error: Maximum function
nesting level of '100' reached, aborting! in
/usr/share/pear/PHP/CodeSniffer/File.php on line 1306
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpcs:0
PHP 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:38
PHP 3. PHP_CodeSniffer->process()
/usr/share/pear/PHP/CodeSniffer/CLI.php:494
PHP 4. PHP_CodeSniffer->processFile()
/usr/share/pear/PHP/CodeSniffer.php:437
PHP 5. PHP_CodeSniffer->_processFile()
/usr/share/pear/PHP/CodeSniffer.php:1001
PHP 6. PHP_CodeSniffer_File->start()
/usr/share/pear/PHP/CodeSniffer.php:1087
PHP 7. PHP_CodeSniffer_File->_parse()
/usr/share/pear/PHP/CodeSniffer/File.php:376
PHP 8. PHP_CodeSniffer_File::tokenizeString()
/usr/share/pear/PHP/CodeSniffer/File.php:536
PHP 9. PHP_CodeSniffer_File::_createScopeMap()
/usr/share/pear/PHP/CodeSniffer/File.php:873
PHP 10. PHP_CodeSniffer_File::_recurseScopeMap()
/usr/share/pear/PHP/CodeSniffer/File.php:1261
PHP 11. PHP_CodeSniffer_File::_recurseScopeMap()
/usr/share/pear/PHP/CodeSniffer/File.php:1397
PHP 12. PHP_CodeSniffer_File::_recurseScopeMap()
/usr/share/pear/PHP/CodeSniffer/File.php:1397
PHP 13. PHP_CodeSniffer_File::_recurseScopeMap()
/usr/share/pear/PHP/CodeSniffer/File.php:1397

(... excerpted ...)

PHP 99. PHP_CodeSniffer_File::_recurseScopeMap()
/usr/share/pear/PHP/CodeSniffer/File.php:1397

------------------------------------------------------------------------

Search Discussions

  • Daniels at Jan 17, 2011 at 11:39 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18190&edit=1

    ID: 18190
    Comment by: daniels
    Reported By: ds at netcar24 dot com
    Summary: Analysis crashes on switch containing long sequence of
    empty cases
    Status: Feedback
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: CentOS 5.5 x86_64
    Package Version: 1.3.0RC1
    PHP Version: 5.3.5
    Assigned To: squiz
    New Comment:

    I do have the same problem, I can reproduce it with the following
    statement:

    switch ($a) {
    case '1':
    case '2':
    case '3':
    ...
    case '99':
    case '100':
    case '101':
    case '102':
    break;
    }

    (just paste the snippet into a file an add the missing 'case'
    instructions)


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-01-14 01:14:56] squiz

    <div id="changeset">
    <span class="removed">-Status: Open</span>
    <span class="added">+Status: Feedback</span>
    <span class="removed">-Assigned To:</span>
    <span class="added">+Assigned To: squiz</span>
    </div>Any chance you can provide sample code because I cannot replicate
    this. It's quite possible that your write case statements differently to
    me.

    ------------------------------------------------------------------------

    [2011-01-13 08:50:02] ty_cybozu

    Description:
    ------------
    While analyzing production source code in conjunction with
    Sonar, a PHP fatal error occurs reporting
    that the maximum function nesting level of '100' has been
    reached.

    Running phpcs -vv on the offending source file revealed that
    phpcs was barfing on a switch statement
    containing several hundred empty case clauses in sequence.

    Test script:
    ---------------
    (attached)

    Expected result:
    ----------------
    I expect PHP_CodeSniffer will process such code segments
    without trouble.

    Actual result:
    --------------
    Registering sniffs in PEAR standard... DONE (26 sniffs
    registered)
    Processing system.php PHP Fatal error: Maximum function
    nesting level of '100' reached, aborting! in
    /usr/share/pear/PHP/CodeSniffer/File.php on line 1306
    PHP Stack trace:
    PHP 1. {main}() /usr/bin/phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:38
    PHP 3. PHP_CodeSniffer->process()
    /usr/share/pear/PHP/CodeSniffer/CLI.php:494
    PHP 4. PHP_CodeSniffer->processFile()
    /usr/share/pear/PHP/CodeSniffer.php:437
    PHP 5. PHP_CodeSniffer->_processFile()
    /usr/share/pear/PHP/CodeSniffer.php:1001
    PHP 6. PHP_CodeSniffer_File->start()
    /usr/share/pear/PHP/CodeSniffer.php:1087
    PHP 7. PHP_CodeSniffer_File->_parse()
    /usr/share/pear/PHP/CodeSniffer/File.php:376
    PHP 8. PHP_CodeSniffer_File::tokenizeString()
    /usr/share/pear/PHP/CodeSniffer/File.php:536
    PHP 9. PHP_CodeSniffer_File::_createScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:873
    PHP 10. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1261
    PHP 11. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397
    PHP 12. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397
    PHP 13. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397

    (... excerpted ...)

    PHP 99. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397

    ------------------------------------------------------------------------
  • Gsherwood at Jan 17, 2011 at 10:38 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18190&edit=1

    ID: 18190
    Updated by: gsherwood@squiz.net
    Reported By: ty_c at cybozu dot co dot jp
    Summary: Analysis crashes on switch containing long sequence
    of empty cases
    -Status: Feedback
    +Status: Wont fix
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: CentOS 5.5 x86_64
    Package Version: 1.3.0RC1
    PHP Version: 5.3.5
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Feedback
    +Status: Wont fix
    Maybe the error is thrown by xdebug, which is why I cannot replicate.

    Either way, I'm not going to rewrite the tokenizer so that code like
    this works correctly. That's a lot of risk to check code that can
    probably be rewritten to make it easier to maintain and unit test.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-01-17 12:39:27] daniels

    I do have the same problem, I can reproduce it with the following
    statement:

    switch ($a) {
    case '1':
    case '2':
    case '3':
    ...
    case '99':
    case '100':
    case '101':
    case '102':
    break;
    }

    (just paste the snippet into a file an add the missing 'case'
    instructions)

    ------------------------------------------------------------------------

    [2011-01-14 01:14:56] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    Any chance you can provide sample code because I cannot replicate this.
    It's quite possible that your write case statements differently to me.

    ------------------------------------------------------------------------

    [2011-01-13 08:50:02] ty_cybozu

    Description:
    ------------
    While analyzing production source code in conjunction with
    Sonar, a PHP fatal error occurs reporting
    that the maximum function nesting level of '100' has been
    reached.

    Running phpcs -vv on the offending source file revealed that
    phpcs was barfing on a switch statement
    containing several hundred empty case clauses in sequence.

    Test script:
    ---------------
    (attached)

    Expected result:
    ----------------
    I expect PHP_CodeSniffer will process such code segments
    without trouble.

    Actual result:
    --------------
    Registering sniffs in PEAR standard... DONE (26 sniffs
    registered)
    Processing system.php PHP Fatal error: Maximum function
    nesting level of '100' reached, aborting! in
    /usr/share/pear/PHP/CodeSniffer/File.php on line 1306
    PHP Stack trace:
    PHP 1. {main}() /usr/bin/phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:38
    PHP 3. PHP_CodeSniffer->process()
    /usr/share/pear/PHP/CodeSniffer/CLI.php:494
    PHP 4. PHP_CodeSniffer->processFile()
    /usr/share/pear/PHP/CodeSniffer.php:437
    PHP 5. PHP_CodeSniffer->_processFile()
    /usr/share/pear/PHP/CodeSniffer.php:1001
    PHP 6. PHP_CodeSniffer_File->start()
    /usr/share/pear/PHP/CodeSniffer.php:1087
    PHP 7. PHP_CodeSniffer_File->_parse()
    /usr/share/pear/PHP/CodeSniffer/File.php:376
    PHP 8. PHP_CodeSniffer_File::tokenizeString()
    /usr/share/pear/PHP/CodeSniffer/File.php:536
    PHP 9. PHP_CodeSniffer_File::_createScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:873
    PHP 10. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1261
    PHP 11. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397
    PHP 12. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397
    PHP 13. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397

    (... excerpted ...)

    PHP 99. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397

    ------------------------------------------------------------------------
  • Ty_c at Jan 18, 2011 at 12:11 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18190&edit=1

    ID: 18190
    Updated by: ty_c@cybozu.co.jp
    Reported By: ty_c at cybozu dot co dot jp
    Summary: Analysis crashes on switch containing long sequence
    of empty cases
    Status: Wont fix
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: CentOS 5.5 x86_64
    Package Version: 1.3.0RC1
    PHP Version: 5.3.5
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Greg, please accept my apologies. It seems I needed to correct my
    account
    registration before I could post here again.
    daniels code segment replicates the problem. I note that although the
    formatting of
    the code at hand is different, this aught not to affect parsing. The
    tokenized streams
    of both mine and daniels should be completely identical.

    $ seq 1 300 | while read X ; do echo " case '$X':" ; done


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-01-17 23:40:36] squiz

    -Status: Feedback
    +Status: Wont fix
    Maybe the error is thrown by xdebug, which is why I cannot replicate.

    Either way, I'm not going to rewrite the tokenizer so that code like
    this works correctly. That's a lot of risk to check code that can
    probably be rewritten to make it easier to maintain and unit test.

    ------------------------------------------------------------------------

    [2011-01-17 12:39:27] daniels

    I do have the same problem, I can reproduce it with the following
    statement:

    switch ($a) {
    case '1':
    case '2':
    case '3':
    ...
    case '99':
    case '100':
    case '101':
    case '102':
    break;
    }

    (just paste the snippet into a file an add the missing 'case'
    instructions)

    ------------------------------------------------------------------------

    [2011-01-14 01:14:56] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    Any chance you can provide sample code because I cannot replicate this.
    It's quite possible that your write case statements differently to me.

    ------------------------------------------------------------------------

    [2011-01-13 08:50:02] ty_cybozu

    Description:
    ------------
    While analyzing production source code in conjunction with
    Sonar, a PHP fatal error occurs reporting
    that the maximum function nesting level of '100' has been
    reached.

    Running phpcs -vv on the offending source file revealed that
    phpcs was barfing on a switch statement
    containing several hundred empty case clauses in sequence.

    Test script:
    ---------------
    (attached)

    Expected result:
    ----------------
    I expect PHP_CodeSniffer will process such code segments
    without trouble.

    Actual result:
    --------------
    Registering sniffs in PEAR standard... DONE (26 sniffs
    registered)
    Processing system.php PHP Fatal error: Maximum function
    nesting level of '100' reached, aborting! in
    /usr/share/pear/PHP/CodeSniffer/File.php on line 1306
    PHP Stack trace:
    PHP 1. {main}() /usr/bin/phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:38
    PHP 3. PHP_CodeSniffer->process()
    /usr/share/pear/PHP/CodeSniffer/CLI.php:494
    PHP 4. PHP_CodeSniffer->processFile()
    /usr/share/pear/PHP/CodeSniffer.php:437
    PHP 5. PHP_CodeSniffer->_processFile()
    /usr/share/pear/PHP/CodeSniffer.php:1001
    PHP 6. PHP_CodeSniffer_File->start()
    /usr/share/pear/PHP/CodeSniffer.php:1087
    PHP 7. PHP_CodeSniffer_File->_parse()
    /usr/share/pear/PHP/CodeSniffer/File.php:376
    PHP 8. PHP_CodeSniffer_File::tokenizeString()
    /usr/share/pear/PHP/CodeSniffer/File.php:536
    PHP 9. PHP_CodeSniffer_File::_createScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:873
    PHP 10. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1261
    PHP 11. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397
    PHP 12. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397
    PHP 13. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397

    (... excerpted ...)

    PHP 99. PHP_CodeSniffer_File::_recurseScopeMap()
    /usr/share/pear/PHP/CodeSniffer/File.php:1397

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 14, '11 at 12:12a
activeJan 18, '11 at 12:11a
posts4
users3
websitepear.php.net

3 users in discussion

Gsherwood: 2 posts Ty_c: 1 post Daniels: 1 post

People

Translate

site design / logo © 2022 Grokbase