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

ID: 17236
Updated by: demon.gene@gmail.com
Reported By: demon dot gene at gmail dot com
Summary: PHP Warning due to token_get_all(), #1
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: RHEL4
Package Version: 1.2.2
PHP Version: 5.2.4
Roadmap Versions:
New Comment:

That "Warning" line should be showing line 65, not 66, so that all
references to DoubleQuoteUsageSniff.php should show 65.


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

[2010-03-17 00:02:30] ashnazg

Description:
------------
Odd edge case, but could be fairly typical for creating SQL statement
strings, causes a PHP warning from the Squiz's
Strings/DoubleQuoteUsageSniff.

From experimenting with my test file, these characteristics seem
necessary:
- a string portion that contains a $variable inside literal
singlequotes ===> bar = '$z',
- a string portion that contains a variable outside of the doublequotes
that is attached via concatenation, but whose surrounding string
portions include the literal single quotes around it ===> baz = '" . $a
. "'..."
- the newline that splits the singlequoted variable piece from the
doublequoted variable piece

Test script:
---------------
<?php
$x = "bar = '$z',
baz = '" . $a . "'...";
?>

Expected result:
----------------
phpcs --standard=Squiz --report=summary test.php


PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------
FILE ERRORS WARNINGS
--------------------------------------------------------------------------
test.php 4 0
--------------------------------------------------------------------------
A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
--------------------------------------------------------------------------

Actual result:
--------------
PHP Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
on line 65
PHP Stack trace:
PHP 1. {main}() phpcs:0
PHP 2. PHP_CodeSniffer_CLI->process() phpcs:30
PHP 3. PHP_CodeSniffer->process() PHP/CodeSniffer/CLI.php:429
PHP 4. PHP_CodeSniffer->processFile() PHP/CodeSniffer.php:376
PHP 5. PHP_CodeSniffer->_processFile() PHP/CodeSniffer.php:836
PHP 6. PHP_CodeSniffer_File->start() PHP/CodeSniffer.php:921
PHP 7. Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
PHP/CodeSniffer/File.php:431
PHP 8. token_get_all()
PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
on line 66

Call Stack:
0.0004 50256 1. {main}() phpcs:0
0.0187 1018560 2. PHP_CodeSniffer_CLI->process() phpcs:30
0.0193 1022920 3. PHP_CodeSniffer->process()
PHP/CodeSniffer/CLI.php:429
0.1363 4577440 4. PHP_CodeSniffer->processFile()
PHP/CodeSniffer.php:376
0.1365 4577808 5. PHP_CodeSniffer->_processFile()
PHP/CodeSniffer.php:836
0.1365 4578620 6. PHP_CodeSniffer_File->start()
PHP/CodeSniffer.php:921
0.1514 4721892 7.
Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
PHP/CodeSniffer/File.php:431
0.1514 4721892 8. token_get_all()
PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------
FILE ERRORS WARNINGS
--------------------------------------------------------------------------
test.php 4 0
--------------------------------------------------------------------------
A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
--------------------------------------------------------------------------

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

