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

ID: 19469
Updated by: gsherwood@squiz.net
Reported By: juanmf@gmail.com
Summary: PHP_CodeSniffer_File::getMemberProperties() sets
wrong scope
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: windows 7
Package Version: 1.3.4
PHP Version: 5.3.8
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Assigned To:
+Assigned To: squiz
Firstly, this has nothing to do with Windows, so I'm not sure why you
have mentioned
the file comment sniff on windows. I'm ignoring that bit for now.

Secondly, only private members can have a leading underscore in you are
using the
PEAR or Squiz standards (you don't say which specific sniff you are
using) so you will
have to remove the underscore from those protected vars if you want the
sniff to
pass.

I will have a look into why the core is not getting the correct
visibility, but it was
certainly not written with the syntax you are using in mind. You'll need
to split those
member vars into separate lines if you want to conform with commenting
standards.
But PHPCS should parse it correctly regardless, so I will get it fixed.


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

[2012-06-10 17:01:39] juanmf

Description:
------------
Hi, I'm using PHPCS 1.3.3 sicne 1.3.4 has lots of bugs with
Windows paths when sniff are specified with this notation
"PEAR.Commenting.FileComment".

The problem is that
PHP_CodeSniffer_File::getMemberProperties() says that $_key
is public in code like the following (see Test script). Therefore
the ValidVariableName sniff complains about the leading
underscore.

Thanks!


Test script:
---------------
class a
{
protected
$_sheet,
$_FieldParser,
$_key;
}


Expected result:
----------------
$_key should pass since its protected.


Actual result:
--------------
$_key fires this:
Public member variable "_key" must not contain a leading
underscore.

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

