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"
------------------------------------------------------------------------