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

ID: 18973
Comment by: brian.kendig@disney.com
Reported By: brian dot kendig at disney dot com
Summary: phpcs is looking for variables in a nowdoc
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: Mac OS X 10.6.8
Package Version: SVN
PHP Version: 5.3.8
Roadmap Versions:
New Comment:

The same error also occurs in heredocs. php won't recognize $456 as a
valid variable name, so phpcs shouldn't be catching it either.


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

[2011-11-08 17:33:51] bkendig

Description:
------------
A quoted value in a nowdoc, like "$456", gives an error: Variable
"456" is not in valid camel caps format

According to
"http://php.net/manual/en/language.types.string.php", text in
nowdocs is not parsed. phpcs should not be flagging an error
here.

Test script:
---------------
$ cat foo.php
<?php
$foo = <<<'BAR'
$123
"$456"
BAR;


Expected result:
----------------
Nothing.


Actual result:
--------------
$ php PHP_CodeSniffer/scripts/phpcs -- foo.php --
standard=Zend

FILE: /Users/brkendig/foo.php
------------------------------------------------------------------------
--------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
------------------------------------------------------------------------
--------
4 | ERROR | Variable "456" is not in valid camel caps format
------------------------------------------------------------------------
--------

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

Search Discussions

  • Gsherwood at Nov 11, 2011 at 1:28 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18973&edit=1

    ID: 18973
    Updated by: gsherwood@squiz.net
    Reported By: brian dot kendig at disney dot com
    Summary: phpcs is looking for variables in a nowdoc
    -Status: Open
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Mac OS X 10.6.8
    Package Version: SVN
    PHP Version: 5.3.8
    -Assigned To:
    +Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Closed
    -Assigned To:
    +Assigned To: squiz
    Fix committed. PHP tokenizes heredocs and nowdocs using the same tokens,
    but that
    confuses some sniffs. PHP_CodeSniffer now detects nowdocs and uses it's
    own token
    types. So look for T_START_NOWDOC instead of T_START_HEREDOC if you want
    to
    detect nowdocs specifically.


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

    [2011-11-08 19:18:23] bkendig

    The same error also occurs in heredocs. php won't recognize $456 as a
    valid variable name, so phpcs shouldn't be catching it either.

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

    [2011-11-08 17:33:51] bkendig

    Description:
    ------------
    A quoted value in a nowdoc, like "$456", gives an error: Variable
    "456" is not in valid camel caps format

    According to
    "http://php.net/manual/en/language.types.string.php", text in
    nowdocs is not parsed. phpcs should not be flagging an error
    here.

    Test script:
    ---------------
    $ cat foo.php
    <?php
    $foo = <<<'BAR'
    $123
    "$456"
    BAR;


    Expected result:
    ----------------
    Nothing.


    Actual result:
    --------------
    $ php PHP_CodeSniffer/scripts/phpcs -- foo.php --
    standard=Zend

    FILE: /Users/brkendig/foo.php
    ------------------------------------------------------------------------
    --------
    FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
    ------------------------------------------------------------------------
    --------
    4 | ERROR | Variable "456" is not in valid camel caps format
    ------------------------------------------------------------------------
    --------

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedNov 8, '11 at 6:19p
activeNov 11, '11 at 1:28a
posts2
users2
websitepear.php.net

2 users in discussion

Brian Kendig: 1 post Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase