Skip to content

Instantly share code, notes, and snippets.

@AD7six
Created May 2, 2011 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AD7six/6f22e866a3a6d1e40e4e to your computer and use it in GitHub Desktop.
Save AD7six/6f22e866a3a6d1e40e4e to your computer and use it in GitHub Desktop.
Index: CodeSniffer/Standards/PEAR/ruleset.xml
===================================================================
--- CodeSniffer/Standards/PEAR/ruleset.xml (revision 310688)
+++ CodeSniffer/Standards/PEAR/ruleset.xml (working copy)
@@ -36,4 +36,9 @@
</properties>
</rule>
+ <rule ref="Generic.WhiteSpace.ScopeIndent">
+ <properties>
+ <property name="nonIndentingScopes" value="T_SWITCH"/>
+ </properties>
+ </rule>
</ruleset>
Index: CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php
===================================================================
--- CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php (revision 310688)
+++ CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php (working copy)
@@ -1,49 +0,0 @@
-<?php
-/**
- * PEAR_Sniffs_Whitespace_ScopeIndentSniff.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id$
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-if (class_exists('Generic_Sniffs_WhiteSpace_ScopeIndentSniff', true) === false) {
- $error = 'Class Generic_Sniffs_WhiteSpace_ScopeIndentSniff not found';
- throw new PHP_CodeSniffer_Exception($error);
-}
-
-/**
- * PEAR_Sniffs_Whitespace_ScopeIndentSniff.
- *
- * Checks that control structures are structured correctly, and their content
- * is indented correctly.
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: @package_version@
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-class PEAR_Sniffs_WhiteSpace_ScopeIndentSniff extends Generic_Sniffs_WhiteSpace_ScopeIndentSniff
-{
-
- /**
- * Any scope openers that should not cause an indent.
- *
- * @var array(int)
- */
- protected $nonIndentingScopes = array(T_SWITCH);
-
-}//end class
-
-?>
Index: CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
===================================================================
--- CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php (revision 310688)
+++ CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php (working copy)
@@ -55,7 +55,7 @@
*
* @var array(int)
*/
- protected $nonIndentingScopes = array();
+ public $nonIndentingScopes = array();
/**
Index: CodeSniffer.php
===================================================================
--- CodeSniffer.php (revision 310688)
+++ CodeSniffer.php (working copy)
@@ -876,6 +876,7 @@
$this->ruleset[$code]['message'] = (string) $rule->message;
}
+ $constants = get_defined_constants();
// Custom properties.
if (isset($rule->properties) === true) {
foreach ($rule->properties->property as $prop) {
@@ -893,7 +894,19 @@
) {
$value = (string) $prop['value'];
$this->ruleset[$code]['properties'][$name] = explode(',', $value);
+ if (empty($prop['literalstring'])) {
+ foreach($this->ruleset[$code]['properties'][$name] as &$val) {
+ if (preg_match('@^[A-Z_]+$@', $val) && isset($constants[$val])) {
+ $val = $constants[$val];
+ }
+ }
+ }
} else {
+ if (empty($prop['literalstring'])) {
+ if (preg_match('@^[A-Z_]+$@', $prop['value']) && isset($constants[$prop['value']])) {
+ $prop['value'] = $constants[$prop['value']];
+ }
+ }
$this->ruleset[$code]['properties'][$name] = (string) $prop['value'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment