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

ID: 18495
Updated by: gsherwood@squiz.net
Reported By: andydawson76 at gmail dot com
Summary: Allow use of constants in ruleset properties
Status: Open
Type: Feature/Change Request
Package: PHP_CodeSniffer
Operating System: linux
Package Version: SVN
PHP Version: 5.3.6
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Assigned To:
+Assigned To: squiz
Your patch references a $constants array, which does not exist. If I
change the code to use the constant() function I can get it working, but
it still assumes constants have been defined in upper-case, which may
not be the case in all standards despite it being a convention.

It might be better to come up with some other way of annotating a
constant value rather than assuming they want a constant value as I
think this would be a fairly rare case and we don't want to have no way
of using the string PHP_EOL just because there is a constant with the
same name.


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

[2011-05-01 17:35:16] ad7six

Description:
------------
PHP has quite a few built in contants, and if you
want to use them in a rule property, right now you
have to use the value, not the contstant name.

This simple diff:
https://gist.github.com/8e61e83c56b9aa95d100
would allow users to use the name of such
constants in their ruleset files, which is easier to
read and cross-compatible (in the event the
constant changes based on OS, or other factors)

Test script:
---------------
/*
Include the following in a ruleset:

<property name="someproperty" type="array"
value="A_PREDEFINED_CONSTANT"/>
Lets assume it's value is 5
*/
print_r($this->someproperty);

Expected result:
----------------
array(5);

Actual result:
--------------
array("A_PREDEFINED_CONSTANT"); // or the person
editing the ruleset.xml file has to use "5"

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

Search Discussions

  • Gsherwood at May 2, 2011 at 6:57 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18495&edit=1

    ID: 18495
    Updated by: gsherwood@squiz.net
    Reported By: andydawson76 at gmail dot com
    Summary: Allow use of constants in ruleset properties
    -Status: Assigned
    +Status: Open
    Type: Feature/Change Request
    Package: PHP_CodeSniffer
    Operating System: linux
    Package Version: SVN
    PHP Version: 5.3.6
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Open



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

    [2011-05-02 06:37:12] squiz

    -Assigned To:
    +Assigned To: squiz
    Your patch references a $constants array, which does not exist. If I
    change the code to use the constant() function I can get it working, but
    it still assumes constants have been defined in upper-case, which may
    not be the case in all standards despite it being a convention.

    It might be better to come up with some other way of annotating a
    constant value rather than assuming they want a constant value as I
    think this would be a fairly rare case and we don't want to have no way
    of using the string PHP_EOL just because there is a constant with the
    same name.

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

    [2011-05-01 17:35:16] ad7six

    Description:
    ------------
    PHP has quite a few built in contants, and if you
    want to use them in a rule property, right now you
    have to use the value, not the contstant name.

    This simple diff:
    https://gist.github.com/8e61e83c56b9aa95d100
    would allow users to use the name of such
    constants in their ruleset files, which is easier to
    read and cross-compatible (in the event the
    constant changes based on OS, or other factors)

    Test script:
    ---------------
    /*
    Include the following in a ruleset:

    <property name="someproperty" type="array"
    value="A_PREDEFINED_CONSTANT"/>
    Lets assume it's value is 5
    */
    print_r($this->someproperty);

    Expected result:
    ----------------
    array(5);

    Actual result:
    --------------
    array("A_PREDEFINED_CONSTANT"); // or the person
    editing the ruleset.xml file has to use "5"

    ------------------------------------------------------------------------
  • Andydawson76 at May 2, 2011 at 8:05 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18495&edit=1

    ID: 18495
    Updated by: andydawson76@gmail.com
    Reported By: andydawson76 at gmail dot com
    Summary: Allow use of constants in ruleset properties
    Status: Open
    Type: Feature/Change Request
    Package: PHP_CodeSniffer
    Operating System: linux
    Package Version: SVN
    PHP Version: 5.3.6
    Roadmap Versions:
    New Comment:

    I've updated the original gist, and here's a use case similar to what
    prompted the
    ticket in the first place https://gist.github.com/6f22e866a3a6d1e40e4e


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

    [2011-05-02 07:58:27] squiz

    -Status: Assigned
    +Status: Open


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

    [2011-05-02 06:37:12] squiz

    -Assigned To:
    +Assigned To: squiz
    Your patch references a $constants array, which does not exist. If I
    change the code to use the constant() function I can get it working, but
    it still assumes constants have been defined in upper-case, which may
    not be the case in all standards despite it being a convention.

    It might be better to come up with some other way of annotating a
    constant value rather than assuming they want a constant value as I
    think this would be a fairly rare case and we don't want to have no way
    of using the string PHP_EOL just because there is a constant with the
    same name.

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

    [2011-05-01 17:35:16] ad7six

    Description:
    ------------
    PHP has quite a few built in contants, and if you
    want to use them in a rule property, right now you
    have to use the value, not the contstant name.

    This simple diff:
    https://gist.github.com/8e61e83c56b9aa95d100
    would allow users to use the name of such
    constants in their ruleset files, which is easier to
    read and cross-compatible (in the event the
    constant changes based on OS, or other factors)

    Test script:
    ---------------
    /*
    Include the following in a ruleset:

    <property name="someproperty" type="array"
    value="A_PREDEFINED_CONSTANT"/>
    Lets assume it's value is 5
    */
    print_r($this->someproperty);

    Expected result:
    ----------------
    array(5);

    Actual result:
    --------------
    array("A_PREDEFINED_CONSTANT"); // or the person
    editing the ruleset.xml file has to use "5"

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMay 2, '11 at 5:36a
activeMay 2, '11 at 8:05a
posts3
users2
websitepear.php.net

2 users in discussion

Gsherwood: 2 posts Andydawson76: 1 post

People

Translate

site design / logo © 2022 Grokbase