Search Discussions

  • Gsherwood at Mar 17, 2010 at 5:42 am
    Edit report at http://pear.php.net/bugs/bug.php?id=17236&edit=1

    ID: 17236
    Updated by: gsherwood@squiz.net
    Reported By: demon dot gene at gmail dot com
    -Summary: PHP Warning due to token_get_all(), #1
    +Summary: PHP Warning due to token_get_all() in
    DoubleQuoteUsageSniff
    Status: Open
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: RHEL4
    Package Version: 1.2.2
    PHP Version: 5.2.4
    Roadmap Versions:
    New Comment:

    -Summary: PHP Warning due to token_get_all(), #1
    +Summary: PHP Warning due to token_get_all() in
    DoubleQuoteUsageSniff



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

    [2010-03-17 00:09:17] ashnazg

    That "Warning" line should be showing line 65, not 66, so that all
    references to DoubleQuoteUsageSniff.php should show 65.

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

    [2010-03-17 00:02:30] ashnazg

    Description:
    ------------
    Odd edge case, but could be fairly typical for creating SQL statement
    strings, causes a PHP warning from the Squiz's
    Strings/DoubleQuoteUsageSniff.

    From experimenting with my test file, these characteristics seem
    necessary:
    - a string portion that contains a $variable inside literal
    singlequotes ===> bar = '$z',
    - a string portion that contains a variable outside of the doublequotes
    that is attached via concatenation, but whose surrounding string
    portions include the literal single quotes around it ===> baz = '" . $a
    . "'..."
    - the newline that splits the singlequoted variable piece from the
    doublequoted variable piece

    Test script:
    ---------------
    <?php
    $x = "bar = '$z',
    baz = '" . $a . "'...";
    ?>

    Expected result:
    ----------------
    phpcs --standard=Squiz --report=summary test.php


    PHP CODE SNIFFER REPORT SUMMARY
    --------------------------------------------------------------------------
    FILE ERRORS WARNINGS
    --------------------------------------------------------------------------
    test.php 4 0
    --------------------------------------------------------------------------
    A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
    --------------------------------------------------------------------------

    Actual result:
    --------------
    PHP Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
    on line 65
    PHP Stack trace:
    PHP 1. {main}() phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process() phpcs:30
    PHP 3. PHP_CodeSniffer->process() PHP/CodeSniffer/CLI.php:429
    PHP 4. PHP_CodeSniffer->processFile() PHP/CodeSniffer.php:376
    PHP 5. PHP_CodeSniffer->_processFile() PHP/CodeSniffer.php:836
    PHP 6. PHP_CodeSniffer_File->start() PHP/CodeSniffer.php:921
    PHP 7. Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
    PHP/CodeSniffer/File.php:431
    PHP 8. token_get_all()
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


    Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
    on line 66

    Call Stack:
    0.0004 50256 1. {main}() phpcs:0
    0.0187 1018560 2. PHP_CodeSniffer_CLI->process() phpcs:30
    0.0193 1022920 3. PHP_CodeSniffer->process()
    PHP/CodeSniffer/CLI.php:429
    0.1363 4577440 4. PHP_CodeSniffer->processFile()
    PHP/CodeSniffer.php:376
    0.1365 4577808 5. PHP_CodeSniffer->_processFile()
    PHP/CodeSniffer.php:836
    0.1365 4578620 6. PHP_CodeSniffer_File->start()
    PHP/CodeSniffer.php:921
    0.1514 4721892 7.
    Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
    PHP/CodeSniffer/File.php:431
    0.1514 4721892 8. token_get_all()
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


    PHP CODE SNIFFER REPORT SUMMARY
    --------------------------------------------------------------------------
    FILE ERRORS WARNINGS
    --------------------------------------------------------------------------
    test.php 4 0
    --------------------------------------------------------------------------
    A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
    --------------------------------------------------------------------------

    ------------------------------------------------------------------------
  • Gsherwood at Mar 18, 2010 at 11:51 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=17236&edit=1

    ID: 17236
    Updated by: gsherwood@squiz.net
    Reported By: demon dot gene at gmail dot com
    Summary: PHP Warning due to token_get_all() in
    DoubleQuoteUsageSniff
    -Status: Open
    +Status: Feedback
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: RHEL4
    Package Version: 1.2.2
    PHP Version: 5.2.4
    -Assigned To:
    +Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    Thank you for taking the time to report a problem with the package.
    This problem may have been already fixed by a previous change that
    is in the SVN of the package. Please checking out the SVN
    repository of this package and upgrade

    svn checkout svn.php.net/repository/pear/packages/PHP_CodeSniffer/trunk
    pear upgrade package2.xml

    or

    pear upgrade package.xml

    If you are able to reproduce the bug with the latest SVN,
    please change the status back to "Open".
    Again, thank you for your continued support of PEAR.

    I'm not getting this with the SVN version. I fixed something related in
    another
    sniff, but don't see a specific fix for this.


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

    [2010-03-17 06:37:52] squiz

    -Summary: PHP Warning due to token_get_all(), #1
    +Summary: PHP Warning due to token_get_all() in
    DoubleQuoteUsageSniff


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

    [2010-03-17 00:09:17] ashnazg

    That "Warning" line should be showing line 65, not 66, so that all
    references to DoubleQuoteUsageSniff.php should show 65.

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

    [2010-03-17 00:02:30] ashnazg

    Description:
    ------------
    Odd edge case, but could be fairly typical for creating SQL statement
    strings, causes a PHP warning from the Squiz's
    Strings/DoubleQuoteUsageSniff.

    From experimenting with my test file, these characteristics seem
    necessary:
    - a string portion that contains a $variable inside literal
    singlequotes ===> bar = '$z',
    - a string portion that contains a variable outside of the doublequotes
    that is attached via concatenation, but whose surrounding string
    portions include the literal single quotes around it ===> baz = '" . $a
    . "'..."
    - the newline that splits the singlequoted variable piece from the
    doublequoted variable piece

    Test script:
    ---------------
    <?php
    $x = "bar = '$z',
    baz = '" . $a . "'...";
    ?>

    Expected result:
    ----------------
    phpcs --standard=Squiz --report=summary test.php


    PHP CODE SNIFFER REPORT SUMMARY
    --------------------------------------------------------------------------
    FILE ERRORS WARNINGS
    --------------------------------------------------------------------------
    test.php 4 0
    --------------------------------------------------------------------------
    A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
    --------------------------------------------------------------------------

    Actual result:
    --------------
    PHP Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
    on line 65
    PHP Stack trace:
    PHP 1. {main}() phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process() phpcs:30
    PHP 3. PHP_CodeSniffer->process() PHP/CodeSniffer/CLI.php:429
    PHP 4. PHP_CodeSniffer->processFile() PHP/CodeSniffer.php:376
    PHP 5. PHP_CodeSniffer->_processFile() PHP/CodeSniffer.php:836
    PHP 6. PHP_CodeSniffer_File->start() PHP/CodeSniffer.php:921
    PHP 7. Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
    PHP/CodeSniffer/File.php:431
    PHP 8. token_get_all()
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


    Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
    on line 66

    Call Stack:
    0.0004 50256 1. {main}() phpcs:0
    0.0187 1018560 2. PHP_CodeSniffer_CLI->process() phpcs:30
    0.0193 1022920 3. PHP_CodeSniffer->process()
    PHP/CodeSniffer/CLI.php:429
    0.1363 4577440 4. PHP_CodeSniffer->processFile()
    PHP/CodeSniffer.php:376
    0.1365 4577808 5. PHP_CodeSniffer->_processFile()
    PHP/CodeSniffer.php:836
    0.1365 4578620 6. PHP_CodeSniffer_File->start()
    PHP/CodeSniffer.php:921
    0.1514 4721892 7.
    Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
    PHP/CodeSniffer/File.php:431
    0.1514 4721892 8. token_get_all()
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


    PHP CODE SNIFFER REPORT SUMMARY
    --------------------------------------------------------------------------
    FILE ERRORS WARNINGS
    --------------------------------------------------------------------------
    test.php 4 0
    --------------------------------------------------------------------------
    A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
    --------------------------------------------------------------------------

    ------------------------------------------------------------------------
  • Demon Gene at Mar 22, 2010 at 8:57 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=17236&edit=1

    ID: 17236
    Updated by: demon.gene@gmail.com
    Reported By: demon dot gene at gmail dot com
    Summary: PHP Warning due to token_get_all() in
    DoubleQuoteUsageSniff
    -Status: Feedback
    +Status: Open
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: RHEL4
    -Package Version: 1.2.2
    +Package Version: SVN-20100322
    PHP Version: 5.2.4
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Feedback
    +Status: Open
    -Package Version: 1.2.2
    +Package Version: SVN-20100322
    The current SVN still throws the same PHP Warning against my test
    script. I think the recent change (February) that helps with bug #17237
    was done directly in the other reported sniff
    (Generic.CodeAnalysis.UnusedFunctionParameter), whereas nothing has
    changed since October in this sniff (Squiz.Strings.DoubleQuoteUsage).


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

    [2010-03-19 00:46:50] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    Thank you for taking the time to report a problem with the package.
    This problem may have been already fixed by a previous change that
    is in the SVN of the package. Please checking out the SVN
    repository of this package and upgrade

    svn checkout svn.php.net/repository/pear/packages/PHP_CodeSniffer/trunk
    pear upgrade package2.xml

    or

    pear upgrade package.xml

    If you are able to reproduce the bug with the latest SVN,
    please change the status back to "Open".
    Again, thank you for your continued support of PEAR.

    I'm not getting this with the SVN version. I fixed something related in
    another
    sniff, but don't see a specific fix for this.

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

    [2010-03-17 06:37:52] squiz

    -Summary: PHP Warning due to token_get_all(), #1
    +Summary: PHP Warning due to token_get_all() in
    DoubleQuoteUsageSniff


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

    [2010-03-17 00:09:17] ashnazg

    That "Warning" line should be showing line 65, not 66, so that all
    references to DoubleQuoteUsageSniff.php should show 65.

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

    [2010-03-17 00:02:30] ashnazg

    Description:
    ------------
    Odd edge case, but could be fairly typical for creating SQL statement
    strings, causes a PHP warning from the Squiz's
    Strings/DoubleQuoteUsageSniff.

    From experimenting with my test file, these characteristics seem
    necessary:
    - a string portion that contains a $variable inside literal
    singlequotes ===> bar = '$z',
    - a string portion that contains a variable outside of the doublequotes
    that is attached via concatenation, but whose surrounding string
    portions include the literal single quotes around it ===> baz = '" . $a
    . "'..."
    - the newline that splits the singlequoted variable piece from the
    doublequoted variable piece

    Test script:
    ---------------
    <?php
    $x = "bar = '$z',
    baz = '" . $a . "'...";
    ?>

    Expected result:
    ----------------
    phpcs --standard=Squiz --report=summary test.php


    PHP CODE SNIFFER REPORT SUMMARY
    --------------------------------------------------------------------------
    FILE ERRORS WARNINGS
    --------------------------------------------------------------------------
    test.php 4 0
    --------------------------------------------------------------------------
    A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
    --------------------------------------------------------------------------

    Actual result:
    --------------
    PHP Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
    on line 65
    PHP Stack trace:
    PHP 1. {main}() phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process() phpcs:30
    PHP 3. PHP_CodeSniffer->process() PHP/CodeSniffer/CLI.php:429
    PHP 4. PHP_CodeSniffer->processFile() PHP/CodeSniffer.php:376
    PHP 5. PHP_CodeSniffer->_processFile() PHP/CodeSniffer.php:836
    PHP 6. PHP_CodeSniffer_File->start() PHP/CodeSniffer.php:921
    PHP 7. Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
    PHP/CodeSniffer/File.php:431
    PHP 8. token_get_all()
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


    Warning: Unexpected character in input: ''' (ASCII=39) state=1 in
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php
    on line 66

    Call Stack:
    0.0004 50256 1. {main}() phpcs:0
    0.0187 1018560 2. PHP_CodeSniffer_CLI->process() phpcs:30
    0.0193 1022920 3. PHP_CodeSniffer->process()
    PHP/CodeSniffer/CLI.php:429
    0.1363 4577440 4. PHP_CodeSniffer->processFile()
    PHP/CodeSniffer.php:376
    0.1365 4577808 5. PHP_CodeSniffer->_processFile()
    PHP/CodeSniffer.php:836
    0.1365 4578620 6. PHP_CodeSniffer_File->start()
    PHP/CodeSniffer.php:921
    0.1514 4721892 7.
    Squiz_Sniffs_Strings_DoubleQuoteUsageSniff->process()
    PHP/CodeSniffer/File.php:431
    0.1514 4721892 8. token_get_all()
    PHP/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php:65


    PHP CODE SNIFFER REPORT SUMMARY
    --------------------------------------------------------------------------
    FILE ERRORS WARNINGS
    --------------------------------------------------------------------------
    test.php 4 0
    --------------------------------------------------------------------------
    A TOTAL OF 4 ERROR(S) AND 0 WARNING(S) WERE FOUND IN 1 FILE(S)
    --------------------------------------------------------------------------

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 16, '10 at 11:14p
activeMar 22, '10 at 8:57p
posts4
users2
websitepear.php.net

2 users in discussion

Demon Gene: 2 posts Gsherwood: 2 posts

People

Translate

site design / logo © 2021 Grokbase