GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 699b70...879176 )
by Chris
13:23
created
CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -30,43 +30,43 @@
 block discarded – undo
30 30
 class Squiz_Sniffs_PHP_DisallowInlineIfSniff implements PHP_CodeSniffer_Sniff
31 31
 {
32 32
 
33
-    /**
34
-     * A list of tokenizers this sniff supports.
35
-     *
36
-     * @var array
37
-     */
38
-    public $supportedTokenizers = array(
39
-                                   'PHP',
40
-                                   'JS',
41
-                                  );
33
+	 /**
34
+	  * A list of tokenizers this sniff supports.
35
+	  *
36
+	  * @var array
37
+	  */
38
+	 public $supportedTokenizers = array(
39
+											  'PHP',
40
+											  'JS',
41
+											 );
42 42
 
43 43
 
44
-    /**
45
-     * Returns an array of tokens this test wants to listen for.
46
-     *
47
-     * @return array
48
-     */
49
-    public function register()
50
-    {
51
-        return array(T_INLINE_THEN);
44
+	 /**
45
+	  * Returns an array of tokens this test wants to listen for.
46
+	  *
47
+	  * @return array
48
+	  */
49
+	 public function register()
50
+	 {
51
+		  return array(T_INLINE_THEN);
52 52
 
53
-    }//end register()
53
+	 }//end register()
54 54
 
55 55
 
56
-    /**
57
-     * Processes this test, when one of its tokens is encountered.
58
-     *
59
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
-     * @param int                  $stackPtr  The position of the current token
61
-     *                                        in the stack passed in $tokens.
62
-     *
63
-     * @return void
64
-     */
65
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
-    {
67
-        $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found');
56
+	 /**
57
+	  * Processes this test, when one of its tokens is encountered.
58
+	  *
59
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+	  * @param int                  $stackPtr  The position of the current token
61
+	  *                                        in the stack passed in $tokens.
62
+	  *
63
+	  * @return void
64
+	  */
65
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+	 {
67
+		  $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found');
68 68
 
69
-    }//end process()
69
+	 }//end process()
70 70
 
71 71
 
72 72
 }//end class
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        return array(T_INLINE_THEN);
51
+        return array( T_INLINE_THEN );
52 52
 
53 53
     }//end register()
54 54
 
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return void
64 64
      */
65
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
66 66
     {
67
-        $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found');
67
+        $phpcsFile->addError( 'Inline IF statements are not allowed', $stackPtr, 'Found' );
68 68
 
69 69
     }//end process()
70 70
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @version   Release: @package_version@
28 28
  * @link      http://pear.php.net/package/PHP_CodeSniffer
29 29
  */
30
-class Squiz_Sniffs_PHP_DisallowInlineIfSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Squiz_Sniffs_PHP_DisallowInlineIfSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
     /**
34 33
      * A list of tokenizers this sniff supports.
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
      *
47 46
      * @return array
48 47
      */
