Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Require space after typecast when concatenation before.

Follow-up to 37a3f5d
  • Loading branch information...
commit 28f647d7d5887e06485da39925a650e3e417a949 1 parent 37a3f5d
Chris Bandy authored August 27, 2011
10  PHP/CodeSniffer/Standards/Kohana/Sniffs/Operators/TypeCastingSniff.php
@@ -58,12 +58,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58 58
         $before = $tokens[$stackPtr - 1];
59 59
         $after = $tokens[$stackPtr + 1];
60 60
 
61  
-        if ($before['type'] !== 'T_STRING_CONCAT'
62  
-            AND ($before['type'] !== 'T_WHITESPACE'
63  
-                OR ($tokens[$stackPtr]['line'] !== $tokens[$stackPtr - 2]['line'] + 1
64  
-                    AND $before['content'] !== ' ')
65  
-                OR $after['type'] !== 'T_WHITESPACE'
66  
-                OR $after['content'] !== ' '))
  61
+        if (($after['type'] !== 'T_WHITESPACE' OR $after['content'] !== ' ')
  62
+            OR ($before['type'] !== 'T_STRING_CONCAT'
  63
+                AND ($before['type'] !== 'T_WHITESPACE' OR $before['content'] !== ' ')
  64
+                AND $tokens[$stackPtr]['line'] !== $tokens[$stackPtr - 2]['line'] + 1))
67 65
         {
68 66
             $error = 'Typecast operators must be first on the line or have a space on either side';
69 67
             $phpcsFile->addError($error, $stackPtr);
3  test/PHP_CodeSniffer/CodeSniffer/Standards/Kohana/Tests/Operators/TypeCastingUnitTest.inc
@@ -7,4 +7,5 @@ $foo = (integer) $bar;
7 7
 $foo = (boolean) $bar;
8 8
 	(int) $indented;
9 9
 
10  
-'{'.(int) $digits.'}'
  10
+'{'.(int) $digits.'}';
  11
+'{'.(int)$digits.'}';
3  test/PHP_CodeSniffer/CodeSniffer/Standards/Kohana/Tests/Operators/TypeCastingUnitTest.php
@@ -40,7 +40,8 @@ public function getErrorList()
40 40
         return array(
41 41
             3 => 1,
42 42
             6 => 1,
43  
-            7 => 1
  43
+            7 => 1,
  44
+            11 => 1,
44 45
         );
45 46
     }
46 47
 
2  test/PHP_CodeSniffer/CodeSniffer/Standards/Kohana/Tests/WhiteSpace/NoConcatenationSpaceUnitTest.inc
@@ -13,4 +13,4 @@ $test = 'extra'
13 13
 
14 14
 	.'indentation';
15 15
 
16  
-'{'.(int) $digits.'}'
  16
+'{'.(int) $digits.'}';

0 notes on commit 28f647d

Please sign in to comment.
Something went wrong with that request. Please try again.