Permalink
Browse files

Fixed issue which traits sniff cause mess in php < 5.4

The constant values for tokens vary based on PHP version.
  • Loading branch information...
1 parent a3f25ed commit 2881a0df2a002ebfc4ef29041e60f29ab22374da @jrbasso jrbasso committed Nov 4, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 Sniffs/NamingConventions/ValidTraitNameSniff.php
@@ -13,10 +13,6 @@
* @link http://pear.php.net/package/PHP_CodeSniffer_CakePHP
*/
-if (!defined('T_TRAIT')) {
- define('T_TRAIT', 355);
-}
-
/**
* CakePHP_Sniffs_NamingConventions_ValidTraitNameSniff.
*
@@ -35,9 +31,15 @@ class CakePHP_Sniffs_NamingConventions_ValidTraitNameSniff implements PHP_CodeSn
/**
* Returns an array of tokens this test wants to listen for.
*
+ * If the constant is not defined, ignore because probably the PHP version
+ * is under 5.4.0 and don't have traits in use
+ *
* @return array
*/
public function register() {
+ if (!defined('T_TRAIT')) {
+ return array();
+ }
return array(T_TRAIT);
}

0 comments on commit 2881a0d

Please sign in to comment.