Search Discussions

  • Gsherwood at Jun 19, 2012 at 6:01 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19469&edit=1

    ID: 19469
    Updated by: gsherwood@squiz.net
    Reported By: juanmf@gmail.com
    Summary: PHP_CodeSniffer_File::getMemberProperties() sets
    wrong scope
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: windows 7
    Package Version: 1.3.4
    PHP Version: 5.3.8
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    Fix committed to Github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/669d7ef76b6c715819a974bb1
    cfd651fe78b3637


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

    [2012-06-19 07:50:20] squiz

    -Assigned To:
    +Assigned To: squiz
    Firstly, this has nothing to do with Windows, so I'm not sure why you
    have mentioned
    the file comment sniff on windows. I'm ignoring that bit for now.

    Secondly, only private members can have a leading underscore in you are
    using the
    PEAR or Squiz standards (you don't say which specific sniff you are
    using) so you will
    have to remove the underscore from those protected vars if you want the
    sniff to
    pass.

    I will have a look into why the core is not getting the correct
    visibility, but it was
    certainly not written with the syntax you are using in mind. You'll need
    to split those
    member vars into separate lines if you want to conform with commenting
    standards.
    But PHPCS should parse it correctly regardless, so I will get it fixed.

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

    [2012-06-10 17:01:39] juanmf

    Description:
    ------------
    Hi, I'm using PHPCS 1.3.3 sicne 1.3.4 has lots of bugs with
    Windows paths when sniff are specified with this notation
    "PEAR.Commenting.FileComment".

    The problem is that
    PHP_CodeSniffer_File::getMemberProperties() says that $_key
    is public in code like the following (see Test script). Therefore
    the ValidVariableName sniff complains about the leading
    underscore.

    Thanks!


    Test script:
    ---------------
    class a
    {
    protected
    $_sheet,
    $_FieldParser,
    $_key;
    }


    Expected result:
    ----------------
    $_key should pass since its protected.


    Actual result:
    --------------
    $_key fires this:
    Public member variable "_key" must not contain a leading
    underscore.

    ------------------------------------------------------------------------
  • Juanmf at Jun 19, 2012 at 6:05 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19469&edit=1

    ID: 19469
    Updated by: juanmf@gmail.com
    Reported By: juanmf@gmail.com
    Summary: PHP_CodeSniffer_File::getMemberProperties() sets
    wrong scope
    Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: windows 7
    Package Version: 1.3.4
    PHP Version: 5.3.8
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Hi Squiz,

    I see you fixed it really fast, I had it already fixed in my local
    copy. But I added
    more tokens to the array (since variables can be asigned some values, in
    which
    case the loop wont get to the visibility keyword):
    $valid = array(
    T_PUBLIC,
    T_PRIVATE,
    T_PROTECTED,
    T_STATIC,
    T_WHITESPACE,
    T_COMMENT,
    T_DOC_COMMENT,
    /* BEGGINS MY ADDITION to overcome protected $a, $b;*/
    T_COMMA,
    T_DOUBLE_ARROW,
    T_OPEN_PARENTHESIS,
    T_CLOSE_PARENTHESIS,
    T_ARRAY,
    T_VARIABLE,
    T_EQUAL,
    T_STRING,
    T_LNUMBER,
    T_SEMICOLON,
    T_CONSTANT_ENCAPSED_STRING,
    /* ENDS MY ADDITION to overcome protected $a, $b;*/
    );

    Thanks,
    Cheers!


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

    [2012-06-19 08:06:54] squiz

    -Status: Assigned
    +Status: Closed
    Fix committed to Github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/669d7ef76b6c715819a974bb1
    cfd651fe78b3637

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

    [2012-06-19 07:50:20] squiz

    -Assigned To:
    +Assigned To: squiz
    Firstly, this has nothing to do with Windows, so I'm not sure why you
    have mentioned
    the file comment sniff on windows. I'm ignoring that bit for now.

    Secondly, only private members can have a leading underscore in you are
    using the
    PEAR or Squiz standards (you don't say which specific sniff you are
    using) so you will
    have to remove the underscore from those protected vars if you want the
    sniff to
    pass.

    I will have a look into why the core is not getting the correct
    visibility, but it was
    certainly not written with the syntax you are using in mind. You'll need
    to split those
    member vars into separate lines if you want to conform with commenting
    standards.
    But PHPCS should parse it correctly regardless, so I will get it fixed.

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

    [2012-06-10 17:01:39] juanmf

    Description:
    ------------
    Hi, I'm using PHPCS 1.3.3 sicne 1.3.4 has lots of bugs with
    Windows paths when sniff are specified with this notation
    "PEAR.Commenting.FileComment".

    The problem is that
    PHP_CodeSniffer_File::getMemberProperties() says that $_key
    is public in code like the following (see Test script). Therefore
    the ValidVariableName sniff complains about the leading
    underscore.

    Thanks!


    Test script:
    ---------------
    class a
    {
    protected
    $_sheet,
    $_FieldParser,
    $_key;
    }


    Expected result:
    ----------------
    $_key should pass since its protected.


    Actual result:
    --------------
    $_key fires this:
    Public member variable "_key" must not contain a leading
    underscore.

    ------------------------------------------------------------------------
  • Juanmf at Jun 19, 2012 at 6:13 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19469&edit=1

    ID: 19469
    Updated by: juanmf@gmail.com
    Reported By: juanmf@gmail.com
    Summary: PHP_CodeSniffer_File::getMemberProperties() sets
    wrong scope
    Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: windows 7
    Package Version: 1.3.4
    PHP Version: 5.3.8
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Made a mistake,
    This T_SEMICOLON should not be there in $valid. Sorry.

    Thanks.


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

    [2012-06-19 08:10:43] juanmf

    Hi Squiz,

    I see you fixed it really fast, I had it already fixed in my local
    copy. But I added
    more tokens to the array (since variables can be asigned some values, in
    which
    case the loop wont get to the visibility keyword):
    $valid = array(
    T_PUBLIC,
    T_PRIVATE,
    T_PROTECTED,
    T_STATIC,
    T_WHITESPACE,
    T_COMMENT,
    T_DOC_COMMENT,
    /* BEGGINS MY ADDITION to overcome protected $a, $b;*/
    T_COMMA,
    T_DOUBLE_ARROW,
    T_OPEN_PARENTHESIS,
    T_CLOSE_PARENTHESIS,
    T_ARRAY,
    T_VARIABLE,
    T_EQUAL,
    T_STRING,
    T_LNUMBER,
    T_SEMICOLON,
    T_CONSTANT_ENCAPSED_STRING,
    /* ENDS MY ADDITION to overcome protected $a, $b;*/
    );

    Thanks,
    Cheers!

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

    [2012-06-19 08:06:54] squiz

    -Status: Assigned
    +Status: Closed
    Fix committed to Github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/669d7ef76b6c715819a974bb1
    cfd651fe78b3637

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

    [2012-06-19 07:50:20] squiz

    -Assigned To:
    +Assigned To: squiz
    Firstly, this has nothing to do with Windows, so I'm not sure why you
    have mentioned
    the file comment sniff on windows. I'm ignoring that bit for now.

    Secondly, only private members can have a leading underscore in you are
    using the
    PEAR or Squiz standards (you don't say which specific sniff you are
    using) so you will
    have to remove the underscore from those protected vars if you want the
    sniff to
    pass.

    I will have a look into why the core is not getting the correct
    visibility, but it was
    certainly not written with the syntax you are using in mind. You'll need
    to split those
    member vars into separate lines if you want to conform with commenting
    standards.
    But PHPCS should parse it correctly regardless, so I will get it fixed.

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

    [2012-06-10 17:01:39] juanmf

    Description:
    ------------
    Hi, I'm using PHPCS 1.3.3 sicne 1.3.4 has lots of bugs with
    Windows paths when sniff are specified with this notation
    "PEAR.Commenting.FileComment".

    The problem is that
    PHP_CodeSniffer_File::getMemberProperties() says that $_key
    is public in code like the following (see Test script). Therefore
    the ValidVariableName sniff complains about the leading
    underscore.

    Thanks!


    Test script:
    ---------------
    class a
    {
    protected
    $_sheet,
    $_FieldParser,
    $_key;
    }


    Expected result:
    ----------------
    $_key should pass since its protected.


    Actual result:
    --------------
    $_key fires this:
    Public member variable "_key" must not contain a leading
    underscore.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJun 19, '12 at 5:44a
activeJun 19, '12 at 6:13a
posts4
users2
websitepear.php.net

2 users in discussion

Juanmf: 2 posts Gsherwood: 2 posts

People

Translate

site design / logo © 2022 Grokbase