49
-    public function register()
50
-    {
48
+    public function register() {
51 49
         return array(T_INLINE_THEN);
52 50
 
53 51
     }//end register()
@@ -62,8 +60,7 @@  discard block
 block discarded – undo
62 60
      *
63 61
      * @return void
64 62
      */
65
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
-    {
63
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
67 64
         $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found');
68 65
 
69 66
     }//end process()
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@
 block discarded – undo
31 31
 {
32 32
 
33 33
 
34
-    /**
35
-     * Returns an array of tokens this test wants to listen for.
36
-     *
37
-     * @return array
38
-     */
39
-    public function register()
40
-    {
41
-        return array(T_STRING);
34
+	 /**
35
+	  * Returns an array of tokens this test wants to listen for.
36
+	  *
37
+	  * @return array
38
+	  */
39
+	 public function register()
40
+	 {
41
+		  return array(T_STRING);
42 42
 
43
-    }//end register()
43
+	 }//end register()
44 44
 
45 45
 
46
-    /**
47
-     * Processes this test, when one of its tokens is encountered.
48
-     *
49
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
-     * @param int                  $stackPtr  The position of the current token in the
51
-     *                                        stack passed in $tokens.
52
-     *
53
-     * @return void
54
-     */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
-    {
57
-        $tokens = $phpcsFile->getTokens();
46
+	 /**
47
+	  * Processes this test, when one of its tokens is encountered.
48
+	  *
49
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+	  * @param int                  $stackPtr  The position of the current token in the
51
+	  *                                        stack passed in $tokens.
52
+	  *
53
+	  * @return void
54
+	  */
55
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+	 {
57
+		  $tokens = $phpcsFile->getTokens();
58 58
 
59
-        if ($tokens[$stackPtr]['content'] === 'ob_end_flush') {
60
-            $phpcsFile->addError('Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr, 'Found');
61
-        }
59
+		  if ($tokens[$stackPtr]['content'] === 'ob_end_flush') {
60
+				$phpcsFile->addError('Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr, 'Found');
61
+		  }
62 62
 
63
-    }//end process()
63
+	 }//end process()
64 64
 
65 65
 
66 66
 }//end class
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function register()
40 40
     {
41
-        return array(T_STRING);
41
+        return array( T_STRING );
42 42
 
43 43
     }//end register()
44 44
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
56 56
     {
57 57
         $tokens = $phpcsFile->getTokens();
58 58
 
59
-        if ($tokens[$stackPtr]['content'] === 'ob_end_flush') {
60
-            $phpcsFile->addError('Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr, 'Found');
59
+        if ( $tokens[ $stackPtr ][ 'content' ] === 'ob_end_flush' ) {
60
+            $phpcsFile->addError( 'Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr, 'Found' );
61 61
         }
62 62
 
63 63
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @version   Release: @package_version@
28 28
  * @link      http://pear.php.net/package/PHP_CodeSniffer
29 29
  */
30
-class Squiz_Sniffs_PHP_DisallowObEndFlushSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Squiz_Sniffs_PHP_DisallowObEndFlushSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
 
34 33
     /**
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
      *
37 36
      * @return array
38 37
      */
39
-    public function register()
40
-    {
38
+    public function register() {
41 39
         return array(T_STRING);
42 40
 
43 41
     }//end register()
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
      *
53 51
      * @return void
54 52
      */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
-    {
53
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
57 54
         $tokens = $phpcsFile->getTokens();
58 55
 
59 56
         if ($tokens[$stackPtr]['content'] === 'ob_end_flush') {
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) {
16
-    throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
16
+	 throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
17 17
 }
18 18
 
19 19
 /**
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
 class Squiz_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
33 33
 {
34 34
 
35
-    /**
36
-     * A list of forbidden functions with their alternatives.
37
-     *
38
-     * The value is NULL if no alternative exists. IE, the
39
-     * function should just not be used.
40
-     *
41
-     * @var array(string => string|null)
42
-     */
43
-    public $forbiddenFunctions = array(
44
-                                  'error_log' => null,
45
-                                  'print_r'   => null,
46
-                                  'var_dump'  => null,
47
-                                 );
35
+	 /**
36
+	  * A list of forbidden functions with their alternatives.
37
+	  *
38
+	  * The value is NULL if no alternative exists. IE, the
39
+	  * function should just not be used.
40
+	  *
41
+	  * @var array(string => string|null)
42
+	  */
43
+	 public $forbiddenFunctions = array(
44
+											 'error_log' => null,
45
+											 'print_r'   => null,
46
+											 'var_dump'  => null,
47
+											);
48 48
 
49
-    /**
50
-     * If true, an error will be thrown; otherwise a warning.
51
-     *
52
-     * @var bool
53
-     */
54
-    public $error = false;
49
+	 /**
50
+	  * If true, an error will be thrown; otherwise a warning.
51
+	  *
52
+	  * @var bool
53
+	  */
54
+	 public $error = false;
55 55
 
56 56
 }//end class
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
  * @link      http://pear.php.net/package/PHP_CodeSniffer
13 13
  */
14 14
 
15
-if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) {
16
-    throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
15
+if ( class_exists( 'Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true ) === false ) {
16
+    throw new PHP_CodeSniffer_Exception( 'Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found' );
17 17
 }
18 18
 
19 19
 /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
  * @version   Release: @package_version@
30 30
  * @link      http://pear.php.net/package/PHP_CodeSniffer
31 31
  */
32
-class Squiz_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
33
-{
32
+class Squiz_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff {
34 33
 
35 34
     /**
36 35
      * A list of forbidden functions with their alternatives.
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -29,44 +29,44 @@
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    /**
33
-     * Returns an array of tokens this test wants to listen for.
34
-     *
35
-     * @return array
36
-     */
37
-    public function register()
38
-    {
39
-        return PHP_CodeSniffer_Tokens::$booleanOperators;
32
+	 /**
33
+	  * Returns an array of tokens this test wants to listen for.
34
+	  *
35
+	  * @return array
36
+	  */
37
+	 public function register()
38
+	 {
39
+		  return PHP_CodeSniffer_Tokens::$booleanOperators;
40 40
 
41
-    }//end register()
41
+	 }//end register()
42 42
 
43 43
 
44
-    /**
45
-     * Processes this test, when one of its tokens is encountered.
46
-     *
47
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
-     * @param int                  $stackPtr  The position of the current token
49
-     *                                        in the stack passed in $tokens.
50
-     *
51
-     * @return void
52
-     */
53
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
-    {
55
-        $tokens = $phpcsFile->getTokens();
56
-        if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
57
-            $foundOwner = false;
58
-            foreach ($tokens[$stackPtr]['nested_parenthesis'] as $open => $close) {
59
-                if (isset($tokens[$open]['parenthesis_owner']) === true) {
60
-                    // Any owner means we are not just a simple statement.
61
-                    return;
62
-                }
63
-            }
64
-        }
44
+	 /**
45
+	  * Processes this test, when one of its tokens is encountered.
46
+	  *
47
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
+	  * @param int                  $stackPtr  The position of the current token
49
+	  *                                        in the stack passed in $tokens.
50
+	  *
51
+	  * @return void
52
+	  */
53
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
+	 {
55
+		  $tokens = $phpcsFile->getTokens();
56
+		  if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
57
+				$foundOwner = false;
58
+				foreach ($tokens[$stackPtr]['nested_parenthesis'] as $open => $close) {
59
+					 if (isset($tokens[$open]['parenthesis_owner']) === true) {
60
+						  // Any owner means we are not just a simple statement.
61
+						  return;
62
+					 }
63
+				}
64
+		  }
65 65
 
66
-        $error = 'Boolean operators are not allowed outside of control structure conditions';
67
-        $phpcsFile->addError($error, $stackPtr, 'Found');
66
+		  $error = 'Boolean operators are not allowed outside of control structure conditions';
67
+		  $phpcsFile->addError($error, $stackPtr, 'Found');
68 68
 
69
-    }//end process()
69
+	 }//end process()
70 70
 
71 71
 
72 72
 }//end class
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return void
52 52
      */
53
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
53
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
54 54
     {
55 55
         $tokens = $phpcsFile->getTokens();
56
-        if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
56
+        if ( isset( $tokens[ $stackPtr ][ 'nested_parenthesis' ] ) === true ) {
57 57
             $foundOwner = false;
58
-            foreach ($tokens[$stackPtr]['nested_parenthesis'] as $open => $close) {
59
-                if (isset($tokens[$open]['parenthesis_owner']) === true) {
58
+            foreach ( $tokens[ $stackPtr ][ 'nested_parenthesis' ] as $open => $close ) {
59
+                if ( isset( $tokens[ $open ][ 'parenthesis_owner' ] ) === true ) {
60 60
                     // Any owner means we are not just a simple statement.
61 61
                     return;
62 62
                 }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         $error = 'Boolean operators are not allowed outside of control structure conditions';
67
-        $phpcsFile->addError($error, $stackPtr, 'Found');
67
+        $phpcsFile->addError( $error, $stackPtr, 'Found' );
68 68
 
69 69
     }//end process()
70 70
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
  * @version   Release: @package_version@
26 26
  * @link      http://pear.php.net/package/PHP_CodeSniffer
27 27
  */
28
-class Squiz_Sniffs_PHP_DisallowBooleanStatementSniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Squiz_Sniffs_PHP_DisallowBooleanStatementSniff implements PHP_CodeSniffer_Sniff {
30 29
 
31 30
 
32 31
     /**
@@ -34,8 +33,7 @@  discard block
 block discarded – undo
34 33
      *
35 34
      * @return array
36 35
      */
37
-    public function register()
38
-    {
36
+    public function register() {
39 37
         return PHP_CodeSniffer_Tokens::$booleanOperators;
40 38
 
41 39
     }//end register()
@@ -50,8 +48,7 @@  discard block
 block discarded – undo
50 48
      *
51 49
      * @return void
52 50
      */
53
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
-    {
51
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
55 52
         $tokens = $phpcsFile->getTokens();
56 53
         if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
57 54
             $foundOwner = false;
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 
16 16
 if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
17
+	 throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
18 18
 }
19 19
 
20 20
 /**
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
 class Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
36 36
 {
37 37
 
38
-    /**
39
-     * A list of forbidden functions with their alternatives.
40
-     *
41
-     * The value is NULL if no alternative exists. IE, the
42
-     * function should just not be used.
43
-     *
44
-     * @var array(string => string|null)
45
-     */
46
-    public $forbiddenFunctions = array(
47
-                                  'sizeof'          => 'count',
48
-                                  'delete'          => 'unset',
49
-                                  'print'           => 'echo',
50
-                                  'is_null'         => null,
51
-                                  'create_function' => null,
52
-                                 );
38
+	 /**
39
+	  * A list of forbidden functions with their alternatives.
40
+	  *
41
+	  * The value is NULL if no alternative exists. IE, the
42
+	  * function should just not be used.
43
+	  *
44
+	  * @var array(string => string|null)
45
+	  */
46
+	 public $forbiddenFunctions = array(
47
+											 'sizeof'          => 'count',
48
+											 'delete'          => 'unset',
49
+											 'print'           => 'echo',
50
+											 'is_null'         => null,
51
+											 'create_function' => null,
52
+											);
53 53
 
54 54
 }//end class
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
  * @link      http://pear.php.net/package/PHP_CodeSniffer
14 14
  */
15 15
 
16
-if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
16
+if ( class_exists( 'Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true ) === false ) {
17
+    throw new PHP_CodeSniffer_Exception( 'Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found' );
18 18
 }
19 19
 
20 20
 /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@
 block discarded – undo
32 32
  * @version   Release: @package_version@
33 33
  * @link      http://pear.php.net/package/PHP_CodeSniffer
34 34
  */
35
-class Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
36
-{
35
+class Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff {
37 36
 
38 37
     /**
39 38
      * A list of forbidden functions with their alternatives.
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php 3 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -32,239 +32,239 @@
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * Returns an array of tokens this test wants to listen for.
37
-     *
38
-     * @return array
39
-     */
40
-    public function register()
41
-    {
42
-        return array(
43
-                T_BREAK,
44
-                T_CONTINUE,
45
-                T_RETURN,
46
-                T_THROW,
47
-                T_EXIT,
48
-               );
49
-
50
-    }//end register()
51
-
52
-
53
-    /**
54
-     * Processes this test, when one of its tokens is encountered.
55
-     *
56
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
-     * @param int                  $stackPtr  The position of the current token in
58
-     *                                        the stack passed in $tokens.
59
-     *
60
-     * @return void
61
-     */
62
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
-    {
64
-        $tokens = $phpcsFile->getTokens();
65
-
66
-        // If this token is preceded with an "or", it only relates to one line
67
-        // and should be ignored. For example: fopen() or die().
68
-        $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
69
-        if ($tokens[$prev]['code'] === T_LOGICAL_OR || $tokens[$prev]['code'] === T_BOOLEAN_OR) {
70
-            return;
71
-        }
72
-
73
-        // Check if this token is actually part of a one-line IF or ELSE statement.
74
-        for ($i = ($stackPtr - 1); $i > 0; $i--) {
75
-            if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
76
-                $i = $tokens[$i]['parenthesis_opener'];
77
-                continue;
78
-            } else if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
79
-                continue;
80
-            }
81
-
82
-            break;
83
-        }
84
-
85
-        if ($tokens[$i]['code'] === T_IF
86
-            || $tokens[$i]['code'] === T_ELSE
87
-            || $tokens[$i]['code'] === T_ELSEIF
88
-        ) {
89
-            return;
90
-        }
91
-
92
-        if ($tokens[$stackPtr]['code'] === T_RETURN) {
93
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
94
-            if ($tokens[$next]['code'] === T_SEMICOLON) {
95
-                $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
96
-                if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) {
97
-                    // If this is the closing brace of a function
98
-                    // then this return statement doesn't return anything
99
-                    // and is not required anyway.
100
-                    $owner = $tokens[$next]['scope_condition'];
101
-                    if ($tokens[$owner]['code'] === T_FUNCTION) {
102
-                        $warning = 'Empty return statement not required here';
103
-                        $phpcsFile->addWarning($warning, $stackPtr, 'ReturnNotRequired');
104
-                        return;
105
-                    }
106
-                }
107
-            }
108
-        }
109
-
110
-        if (isset($tokens[$stackPtr]['scope_opener']) === true) {
111
-            $owner = $tokens[$stackPtr]['scope_condition'];
112
-            if ($tokens[$owner]['code'] === T_CASE || $tokens[$owner]['code'] === T_DEFAULT) {
113
-                // This token closes the scope of a CASE or DEFAULT statement
114
-                // so any code between this statement and the next CASE, DEFAULT or
115
-                // end of SWITCH token will not be executable.
116
-                $end  = $phpcsFile->findEndOfStatement($stackPtr);
117
-                $next = $phpcsFile->findNext(
118
-                    array(
119
-                     T_CASE,
120
-                     T_DEFAULT,
121
-                     T_CLOSE_CURLY_BRACKET,
122
-                    ),
123
-                    ($end + 1)
124
-                );
125
-
126
-                if ($next !== false) {
127
-                    $lastLine = $tokens[$end]['line'];
128
-                    for ($i = ($stackPtr + 1); $i < $next; $i++) {
129
-                        if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
130
-                            continue;
131
-                        }
132
-
133
-                        $line = $tokens[$i]['line'];
134
-                        if ($line > $lastLine) {
135
-                            $type    = substr($tokens[$stackPtr]['type'], 2);
136
-                            $warning = 'Code after %s statement cannot be executed';
137
-                            $data    = array($type);
138
-                            $phpcsFile->addWarning($warning, $i, 'Unreachable', $data);
139
-                            $lastLine = $line;
140
-                        }
141
-                    }
142
-                }//end if
143
-
144
-                // That's all we have to check for these types of statements.
145
-                return;
146
-            }//end if
147
-        }//end if
148
-
149
-        // This token may be part of an inline condition.
150
-        // If we find a closing parenthesis that belongs to a condition
151
-        // we should ignore this token.
152
-        $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
153
-        if (isset($tokens[$prev]['parenthesis_owner']) === true) {
154
-            $owner  = $tokens[$prev]['parenthesis_owner'];
155
-            $ignore = array(
156
-                       T_IF     => true,
157
-                       T_ELSE   => true,
158
-                       T_ELSEIF => true,
159
-                      );
160
-            if (isset($ignore[$tokens[$owner]['code']]) === true) {
161
-                return;
162
-            }
163
-        }
164
-
165
-        $ourConditions = array_keys($tokens[$stackPtr]['conditions']);
166
-
167
-        if (empty($ourConditions) === false) {
168
-            $condition = array_pop($ourConditions);
169
-
170
-            if (isset($tokens[$condition]['scope_closer']) === false) {
171
-                return;
172
-            }
173
-
174
-            // Special case for BREAK statements sitting directly inside SWITCH
175
-            // statements. If we get to this point, we know the BREAK is not being
176
-            // used to close a CASE statement, so it is most likely non-executable
177
-            // code itself (as is the case when you put return; break; at the end of
178
-            // a case). So we need to ignore this token.
179
-            if ($tokens[$condition]['code'] === T_SWITCH
180
-                && $tokens[$stackPtr]['code'] === T_BREAK
181
-            ) {
182
-                return;
183
-            }
184
-
185
-            $closer = $tokens[$condition]['scope_closer'];
186
-
187
-            // If the closer for our condition is shared with other openers,
188
-            // we will need to throw errors from this token to the next
189
-            // shared opener (if there is one), not to the scope closer.
190
-            $nextOpener = null;
191
-            for ($i = ($stackPtr + 1); $i < $closer; $i++) {
192
-                if (isset($tokens[$i]['scope_closer']) === true) {
193
-                    if ($tokens[$i]['scope_closer'] === $closer) {
194
-                        // We found an opener that shares the same
195
-                        // closing token as us.
196
-                        $nextOpener = $i;
197
-                        break;
198
-                    }
199
-                }
200
-            }//end for
201
-
202
-            if ($nextOpener === null) {
203
-                $end = $closer;
204
-            } else {
205
-                $end = ($nextOpener - 1);
206
-            }
207
-        } else {
208
-            // This token is in the global scope.
209
-            if ($tokens[$stackPtr]['code'] === T_BREAK) {
210
-                return;
211
-            }
212
-
213
-            // Throw an error for all lines until the end of the file.
214
-            $end = ($phpcsFile->numTokens - 1);
215
-        }//end if
216
-
217
-        // Find the semicolon that ends this statement, skipping
218
-        // nested statements like FOR loops and closures.
219
-        for ($start = ($stackPtr + 1); $start < $phpcsFile->numTokens; $start++) {
220
-            if ($start === $end) {
221
-                break;
222
-            }
223
-
224
-            if ($tokens[$start]['code'] === T_OPEN_PARENTHESIS) {
225
-                $start = $tokens[$start]['parenthesis_closer'];
226
-                continue;
227
-            }
228
-
229
-            if ($tokens[$start]['code'] === T_OPEN_CURLY_BRACKET) {
230
-                $start = $tokens[$start]['bracket_closer'];
231
-                continue;
232
-            }
233
-
234
-            if ($tokens[$start]['code'] === T_SEMICOLON) {
235
-                break;
236
-            }
237
-        }//end for
238
-
239
-        $lastLine = $tokens[$start]['line'];
240
-        for ($i = ($start + 1); $i < $end; $i++) {
241
-            if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true
242
-                || isset(PHP_CodeSniffer_Tokens::$bracketTokens[$tokens[$i]['code']]) === true
243
-            ) {
244
-                continue;
245
-            }
246
-
247
-            // Skip whole functions and classes/interfaces because they are not
248
-            // technically executed code, but rather declarations that may be used.
249
-            if ($tokens[$i]['code'] === T_FUNCTION
250
-                || $tokens[$i]['code'] === T_CLASS
251
-                || $tokens[$i]['code'] === T_INTERFACE
252
-            ) {
253
-                $i = $tokens[$i]['scope_closer'];
254
-                continue;
255
-            }
256
-
257
-            $line = $tokens[$i]['line'];
258
-            if ($line > $lastLine) {
259
-                $type    = substr($tokens[$stackPtr]['type'], 2);
260
-                $warning = 'Code after %s statement cannot be executed';
261
-                $data    = array($type);
262
-                $phpcsFile->addWarning($warning, $i, 'Unreachable', $data);
263
-                $lastLine = $line;
264
-            }
265
-        }//end for
266
-
267
-    }//end process()
35
+	 /**
36
+	  * Returns an array of tokens this test wants to listen for.
37
+	  *
38
+	  * @return array
39
+	  */
40
+	 public function register()
41
+	 {
42
+		  return array(
43
+					 T_BREAK,
44
+					 T_CONTINUE,
45
+					 T_RETURN,
46
+					 T_THROW,
47
+					 T_EXIT,
48
+					);
49
+
50
+	 }//end register()
51
+
52
+
53
+	 /**
54
+	  * Processes this test, when one of its tokens is encountered.
55
+	  *
56
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+	  * @param int                  $stackPtr  The position of the current token in
58
+	  *                                        the stack passed in $tokens.
59
+	  *
60
+	  * @return void
61
+	  */
62
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
+	 {
64
+		  $tokens = $phpcsFile->getTokens();
65
+
66
+		  // If this token is preceded with an "or", it only relates to one line
67
+		  // and should be ignored. For example: fopen() or die().
68
+		  $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
69
+		  if ($tokens[$prev]['code'] === T_LOGICAL_OR || $tokens[$prev]['code'] === T_BOOLEAN_OR) {
70
+				return;
71
+		  }
72
+
73
+		  // Check if this token is actually part of a one-line IF or ELSE statement.
74
+		  for ($i = ($stackPtr - 1); $i > 0; $i--) {
75
+				if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
76
+					 $i = $tokens[$i]['parenthesis_opener'];
77
+					 continue;
78
+				} else if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
79
+					 continue;
80
+				}
81
+
82
+				break;
83
+		  }
84
+
85
+		  if ($tokens[$i]['code'] === T_IF
86
+				|| $tokens[$i]['code'] === T_ELSE
87
+				|| $tokens[$i]['code'] === T_ELSEIF
88
+		  ) {
89
+				return;
90
+		  }
91
+
92
+		  if ($tokens[$stackPtr]['code'] === T_RETURN) {
93
+				$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
94
+				if ($tokens[$next]['code'] === T_SEMICOLON) {
95
+					 $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
96
+					 if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) {
97
+						  // If this is the closing brace of a function
98
+						  // then this return statement doesn't return anything
99
+						  // and is not required anyway.
100
+						  $owner = $tokens[$next]['scope_condition'];
101
+						  if ($tokens[$owner]['code'] === T_FUNCTION) {
102
+								$warning = 'Empty return statement not required here';
103
+								$phpcsFile->addWarning($warning, $stackPtr, 'ReturnNotRequired');
104
+								return;
105
+						  }
106
+					 }
107
+				}
108
+		  }
109
+
110
+		  if (isset($tokens[$stackPtr]['scope_opener']) === true) {
111
+				$owner = $tokens[$stackPtr]['scope_condition'];
112
+				if ($tokens[$owner]['code'] === T_CASE || $tokens[$owner]['code'] === T_DEFAULT) {
113
+					 // This token closes the scope of a CASE or DEFAULT statement
114
+					 // so any code between this statement and the next CASE, DEFAULT or
115
+					 // end of SWITCH token will not be executable.
116
+					 $end  = $phpcsFile->findEndOfStatement($stackPtr);
117
+					 $next = $phpcsFile->findNext(
118
+						  array(
119
+							T_CASE,
120
+							T_DEFAULT,
121
+							T_CLOSE_CURLY_BRACKET,
122
+						  ),
123
+						  ($end + 1)
124
+					 );
125
+
126
+					 if ($next !== false) {
127
+						  $lastLine = $tokens[$end]['line'];
128
+						  for ($i = ($stackPtr + 1); $i < $next; $i++) {
129
+								if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
130
+									 continue;
131
+								}
132
+
133
+								$line = $tokens[$i]['line'];
134
+								if ($line > $lastLine) {
135
+									 $type    = substr($tokens[$stackPtr]['type'], 2);
136
+									 $warning = 'Code after %s statement cannot be executed';
137
+									 $data    = array($type);
138
+									 $phpcsFile->addWarning($warning, $i, 'Unreachable', $data);
139
+									 $lastLine = $line;
140
+								}
141
+						  }
142
+					 }//end if
143
+
144
+					 // That's all we have to check for these types of statements.
145
+					 return;
146
+				}//end if
147
+		  }//end if
148
+
149
+		  // This token may be part of an inline condition.
150
+		  // If we find a closing parenthesis that belongs to a condition
151
+		  // we should ignore this token.
152
+		  $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
153
+		  if (isset($tokens[$prev]['parenthesis_owner']) === true) {
154
+				$owner  = $tokens[$prev]['parenthesis_owner'];
155
+				$ignore = array(
156
+							  T_IF     => true,
157
+							  T_ELSE   => true,
158
+							  T_ELSEIF => true,
159
+							 );
160
+				if (isset($ignore[$tokens[$owner]['code']]) === true) {
161
+					 return;
162
+				}
163
+		  }
164
+
165
+		  $ourConditions = array_keys($tokens[$stackPtr]['conditions']);
166
+
167
+		  if (empty($ourConditions) === false) {
168
+				$condition = array_pop($ourConditions);
169
+
170
+				if (isset($tokens[$condition]['scope_closer']) === false) {
171
+					 return;
172
+				}
173
+
174
+				// Special case for BREAK statements sitting directly inside SWITCH
175
+				// statements. If we get to this point, we know the BREAK is not being
176
+				// used to close a CASE statement, so it is most likely non-executable
177
+				// code itself (as is the case when you put return; break; at the end of
178
+				// a case). So we need to ignore this token.
179
+				if ($tokens[$condition]['code'] === T_SWITCH
180
+					 && $tokens[$stackPtr]['code'] === T_BREAK
181
+				) {
182
+					 return;
183
+				}
184
+
185
+				$closer = $tokens[$condition]['scope_closer'];
186
+
187
+				// If the closer for our condition is shared with other openers,
188
+				// we will need to throw errors from this token to the next
189
+				// shared opener (if there is one), not to the scope closer.
190
+				$nextOpener = null;
191
+				for ($i = ($stackPtr + 1); $i < $closer; $i++) {
192
+					 if (isset($tokens[$i]['scope_closer']) === true) {
193
+						  if ($tokens[$i]['scope_closer'] === $closer) {
194
+								// We found an opener that shares the same
195
+								// closing token as us.
196
+								$nextOpener = $i;
197
+								break;
198
+						  }
199
+					 }
200
+				}//end for
201
+
202
+				if ($nextOpener === null) {
203
+					 $end = $closer;
204
+				} else {
205
+					 $end = ($nextOpener - 1);
206
+				}
207
+		  } else {
208
+				// This token is in the global scope.
209
+				if ($tokens[$stackPtr]['code'] === T_BREAK) {
210
+					 return;
211
+				}
212
+
213
+				// Throw an error for all lines until the end of the file.
214
+				$end = ($phpcsFile->numTokens - 1);
215
+		  }//end if
216
+
217
+		  // Find the semicolon that ends this statement, skipping
218
+		  // nested statements like FOR loops and closures.
219
+		  for ($start = ($stackPtr + 1); $start < $phpcsFile->numTokens; $start++) {
220
+				if ($start === $end) {
221
+					 break;
222
+				}
223
+
224
+				if ($tokens[$start]['code'] === T_OPEN_PARENTHESIS) {
225
+					 $start = $tokens[$start]['parenthesis_closer'];
226
+					 continue;
227
+				}
228
+
229
+				if ($tokens[$start]['code'] === T_OPEN_CURLY_BRACKET) {
230
+					 $start = $tokens[$start]['bracket_closer'];
231
+					 continue;
232
+				}
233
+
234
+				if ($tokens[$start]['code'] === T_SEMICOLON) {
235
+					 break;
236
+				}
237
+		  }//end for
238
+
239
+		  $lastLine = $tokens[$start]['line'];
240
+		  for ($i = ($start + 1); $i < $end; $i++) {
241
+				if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true
242
+					 || isset(PHP_CodeSniffer_Tokens::$bracketTokens[$tokens[$i]['code']]) === true
243
+				) {
244
+					 continue;
245
+				}
246
+
247
+				// Skip whole functions and classes/interfaces because they are not
248
+				// technically executed code, but rather declarations that may be used.
249
+				if ($tokens[$i]['code'] === T_FUNCTION
250
+					 || $tokens[$i]['code'] === T_CLASS
251
+					 || $tokens[$i]['code'] === T_INTERFACE
252
+				) {
253
+					 $i = $tokens[$i]['scope_closer'];
254
+					 continue;
255
+				}
256
+
257
+				$line = $tokens[$i]['line'];
258
+				if ($line > $lastLine) {
259
+					 $type    = substr($tokens[$stackPtr]['type'], 2);
260
+					 $warning = 'Code after %s statement cannot be executed';
261
+					 $data    = array($type);
262
+					 $phpcsFile->addWarning($warning, $i, 'Unreachable', $data);
263
+					 $lastLine = $line;
264
+				}
265
+		  }//end for
266
+
267
+	 }//end process()
268 268
 
269 269
 
270 270
 }//end class
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -59,83 +59,83 @@  discard block
 block discarded – undo
59 59
      *
60 60
      * @return void
61 61
      */
62
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
62
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
63 63
     {
64 64
         $tokens = $phpcsFile->getTokens();
65 65
 
66 66
         // If this token is preceded with an "or", it only relates to one line
67 67
         // and should be ignored. For example: fopen() or die().
68
-        $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
69
-        if ($tokens[$prev]['code'] === T_LOGICAL_OR || $tokens[$prev]['code'] === T_BOOLEAN_OR) {
68
+        $prev = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
69
+        if ( $tokens[ $prev ][ 'code' ] === T_LOGICAL_OR || $tokens[ $prev ][ 'code' ] === T_BOOLEAN_OR ) {
70 70
             return;
71 71
         }
72 72
 
73 73
         // Check if this token is actually part of a one-line IF or ELSE statement.
74
-        for ($i = ($stackPtr - 1); $i > 0; $i--) {
75
-            if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
76
-                $i = $tokens[$i]['parenthesis_opener'];
74
+        for ( $i = ( $stackPtr - 1 ); $i > 0; $i-- ) {
75
+            if ( $tokens[ $i ][ 'code' ] === T_CLOSE_PARENTHESIS ) {
76
+                $i = $tokens[ $i ][ 'parenthesis_opener' ];
77 77
                 continue;
78
-            } else if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
78
+            } else if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === true ) {
79 79
                 continue;
80 80
             }
81 81
 
82 82
             break;
83 83
         }
84 84
 
85
-        if ($tokens[$i]['code'] === T_IF
86
-            || $tokens[$i]['code'] === T_ELSE
87
-            || $tokens[$i]['code'] === T_ELSEIF
85
+        if ( $tokens[ $i ][ 'code' ] === T_IF
86
+            || $tokens[ $i ][ 'code' ] === T_ELSE
87
+            || $tokens[ $i ][ 'code' ] === T_ELSEIF
88 88
         ) {
89 89
             return;
90 90
         }
91 91
 
92
-        if ($tokens[$stackPtr]['code'] === T_RETURN) {
93
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
94
-            if ($tokens[$next]['code'] === T_SEMICOLON) {
95
-                $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
96
-                if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) {
92
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_RETURN ) {
93
+            $next = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
94
+            if ( $tokens[ $next ][ 'code' ] === T_SEMICOLON ) {
95
+                $next = $phpcsFile->findNext( T_WHITESPACE, ( $next + 1 ), null, true );
96
+                if ( $tokens[ $next ][ 'code' ] === T_CLOSE_CURLY_BRACKET ) {
97 97
                     // If this is the closing brace of a function
98 98
                     // then this return statement doesn't return anything
99 99
                     // and is not required anyway.
100
-                    $owner = $tokens[$next]['scope_condition'];
101
-                    if ($tokens[$owner]['code'] === T_FUNCTION) {
100
+                    $owner = $tokens[ $next ][ 'scope_condition' ];
101
+                    if ( $tokens[ $owner ][ 'code' ] === T_FUNCTION ) {
102 102
                         $warning = 'Empty return statement not required here';
103
-                        $phpcsFile->addWarning($warning, $stackPtr, 'ReturnNotRequired');
103
+                        $phpcsFile->addWarning( $warning, $stackPtr, 'ReturnNotRequired' );
104 104
                         return;
105 105
                     }
106 106
                 }
107 107
             }
108 108
         }
109 109
 
110
-        if (isset($tokens[$stackPtr]['scope_opener']) === true) {
111
-            $owner = $tokens[$stackPtr]['scope_condition'];
112
-            if ($tokens[$owner]['code'] === T_CASE || $tokens[$owner]['code'] === T_DEFAULT) {
110
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === true ) {
111
+            $owner = $tokens[ $stackPtr ][ 'scope_condition' ];
112
+            if ( $tokens[ $owner ][ 'code' ] === T_CASE || $tokens[ $owner ][ 'code' ] === T_DEFAULT ) {
113 113
                 // This token closes the scope of a CASE or DEFAULT statement
114 114
                 // so any code between this statement and the next CASE, DEFAULT or
115 115
                 // end of SWITCH token will not be executable.
116
-                $end  = $phpcsFile->findEndOfStatement($stackPtr);
116
+                $end  = $phpcsFile->findEndOfStatement( $stackPtr );
117 117
                 $next = $phpcsFile->findNext(
118 118
                     array(
119 119
                      T_CASE,
120 120
                      T_DEFAULT,
121 121
                      T_CLOSE_CURLY_BRACKET,
122 122
                     ),
123
-                    ($end + 1)
123
+                    ( $end + 1 )
124 124
                 );
125 125
 
126
-                if ($next !== false) {
127
-                    $lastLine = $tokens[$end]['line'];
128
-                    for ($i = ($stackPtr + 1); $i < $next; $i++) {
129
-                        if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
126
+                if ( $next !== false ) {
127
+                    $lastLine = $tokens[ $end ][ 'line' ];
128
+                    for ( $i = ( $stackPtr + 1 ); $i < $next; $i++ ) {
129
+                        if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === true ) {
130 130
                             continue;
131 131
                         }
132 132
 
133
-                        $line = $tokens[$i]['line'];
134
-                        if ($line > $lastLine) {
135
-                            $type    = substr($tokens[$stackPtr]['type'], 2);
133
+                        $line = $tokens[ $i ][ 'line' ];
134
+                        if ( $line > $lastLine ) {
135
+                            $type    = substr( $tokens[ $stackPtr ][ 'type' ], 2 );
136 136
                             $warning = 'Code after %s statement cannot be executed';
137
-                            $data    = array($type);
138
-                            $phpcsFile->addWarning($warning, $i, 'Unreachable', $data);
137
+                            $data    = array( $type );
138
+                            $phpcsFile->addWarning( $warning, $i, 'Unreachable', $data );
139 139
                             $lastLine = $line;
140 140
                         }
141 141
                     }
@@ -149,25 +149,25 @@  discard block
 block discarded – undo
149 149
         // This token may be part of an inline condition.
150 150
         // If we find a closing parenthesis that belongs to a condition
151 151
         // we should ignore this token.
152
-        $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
153
-        if (isset($tokens[$prev]['parenthesis_owner']) === true) {
154
-            $owner  = $tokens[$prev]['parenthesis_owner'];
152
+        $prev = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
153
+        if ( isset( $tokens[ $prev ][ 'parenthesis_owner' ] ) === true ) {
154
+            $owner  = $tokens[ $prev ][ 'parenthesis_owner' ];
155 155
             $ignore = array(
156 156
                        T_IF     => true,
157 157
                        T_ELSE   => true,
158 158
                        T_ELSEIF => true,
159 159
                       );
160
-            if (isset($ignore[$tokens[$owner]['code']]) === true) {
160
+            if ( isset( $ignore[ $tokens[ $owner ][ 'code' ] ] ) === true ) {
161 161
                 return;
162 162
             }
163 163
         }
164 164
 
165
-        $ourConditions = array_keys($tokens[$stackPtr]['conditions']);
165
+        $ourConditions = array_keys( $tokens[ $stackPtr ][ 'conditions' ] );
166 166
 
167
-        if (empty($ourConditions) === false) {
168
-            $condition = array_pop($ourConditions);
167
+        if ( empty( $ourConditions ) === false ) {
168
+            $condition = array_pop( $ourConditions );
169 169
 
170
-            if (isset($tokens[$condition]['scope_closer']) === false) {
170
+            if ( isset( $tokens[ $condition ][ 'scope_closer' ] ) === false ) {
171 171
                 return;
172 172
             }
173 173
 
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
             // used to close a CASE statement, so it is most likely non-executable
177 177
             // code itself (as is the case when you put return; break; at the end of
178 178
             // a case). So we need to ignore this token.
179
-            if ($tokens[$condition]['code'] === T_SWITCH
180
-                && $tokens[$stackPtr]['code'] === T_BREAK
179
+            if ( $tokens[ $condition ][ 'code' ] === T_SWITCH
180
+                && $tokens[ $stackPtr ][ 'code' ] === T_BREAK
181 181
             ) {
182 182
                 return;
183 183
             }
184 184
 
185
-            $closer = $tokens[$condition]['scope_closer'];
185
+            $closer = $tokens[ $condition ][ 'scope_closer' ];
186 186
 
187 187
             // If the closer for our condition is shared with other openers,
188 188
             // we will need to throw errors from this token to the next
189 189
             // shared opener (if there is one), not to the scope closer.
190 190
             $nextOpener = null;
191
-            for ($i = ($stackPtr + 1); $i < $closer; $i++) {
192
-                if (isset($tokens[$i]['scope_closer']) === true) {
193
-                    if ($tokens[$i]['scope_closer'] === $closer) {
191
+            for ( $i = ( $stackPtr + 1 ); $i < $closer; $i++ ) {
192
+                if ( isset( $tokens[ $i ][ 'scope_closer' ] ) === true ) {
193
+                    if ( $tokens[ $i ][ 'scope_closer' ] === $closer ) {
194 194
                         // We found an opener that shares the same
195 195
                         // closing token as us.
196 196
                         $nextOpener = $i;
@@ -199,67 +199,67 @@  discard block
 block discarded – undo
199 199
                 }
200 200
             }//end for
201 201
 
202
-            if ($nextOpener === null) {
202
+            if ( $nextOpener === null ) {
203 203
                 $end = $closer;
204 204
             } else {
205
-                $end = ($nextOpener - 1);
205
+                $end = ( $nextOpener - 1 );
206 206
             }
207 207
         } else {
208 208
             // This token is in the global scope.
209
-            if ($tokens[$stackPtr]['code'] === T_BREAK) {
209
+            if ( $tokens[ $stackPtr ][ 'code' ] === T_BREAK ) {
210 210
                 return;
211 211
             }
212 212
 
213 213
             // Throw an error for all lines until the end of the file.
214
-            $end = ($phpcsFile->numTokens - 1);
214
+            $end = ( $phpcsFile->numTokens - 1 );
215 215
         }//end if
216 216
 
217 217
         // Find the semicolon that ends this statement, skipping
218 218
         // nested statements like FOR loops and closures.
219
-        for ($start = ($stackPtr + 1); $start < $phpcsFile->numTokens; $start++) {
220
-            if ($start === $end) {
219
+        for ( $start = ( $stackPtr + 1 ); $start < $phpcsFile->numTokens; $start++ ) {
220
+            if ( $start === $end ) {
221 221
                 break;
222 222
             }
223 223
 
224
-            if ($tokens[$start]['code'] === T_OPEN_PARENTHESIS) {
225
-                $start = $tokens[$start]['parenthesis_closer'];
224
+            if ( $tokens[ $start ][ 'code' ] === T_OPEN_PARENTHESIS ) {
225
+                $start = $tokens[ $start ][ 'parenthesis_closer' ];
226 226
                 continue;
227 227
             }
228 228
 
229
-            if ($tokens[$start]['code'] === T_OPEN_CURLY_BRACKET) {
230
-                $start = $tokens[$start]['bracket_closer'];
229
+            if ( $tokens[ $start ][ 'code' ] === T_OPEN_CURLY_BRACKET ) {
230
+                $start = $tokens[ $start ][ 'bracket_closer' ];
231 231
                 continue;
232 232
             }
233 233
 
234
-            if ($tokens[$start]['code'] === T_SEMICOLON) {
234
+            if ( $tokens[ $start ][ 'code' ] === T_SEMICOLON ) {
235 235
                 break;
236 236
             }
237 237
         }//end for
238 238
 
239
-        $lastLine = $tokens[$start]['line'];
240
-        for ($i = ($start + 1); $i < $end; $i++) {
241
-            if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === true
242
-                || isset(PHP_CodeSniffer_Tokens::$bracketTokens[$tokens[$i]['code']]) === true
239
+        $lastLine = $tokens[ $start ][ 'line' ];
240
+        for ( $i = ( $start + 1 ); $i < $end; $i++ ) {
241
+            if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === true
242
+                || isset( PHP_CodeSniffer_Tokens::$bracketTokens[ $tokens[ $i ][ 'code' ] ] ) === true
243 243
             ) {
244 244
                 continue;
245 245
             }
246 246
 
247 247
             // Skip whole functions and classes/interfaces because they are not
248 248
             // technically executed code, but rather declarations that may be used.
249
-            if ($tokens[$i]['code'] === T_FUNCTION
250
-                || $tokens[$i]['code'] === T_CLASS
251
-                || $tokens[$i]['code'] === T_INTERFACE
249
+            if ( $tokens[ $i ][ 'code' ] === T_FUNCTION
250
+                || $tokens[ $i ][ 'code' ] === T_CLASS
251
+                || $tokens[ $i ][ 'code' ] === T_INTERFACE
252 252
             ) {
253
-                $i = $tokens[$i]['scope_closer'];
253
+                $i = $tokens[ $i ][ 'scope_closer' ];
254 254
                 continue;
255 255
             }
256 256
 
257
-            $line = $tokens[$i]['line'];
258
-            if ($line > $lastLine) {
259
-                $type    = substr($tokens[$stackPtr]['type'], 2);
257
+            $line = $tokens[ $i ][ 'line' ];
258
+            if ( $line > $lastLine ) {
259
+                $type    = substr( $tokens[ $stackPtr ][ 'type' ], 2 );
260 260
                 $warning = 'Code after %s statement cannot be executed';
261
-                $data    = array($type);
262
-                $phpcsFile->addWarning($warning, $i, 'Unreachable', $data);
261
+                $data    = array( $type );
262
+                $phpcsFile->addWarning( $warning, $i, 'Unreachable', $data );
263 263
                 $lastLine = $line;
264 264
             }
265 265
         }//end for
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
  * @version   Release: @package_version@
29 29
  * @link      http://pear.php.net/package/PHP_CodeSniffer
30 30
  */
31
-class Squiz_Sniffs_PHP_NonExecutableCodeSniff implements PHP_CodeSniffer_Sniff
32
-{
31
+class Squiz_Sniffs_PHP_NonExecutableCodeSniff implements PHP_CodeSniffer_Sniff {
33 32
 
34 33
 
35 34
     /**
@@ -37,8 +36,7 @@  discard block
 block discarded – undo
37 36
      *
38 37
      * @return array
39 38
      */
40
-    public function register()
41
-    {
39
+    public function register() {
42 40
         return array(
43 41
                 T_BREAK,
44 42
                 T_CONTINUE,
@@ -59,8 +57,7 @@  discard block
 block discarded – undo
59 57
      *
60 58
      * @return void
61 59
      */
62
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
-    {
60
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
64 61
         $tokens = $phpcsFile->getTokens();
65 62
 
66 63
         // If this token is preceded with an "or", it only relates to one line
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,38 +31,38 @@
 block discarded – undo
31 31
 {
32 32
 
33 33
 
34
-    /**
35
-     * Returns an array of tokens this test wants to listen for.
36
-     *
37
-     * @return array
38
-     */
39
-    public function register()
40
-    {
41
-        return array(T_GLOBAL);
34
+	 /**
35
+	  * Returns an array of tokens this test wants to listen for.
36
+	  *
37
+	  * @return array
38
+	  */
39
+	 public function register()
40
+	 {
41
+		  return array(T_GLOBAL);
42 42
 
43
-    }//end register()
43
+	 }//end register()
44 44
 
45 45
 
46
-    /**
47
-     * Processes this test, when one of its tokens is encountered.
48
-     *
49
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
-     * @param int                  $stackPtr  The position of the current token in the
51
-     *                                        stack passed in $tokens.
52
-     *
53
-     * @return void
54
-     */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
-    {
57
-        $tokens = $phpcsFile->getTokens();
46
+	 /**
47
+	  * Processes this test, when one of its tokens is encountered.
48
+	  *
49
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+	  * @param int                  $stackPtr  The position of the current token in the
51
+	  *                                        stack passed in $tokens.
52
+	  *
53
+	  * @return void
54
+	  */
55
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+	 {
57
+		  $tokens = $phpcsFile->getTokens();
58 58
 
59
-        $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)];
60
-        $varName = str_replace('$', '', $nextVar['content']);
61
-        $error   = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead';
62
-        $data    = array($varName);
63
-        $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data);
59
+		  $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)];
60
+		  $varName = str_replace('$', '', $nextVar['content']);
61
+		  $error   = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead';
62
+		  $data    = array($varName);
63
+		  $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data);
64 64
 
65
-    }//end process()
65
+	 }//end process()
66 66
 
67 67
 
68 68
 }//end class
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function register()
40 40
     {
41
-        return array(T_GLOBAL);
41
+        return array( T_GLOBAL );
42 42
 
43 43
     }//end register()
44 44
 
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
56 56
     {
57 57
         $tokens = $phpcsFile->getTokens();
58 58
 
59
-        $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)];
60
-        $varName = str_replace('$', '', $nextVar['content']);
59
+        $nextVar = $tokens[ $phpcsFile->findNext( array( T_VARIABLE ), $stackPtr ) ];
60
+        $varName = str_replace( '$', '', $nextVar[ 'content' ] );
61 61
         $error   = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead';
62
-        $data    = array($varName);
63
-        $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data);
62
+        $data    = array( $varName );
63
+        $phpcsFile->addError( $error, $stackPtr, 'NotAllowed', $data );
64 64
 
65 65
     }//end process()
66 66
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @version   Release: @package_version@
28 28
  * @link      http://pear.php.net/package/PHP_CodeSniffer
29 29
  */
30
-class Squiz_Sniffs_PHP_GlobalKeywordSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Squiz_Sniffs_PHP_GlobalKeywordSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
 
34 33
     /**
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
      *
37 36
      * @return array
38 37
      */
39
-    public function register()
40
-    {
38
+    public function register() {
41 39
         return array(T_GLOBAL);
42 40
 
43 41
     }//end register()
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
      *
53 51
      * @return void
54 52
      */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
-    {
53
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
57 54
         $tokens = $phpcsFile->getTokens();
58 55
 
59 56
         $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)];
Please login to merge, or discard this patch.
php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,33 +31,33 @@
 block discarded – undo
31 31
 {
32 32
 
33 33
 
34
-    /**
35
-     * Returns an array of tokens this test wants to listen for.
36
-     *
37
-     * @return array
38
-     */
39
-    public function register()
40
-    {
41
-        return array(T_EVAL);
42
-
43
-    }//end register()
44
-
45
-
46
-    /**
47
-     * Processes this test, when one of its tokens is encountered.
48
-     *
49
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
-     * @param int                  $stackPtr  The position of the current token in
51
-     *                                        the stack passed in $tokens.
52
-     *
53
-     * @return void
54
-     */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
-    {
57
-        $error = 'Use of eval() is discouraged';
58
-        $phpcsFile->addWarning($error, $stackPtr, 'Discouraged');
59
-
60
-    }//end process()
34
+	 /**
35
+	  * Returns an array of tokens this test wants to listen for.
36
+	  *
37
+	  * @return array
38
+	  */
39
+	 public function register()
40
+	 {
41
+		  return array(T_EVAL);
42
+
43
+	 }//end register()
44
+
45
+
46
+	 /**
47
+	  * Processes this test, when one of its tokens is encountered.
48
+	  *
49
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+	  * @param int                  $stackPtr  The position of the current token in
51
+	  *                                        the stack passed in $tokens.
52
+	  *
53
+	  * @return void
54
+	  */
55
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+	 {
57
+		  $error = 'Use of eval() is discouraged';
58
+		  $phpcsFile->addWarning($error, $stackPtr, 'Discouraged');
59
+
60
+	 }//end process()
61 61
 
62 62
 
63 63
 }//end class
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function register()
40 40
     {
41
-        return array(T_EVAL);
41
+        return array( T_EVAL );
42 42
 
43 43
     }//end register()
44 44
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
56 56
     {
57 57
         $error = 'Use of eval() is discouraged';
58
-        $phpcsFile->addWarning($error, $stackPtr, 'Discouraged');
58
+        $phpcsFile->addWarning( $error, $stackPtr, 'Discouraged' );
59 59
 
60 60
     }//end process()
61 61
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @version   Release: @package_version@
28 28
  * @link      http://pear.php.net/package/PHP_CodeSniffer
29 29
  */
30
-class Squiz_Sniffs_PHP_EvalSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Squiz_Sniffs_PHP_EvalSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
 
34 33
     /**
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
      *
37 36
      * @return array
38 37
      */
39
-    public function register()
40
-    {
38
+    public function register() {
41 39
         return array(T_EVAL);
42 40
 
43 41
     }//end register()
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
      *
53 51
      * @return void
54 52
      */
55
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
-    {
53
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
57 54
         $error = 'Use of eval() is discouraged';
58 55
         $phpcsFile->addWarning($error, $stackPtr, 'Discouraged');
59 56
 
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php 3 patches
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * Returns an array of tokens this test wants to listen for.
37
-     *
38
-     * @return array
39
-     */
40
-    public function register()
41
-    {
42
-        return array(T_EQUAL);
43
-
44
-    }//end register()
45
-
46
-
47
-    /**
48
-     * Processes this test, when one of its tokens is encountered.
49
-     *
50
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
-     * @param int                  $stackPtr  The position of the current token in the
52
-     *                                        stack passed in $tokens.
53
-     *
54
-     * @return void
55
-     */
56
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
57
-    {
58
-        $tokens = $phpcsFile->getTokens();
59
-
60
-        // Ignore default value assignments in function definitions.
61
-        $function = $phpcsFile->findPrevious(array(T_FUNCTION, T_CLOSURE), ($stackPtr - 1), null, false, null, true);
62
-        if ($function !== false) {
63
-            $opener = $tokens[$function]['parenthesis_opener'];
64
-            $closer = $tokens[$function]['parenthesis_closer'];
65
-            if ($opener < $stackPtr && $closer > $stackPtr) {
66
-                return;
67
-            }
68
-        }
69
-
70
-        /*
35
+	 /**
36
+	  * Returns an array of tokens this test wants to listen for.
37
+	  *
38
+	  * @return array
39
+	  */
40
+	 public function register()
41
+	 {
42
+		  return array(T_EQUAL);
43
+
44
+	 }//end register()
45
+
46
+
47
+	 /**
48
+	  * Processes this test, when one of its tokens is encountered.
49
+	  *
50
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
+	  * @param int                  $stackPtr  The position of the current token in the
52
+	  *                                        stack passed in $tokens.
53
+	  *
54
+	  * @return void
55
+	  */
56
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
57
+	 {
58
+		  $tokens = $phpcsFile->getTokens();
59
+
60
+		  // Ignore default value assignments in function definitions.
61
+		  $function = $phpcsFile->findPrevious(array(T_FUNCTION, T_CLOSURE), ($stackPtr - 1), null, false, null, true);
62
+		  if ($function !== false) {
63
+				$opener = $tokens[$function]['parenthesis_opener'];
64
+				$closer = $tokens[$function]['parenthesis_closer'];
65
+				if ($opener < $stackPtr && $closer > $stackPtr) {
66
+					 return;
67
+				}
68
+		  }
69
+
70
+		  /*
71 71
             The general rule is:
72 72
             Find an equal sign and go backwards along the line. If you hit an
73 73
             end bracket, skip to the opening bracket. When you find a variable,
@@ -75,104 +75,104 @@  discard block
 block discarded – undo
75 75
             or in the statement. If not, throw an error.
76 76
         */
77 77
 
78
-        for ($varToken = ($stackPtr - 1); $varToken >= 0; $varToken--) {
79
-            // Skip brackets.
80
-            if (isset($tokens[$varToken]['parenthesis_opener']) === true && $tokens[$varToken]['parenthesis_opener'] < $varToken) {
81
-                $varToken = $tokens[$varToken]['parenthesis_opener'];
82
-                continue;
83
-            }
84
-
85
-            if (isset($tokens[$varToken]['bracket_opener']) === true) {
86
-                $varToken = $tokens[$varToken]['bracket_opener'];
87
-                continue;
88
-            }
89
-
90
-            if ($tokens[$varToken]['code'] === T_SEMICOLON) {
91
-                // We've reached the next statement, so we
92
-                // didn't find a variable.
93
-                return;
94
-            }
95
-
96
-            if ($tokens[$varToken]['code'] === T_VARIABLE) {
97
-                // We found our variable.
98
-                break;
99
-            }
100
-        }//end for
101
-
102
-        if ($varToken <= 0) {
103
-            // Didn't find a variable.
104
-            return;
105
-        }
106
-
107
-        // Deal with this type of variable: self::$var by setting the var
108
-        // token to be "self" rather than "$var".
109
-        if ($tokens[($varToken - 1)]['code'] === T_DOUBLE_COLON) {
110
-            $varToken = ($varToken - 2);
111
-        }
112
-
113
-        // Deal with this type of variable: $obj->$var by setting the var
114
-        // token to be "$obj" rather than "$var".
115
-        if ($tokens[($varToken - 1)]['code'] === T_OBJECT_OPERATOR) {
116
-            $varToken = ($varToken - 2);
117
-        }
118
-
119
-        // Deal with this type of variable: $$var by setting the var
120
-        // token to be "$" rather than "$var".
121
-        if ($tokens[($varToken - 1)]['content'] === '$') {
122
-            $varToken--;
123
-        }
124
-
125
-        // Ignore member var definitions.
126
-        $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($varToken - 1), null, true);
127
-        if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$prev]['code']]) === true) {
128
-            return;
129
-        }
130
-
131
-        if ($tokens[$prev]['code'] === T_STATIC) {
132
-            return;
133
-        }
134
-
135
-        // Make sure this variable is the first thing in the statement.
136
-        $varLine  = $tokens[$varToken]['line'];
137
-        $prevLine = 0;
138
-        for ($i = ($varToken - 1); $i >= 0; $i--) {
139
-            if ($tokens[$i]['code'] === T_SEMICOLON) {
140
-                // We reached the end of the statement.
141
-                return;
142
-            }
143
-
144
-            if ($tokens[$i]['code'] === T_INLINE_THEN) {
145
-                // We reached the end of the inline THEN statement.
146
-                return;
147
-            }
148
-
149
-            if ($tokens[$i]['code'] === T_INLINE_ELSE) {
150
-                // We reached the end of the inline ELSE statement.
151
-                return;
152
-            }
153
-
154
-            if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
155
-                $prevLine = $tokens[$i]['line'];
156
-                break;
157
-            }
158
-        }//end for
159
-
160
-        // Ignore the first part of FOR loops as we are allowed to
161
-        // assign variables there even though the variable is not the
162
-        // first thing on the line. Also ignore WHILE loops.
163
-        if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_owner']) === true) {
164
-            $owner = $tokens[$i]['parenthesis_owner'];
165
-            if ($tokens[$owner]['code'] === T_FOR || $tokens[$owner]['code'] === T_WHILE) {
166
-                return;
167
-            }
168
-        }
169
-
170
-        if ($prevLine === $varLine) {
171
-            $error = 'Assignments must be the first block of code on a line';
172
-            $phpcsFile->addError($error, $stackPtr, 'Found');
173
-        }
174
-
175
-    }//end process()
78
+		  for ($varToken = ($stackPtr - 1); $varToken >= 0; $varToken--) {
79
+				// Skip brackets.
80
+				if (isset($tokens[$varToken]['parenthesis_opener']) === true && $tokens[$varToken]['parenthesis_opener'] < $varToken) {
81
+					 $varToken = $tokens[$varToken]['parenthesis_opener'];
82
+					 continue;
83
+				}
84
+
85
+				if (isset($tokens[$varToken]['bracket_opener']) === true) {
86
+					 $varToken = $tokens[$varToken]['bracket_opener'];
87
+					 continue;
88
+				}
89
+
90
+				if ($tokens[$varToken]['code'] === T_SEMICOLON) {
91
+					 // We've reached the next statement, so we
92
+					 // didn't find a variable.
93
+					 return;
94
+				}
95
+
96
+				if ($tokens[$varToken]['code'] === T_VARIABLE) {
97
+					 // We found our variable.
98
+					 break;
99
+				}
100
+		  }//end for
101
+
102
+		  if ($varToken <= 0) {
103
+				// Didn't find a variable.
104
+				return;
105
+		  }
106
+
107
+		  // Deal with this type of variable: self::$var by setting the var
108
+		  // token to be "self" rather than "$var".
109
+		  if ($tokens[($varToken - 1)]['code'] === T_DOUBLE_COLON) {
110
+				$varToken = ($varToken - 2);
111
+		  }
112
+
113
+		  // Deal with this type of variable: $obj->$var by setting the var
114
+		  // token to be "$obj" rather than "$var".
115
+		  if ($tokens[($varToken - 1)]['code'] === T_OBJECT_OPERATOR) {
116
+				$varToken = ($varToken - 2);
117
+		  }
118
+
119
+		  // Deal with this type of variable: $$var by setting the var
120
+		  // token to be "$" rather than "$var".
121
+		  if ($tokens[($varToken - 1)]['content'] === '$') {
122
+				$varToken--;
123
+		  }
124
+
125
+		  // Ignore member var definitions.
126
+		  $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($varToken - 1), null, true);
127
+		  if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$prev]['code']]) === true) {
128
+				return;
129
+		  }
130
+
131
+		  if ($tokens[$prev]['code'] === T_STATIC) {
132
+				return;
133
+		  }
134
+
135
+		  // Make sure this variable is the first thing in the statement.
136
+		  $varLine  = $tokens[$varToken]['line'];
137
+		  $prevLine = 0;
138
+		  for ($i = ($varToken - 1); $i >= 0; $i--) {
139
+				if ($tokens[$i]['code'] === T_SEMICOLON) {
140
+					 // We reached the end of the statement.
141
+					 return;
142
+				}
143
+
144
+				if ($tokens[$i]['code'] === T_INLINE_THEN) {
145
+					 // We reached the end of the inline THEN statement.
146
+					 return;
147
+				}
148
+
149
+				if ($tokens[$i]['code'] === T_INLINE_ELSE) {
150
+					 // We reached the end of the inline ELSE statement.
151
+					 return;
152
+				}
153
+
154
+				if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
155
+					 $prevLine = $tokens[$i]['line'];
156
+					 break;
157
+				}
158
+		  }//end for
159
+
160
+		  // Ignore the first part of FOR loops as we are allowed to
161
+		  // assign variables there even though the variable is not the
162
+		  // first thing on the line. Also ignore WHILE loops.
163
+		  if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_owner']) === true) {
164
+				$owner = $tokens[$i]['parenthesis_owner'];
165
+				if ($tokens[$owner]['code'] === T_FOR || $tokens[$owner]['code'] === T_WHILE) {
166
+					 return;
167
+				}
168
+		  }
169
+
170
+		  if ($prevLine === $varLine) {
171
+				$error = 'Assignments must be the first block of code on a line';
172
+				$phpcsFile->addError($error, $stackPtr, 'Found');
173
+		  }
174
+
175
+	 }//end process()
176 176
 
177 177
 
178 178
 }//end class
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function register()
41 41
     {
42
-        return array(T_EQUAL);
42
+        return array( T_EQUAL );
43 43
 
44 44
     }//end register()
45 45
 
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return void
55 55
      */
56
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
57 57
     {
58 58
         $tokens = $phpcsFile->getTokens();
59 59
 
60 60
         // Ignore default value assignments in function definitions.
61
-        $function = $phpcsFile->findPrevious(array(T_FUNCTION, T_CLOSURE), ($stackPtr - 1), null, false, null, true);
62
-        if ($function !== false) {
63
-            $opener = $tokens[$function]['parenthesis_opener'];
64
-            $closer = $tokens[$function]['parenthesis_closer'];
65
-            if ($opener < $stackPtr && $closer > $stackPtr) {
61
+        $function = $phpcsFile->findPrevious( array( T_FUNCTION, T_CLOSURE ), ( $stackPtr - 1 ), null, false, null, true );
62
+        if ( $function !== false ) {
63
+            $opener = $tokens[ $function ][ 'parenthesis_opener' ];
64
+            $closer = $tokens[ $function ][ 'parenthesis_closer' ];
65
+            if ( $opener < $stackPtr && $closer > $stackPtr ) {
66 66
                 return;
67 67
             }
68 68
         }
@@ -75,84 +75,84 @@  discard block
 block discarded – undo
75 75
             or in the statement. If not, throw an error.
76 76
         */
77 77
 
78
-        for ($varToken = ($stackPtr - 1); $varToken >= 0; $varToken--) {
78
+        for ( $varToken = ( $stackPtr - 1 ); $varToken >= 0; $varToken-- ) {
79 79
             // Skip brackets.
80
-            if (isset($tokens[$varToken]['parenthesis_opener']) === true && $tokens[$varToken]['parenthesis_opener'] < $varToken) {
81
-                $varToken = $tokens[$varToken]['parenthesis_opener'];
80
+            if ( isset( $tokens[ $varToken ][ 'parenthesis_opener' ] ) === true && $tokens[ $varToken ][ 'parenthesis_opener' ] < $varToken ) {
81
+                $varToken = $tokens[ $varToken ][ 'parenthesis_opener' ];
82 82
                 continue;
83 83
             }
84 84
 
85
-            if (isset($tokens[$varToken]['bracket_opener']) === true) {
86
-                $varToken = $tokens[$varToken]['bracket_opener'];
85
+            if ( isset( $tokens[ $varToken ][ 'bracket_opener' ] ) === true ) {
86
+                $varToken = $tokens[ $varToken ][ 'bracket_opener' ];
87 87
                 continue;
88 88
             }
89 89
 
90
-            if ($tokens[$varToken]['code'] === T_SEMICOLON) {
90
+            if ( $tokens[ $varToken ][ 'code' ] === T_SEMICOLON ) {
91 91
                 // We've reached the next statement, so we
92 92
                 // didn't find a variable.
93 93
                 return;
94 94
             }
95 95
 
96
-            if ($tokens[$varToken]['code'] === T_VARIABLE) {
96
+            if ( $tokens[ $varToken ][ 'code' ] === T_VARIABLE ) {
97 97
                 // We found our variable.
98 98
                 break;
99 99
             }
100 100
         }//end for
101 101
 
102
-        if ($varToken <= 0) {
102
+        if ( $varToken <= 0 ) {
103 103
             // Didn't find a variable.
104 104
             return;
105 105
         }
106 106
 
107 107
         // Deal with this type of variable: self::$var by setting the var
108 108
         // token to be "self" rather than "$var".
109
-        if ($tokens[($varToken - 1)]['code'] === T_DOUBLE_COLON) {
110
-            $varToken = ($varToken - 2);
109
+        if ( $tokens[ ( $varToken - 1 ) ][ 'code' ] === T_DOUBLE_COLON ) {
110
+            $varToken = ( $varToken - 2 );
111 111
         }
112 112
 
113 113
         // Deal with this type of variable: $obj->$var by setting the var
114 114
         // token to be "$obj" rather than "$var".
115
-        if ($tokens[($varToken - 1)]['code'] === T_OBJECT_OPERATOR) {
116
-            $varToken = ($varToken - 2);
115
+        if ( $tokens[ ( $varToken - 1 ) ][ 'code' ] === T_OBJECT_OPERATOR ) {
116
+            $varToken = ( $varToken - 2 );
117 117
         }
118 118
 
119 119
         // Deal with this type of variable: $$var by setting the var
120 120
         // token to be "$" rather than "$var".
121
-        if ($tokens[($varToken - 1)]['content'] === '$') {
121
+        if ( $tokens[ ( $varToken - 1 ) ][ 'content' ] === '$' ) {
122 122
             $varToken--;
123 123
         }
124 124
 
125 125
         // Ignore member var definitions.
126
-        $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($varToken - 1), null, true);
127
-        if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$prev]['code']]) === true) {
126
+        $prev = $phpcsFile->findPrevious( T_WHITESPACE, ( $varToken - 1 ), null, true );
127
+        if ( isset( PHP_CodeSniffer_Tokens::$scopeModifiers[ $tokens[ $prev ][ 'code' ] ] ) === true ) {
128 128
             return;
129 129
         }
130 130
 
131
-        if ($tokens[$prev]['code'] === T_STATIC) {
131
+        if ( $tokens[ $prev ][ 'code' ] === T_STATIC ) {
132 132
             return;
133 133
         }
134 134
 
135 135
         // Make sure this variable is the first thing in the statement.
136
-        $varLine  = $tokens[$varToken]['line'];
136
+        $varLine  = $tokens[ $varToken ][ 'line' ];
137 137
         $prevLine = 0;
138
-        for ($i = ($varToken - 1); $i >= 0; $i--) {
139
-            if ($tokens[$i]['code'] === T_SEMICOLON) {
138
+        for ( $i = ( $varToken - 1 ); $i >= 0; $i-- ) {
139
+            if ( $tokens[ $i ][ 'code' ] === T_SEMICOLON ) {
140 140
                 // We reached the end of the statement.
141 141
                 return;
142 142
             }
143 143
 
144
-            if ($tokens[$i]['code'] === T_INLINE_THEN) {
144
+            if ( $tokens[ $i ][ 'code' ] === T_INLINE_THEN ) {
145 145
                 // We reached the end of the inline THEN statement.
146 146
                 return;
147 147
             }
148 148
 
149
-            if ($tokens[$i]['code'] === T_INLINE_ELSE) {
149
+            if ( $tokens[ $i ][ 'code' ] === T_INLINE_ELSE ) {
150 150
                 // We reached the end of the inline ELSE statement.
151 151
                 return;
152 152
             }
153 153
 
154
-            if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
155
-                $prevLine = $tokens[$i]['line'];
154
+            if ( isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === false ) {
155
+                $prevLine = $tokens[ $i ][ 'line' ];
156 156
                 break;
157 157
             }
158 158
         }//end for
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
         // Ignore the first part of FOR loops as we are allowed to
161 161
         // assign variables there even though the variable is not the
162 162
         // first thing on the line. Also ignore WHILE loops.
163
-        if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_owner']) === true) {
164
-            $owner = $tokens[$i]['parenthesis_owner'];
165
-            if ($tokens[$owner]['code'] === T_FOR || $tokens[$owner]['code'] === T_WHILE) {
163
+        if ( $tokens[ $i ][ 'code' ] === T_OPEN_PARENTHESIS && isset( $tokens[ $i ][ 'parenthesis_owner' ] ) === true ) {
164
+            $owner = $tokens[ $i ][ 'parenthesis_owner' ];
165
+            if ( $tokens[ $owner ][ 'code' ] === T_FOR || $tokens[ $owner ][ 'code' ] === T_WHILE ) {
166 166
                 return;
167 167
             }
168 168
         }
169 169
 
170
-        if ($prevLine === $varLine) {
170
+        if ( $prevLine === $varLine ) {
171 171
             $error = 'Assignments must be the first block of code on a line';
172
-            $phpcsFile->addError($error, $stackPtr, 'Found');
172
+            $phpcsFile->addError( $error, $stackPtr, 'Found' );
173 173
         }
174 174
 
175 175
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
  * @version   Release: @package_version@
29 29
  * @link      http://pear.php.net/package/PHP_CodeSniffer
30 30
  */
31
-class Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff implements PHP_CodeSniffer_Sniff
32
-{
31
+class Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff implements PHP_CodeSniffer_Sniff {
33 32
 
34 33
 
35 34
     /**
@@ -37,8 +36,7 @@  discard block
 block discarded – undo
37 36
      *
38 37
      * @return array
39 38
      */
40
-    public function register()
41
-    {
39
+    public function register() {
42 40
         return array(T_EQUAL);
43 41
 
44 42
     }//end register()
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
      *
54 52
      * @return void
55 53
      */
56
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
57
-    {
54
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
58 55
         $tokens = $phpcsFile->getTokens();
59 56
 
60 57
         // Ignore default value assignments in function definitions.
Please login to merge, or discard this patch.