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
Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -29,97 +29,97 @@
 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 array(T_EQUAL);
40
-
41
-    }//end register()
42
-
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
-
57
-        // Ignore default value assignments in function definitions.
58
-        $function = $phpcsFile->findPrevious(T_FUNCTION, ($stackPtr - 1), null, false, null, true);
59
-        if ($function !== false) {
60
-            $opener = $tokens[$function]['parenthesis_opener'];
61
-            $closer = $tokens[$function]['parenthesis_closer'];
62
-            if ($opener < $stackPtr && $closer > $stackPtr) {
63
-                return;
64
-            }
65
-        }
66
-
67
-        // Ignore values in array definitions.
68
-        $array = $phpcsFile->findNext(
69
-            T_ARRAY,
70
-            ($stackPtr + 1),
71
-            null,
72
-            false,
73
-            null,
74
-            true
75
-        );
76
-
77
-        if ($array !== false) {
78
-            return;
79
-        }
80
-
81
-        // Ignore function calls.
82
-        $ignore = array(
83
-                   T_STRING,
84
-                   T_WHITESPACE,
85
-                   T_OBJECT_OPERATOR,
86
-                  );
87
-
88
-        $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true);
89
-        if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS
90
-            && $tokens[($next - 1)]['code'] === T_STRING
91
-        ) {
92
-            // Code will look like: $var = myFunction(
93
-            // and will be ignored.
94
-            return;
95
-        }
96
-
97
-        $endStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
98
-        if ($tokens[$stackPtr]['conditions'] !== $tokens[$endStatement]['conditions']) {
99
-            // This statement doesn't end with a semicolon, which is the case for
100
-            // the last expression in a for loop.
101
-            return;
102
-        }
103
-
104
-        for ($i = ($stackPtr + 1); $i < $endStatement; $i++) {
105
-            if (isset(PHP_CodeSniffer_Tokens::$comparisonTokens[$tokens[$i]['code']]) === true
106
-                || $tokens[$i]['code'] === T_INLINE_THEN
107
-            ) {
108
-                $error = 'The value of a comparison must not be assigned to a variable';
109
-                $phpcsFile->addError($error, $stackPtr, 'AssignedComparison');
110
-                break;
111
-            }
112
-
113
-            if (isset(PHP_CodeSniffer_Tokens::$booleanOperators[$tokens[$i]['code']]) === true
114
-                || $tokens[$i]['code'] === T_BOOLEAN_NOT
115
-            ) {
116
-                $error = 'The value of a boolean operation must not be assigned to a variable';
117
-                $phpcsFile->addError($error, $stackPtr, 'AssignedBool');
118
-                break;
119
-            }
120
-        }
121
-
122
-    }//end process()
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 array(T_EQUAL);
40
+
41
+	 }//end register()
42
+
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
+
57
+		  // Ignore default value assignments in function definitions.
58
+		  $function = $phpcsFile->findPrevious(T_FUNCTION, ($stackPtr - 1), null, false, null, true);
59
+		  if ($function !== false) {
60
+				$opener = $tokens[$function]['parenthesis_opener'];
61
+				$closer = $tokens[$function]['parenthesis_closer'];
62
+				if ($opener < $stackPtr && $closer > $stackPtr) {
63
+					 return;
64
+				}
65
+		  }
66
+
67
+		  // Ignore values in array definitions.
68
+		  $array = $phpcsFile->findNext(
69
+				T_ARRAY,
70
+				($stackPtr + 1),
71
+				null,
72
+				false,
73
+				null,
74
+				true
75
+		  );
76
+
77
+		  if ($array !== false) {
78
+				return;
79
+		  }
80
+
81
+		  // Ignore function calls.
82
+		  $ignore = array(
83
+						 T_STRING,
84
+						 T_WHITESPACE,
85
+						 T_OBJECT_OPERATOR,
86
+						);
87
+
88
+		  $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true);
89
+		  if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS
90
+				&& $tokens[($next - 1)]['code'] === T_STRING
91
+		  ) {
92
+				// Code will look like: $var = myFunction(
93
+				// and will be ignored.
94
+				return;
95
+		  }
96
+
97
+		  $endStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
98
+		  if ($tokens[$stackPtr]['conditions'] !== $tokens[$endStatement]['conditions']) {
99
+				// This statement doesn't end with a semicolon, which is the case for
100
+				// the last expression in a for loop.
101
+				return;
102
+		  }
103
+
104
+		  for ($i = ($stackPtr + 1); $i < $endStatement; $i++) {
105
+				if (isset(PHP_CodeSniffer_Tokens::$comparisonTokens[$tokens[$i]['code']]) === true
106
+					 || $tokens[$i]['code'] === T_INLINE_THEN
107
+				) {
108
+					 $error = 'The value of a comparison must not be assigned to a variable';
109
+					 $phpcsFile->addError($error, $stackPtr, 'AssignedComparison');
110
+					 break;
111
+				}
112
+
113
+				if (isset(PHP_CodeSniffer_Tokens::$booleanOperators[$tokens[$i]['code']]) === true
114
+					 || $tokens[$i]['code'] === T_BOOLEAN_NOT
115
+				) {
116
+					 $error = 'The value of a boolean operation must not be assigned to a variable';
117
+					 $phpcsFile->addError($error, $stackPtr, 'AssignedBool');
118
+					 break;
119
+				}
120
+		  }
121
+
122
+	 }//end process()
123 123
 
124 124
 
125 125
 }//end class
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function register()
38 38
     {
39
-        return array(T_EQUAL);
39
+        return array( T_EQUAL );
40 40
 
41 41
     }//end register()
42 42
 
@@ -50,16 +50,16 @@  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 56
 
57 57
         // Ignore default value assignments in function definitions.
58
-        $function = $phpcsFile->findPrevious(T_FUNCTION, ($stackPtr - 1), null, false, null, true);
59
-        if ($function !== false) {
60
-            $opener = $tokens[$function]['parenthesis_opener'];
61
-            $closer = $tokens[$function]['parenthesis_closer'];
62
-            if ($opener < $stackPtr && $closer > $stackPtr) {
58
+        $function = $phpcsFile->findPrevious( T_FUNCTION, ( $stackPtr - 1 ), null, false, null, true );
59
+        if ( $function !== false ) {
60
+            $opener = $tokens[ $function ][ 'parenthesis_opener' ];
61
+            $closer = $tokens[ $function ][ 'parenthesis_closer' ];
62
+            if ( $opener < $stackPtr && $closer > $stackPtr ) {
63 63
                 return;
64 64
             }
65 65
         }
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         // Ignore values in array definitions.
68 68
         $array = $phpcsFile->findNext(
69 69
             T_ARRAY,
70
-            ($stackPtr + 1),
70
+            ( $stackPtr + 1 ),
71 71
             null,
72 72
             false,
73 73
             null,
74 74
             true
75 75
         );
76 76
 
77
-        if ($array !== false) {
77
+        if ( $array !== false ) {
78 78
             return;
79 79
         }
80 80
 
@@ -85,36 +85,36 @@  discard block
 block discarded – undo
85 85
                    T_OBJECT_OPERATOR,
86 86
                   );
87 87
 
88
-        $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true);
89
-        if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS
90
-            && $tokens[($next - 1)]['code'] === T_STRING
88
+        $next = $phpcsFile->findNext( $ignore, ( $stackPtr + 1 ), null, true );
89
+        if ( $tokens[ $next ][ 'code' ] === T_OPEN_PARENTHESIS
90
+            && $tokens[ ( $next - 1 ) ][ 'code' ] === T_STRING
91 91
         ) {
92 92
             // Code will look like: $var = myFunction(
93 93
             // and will be ignored.
94 94
             return;
95 95
         }
96 96
 
97
-        $endStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
98
-        if ($tokens[$stackPtr]['conditions'] !== $tokens[$endStatement]['conditions']) {
97
+        $endStatement = $phpcsFile->findNext( T_SEMICOLON, ( $stackPtr + 1 ) );
98
+        if ( $tokens[ $stackPtr ][ 'conditions' ] !== $tokens[ $endStatement ][ 'conditions' ] ) {
99 99
             // This statement doesn't end with a semicolon, which is the case for
100 100
             // the last expression in a for loop.
101 101
             return;
102 102
         }
103 103
 
104
-        for ($i = ($stackPtr + 1); $i < $endStatement; $i++) {
105
-            if (isset(PHP_CodeSniffer_Tokens::$comparisonTokens[$tokens[$i]['code']]) === true
106
-                || $tokens[$i]['code'] === T_INLINE_THEN
104
+        for ( $i = ( $stackPtr + 1 ); $i < $endStatement; $i++ ) {
105
+            if ( isset( PHP_CodeSniffer_Tokens::$comparisonTokens[ $tokens[ $i ][ 'code' ] ] ) === true
106
+                || $tokens[ $i ][ 'code' ] === T_INLINE_THEN
107 107
             ) {
108 108
                 $error = 'The value of a comparison must not be assigned to a variable';
109
-                $phpcsFile->addError($error, $stackPtr, 'AssignedComparison');
109
+                $phpcsFile->addError( $error, $stackPtr, 'AssignedComparison' );
110 110
                 break;
111 111
             }
112 112
 
113
-            if (isset(PHP_CodeSniffer_Tokens::$booleanOperators[$tokens[$i]['code']]) === true
114
-                || $tokens[$i]['code'] === T_BOOLEAN_NOT
113
+            if ( isset( PHP_CodeSniffer_Tokens::$booleanOperators[ $tokens[ $i ][ 'code' ] ] ) === true
114
+                || $tokens[ $i ][ 'code' ] === T_BOOLEAN_NOT
115 115
             ) {
116 116
                 $error = 'The value of a boolean operation must not be assigned to a variable';
117
-                $phpcsFile->addError($error, $stackPtr, 'AssignedBool');
117
+                $phpcsFile->addError( $error, $stackPtr, 'AssignedBool' );
118 118
                 break;
119 119
             }
120 120
         }
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_DisallowComparisonAssignmentSniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff 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 array(T_EQUAL);
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
 
57 54
         // Ignore default value assignments in function definitions.
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php 3 patches
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -30,208 +30,208 @@
 block discarded – undo
30 30
 class Squiz_Sniffs_PHP_CommentedOutCodeSniff 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
-                                   'CSS',
41
-                                  );
42
-
43
-    /**
44
-     * If a comment is more than $maxPercentage% code, a warning will be shown.
45
-     *
46
-     * @var int
47
-     */
48
-    public $maxPercentage = 35;
49
-
50
-
51
-    /**
52
-     * Returns an array of tokens this test wants to listen for.
53
-     *
54
-     * @return array
55
-     */
56
-    public function register()
57
-    {
58
-        return array(T_COMMENT);
59
-
60
-    }//end register()
61
-
62
-
63
-    /**
64
-     * Processes this test, when one of its tokens is encountered.
65
-     *
66
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
67
-     * @param int                  $stackPtr  The position of the current token
68
-     *                                        in the stack passed in $tokens.
69
-     *
70
-     * @return void
71
-     */
72
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
73
-    {
74
-        $tokens = $phpcsFile->getTokens();
75
-
76
-        // Process whole comment blocks at once, so skip all but the first token.
77
-        if ($stackPtr > 0 && $tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) {
78
-            return;
79
-        }
80
-
81
-        // Ignore comments at the end of code blocks.
82
-        if (substr($tokens[$stackPtr]['content'], 0, 6) === '//end ') {
83
-            return;
84
-        }
85
-
86
-        $content = '';
87
-        if ($phpcsFile->tokenizerType === 'PHP') {
88
-            $content = '<?php ';
89
-        }
90
-
91
-        for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
92
-            if ($tokens[$stackPtr]['code'] !== $tokens[$i]['code']) {
93
-                break;
94
-            }
95
-
96
-            /*
33
+	 /**
34
+	  * A list of tokenizers this sniff supports.
35
+	  *
36
+	  * @var array
37
+	  */
38
+	 public $supportedTokenizers = array(
39
+											  'PHP',
40
+											  'CSS',
41
+											 );
42
+
43
+	 /**
44
+	  * If a comment is more than $maxPercentage% code, a warning will be shown.
45
+	  *
46
+	  * @var int
47
+	  */
48
+	 public $maxPercentage = 35;
49
+
50
+
51
+	 /**
52
+	  * Returns an array of tokens this test wants to listen for.
53
+	  *
54
+	  * @return array
55
+	  */
56
+	 public function register()
57
+	 {
58
+		  return array(T_COMMENT);
59
+
60
+	 }//end register()
61
+
62
+
63
+	 /**
64
+	  * Processes this test, when one of its tokens is encountered.
65
+	  *
66
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
67
+	  * @param int                  $stackPtr  The position of the current token
68
+	  *                                        in the stack passed in $tokens.
69
+	  *
70
+	  * @return void
71
+	  */
72
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
73
+	 {
74
+		  $tokens = $phpcsFile->getTokens();
75
+
76
+		  // Process whole comment blocks at once, so skip all but the first token.
77
+		  if ($stackPtr > 0 && $tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) {
78
+				return;
79
+		  }
80
+
81
+		  // Ignore comments at the end of code blocks.
82
+		  if (substr($tokens[$stackPtr]['content'], 0, 6) === '//end ') {
83
+				return;
84
+		  }
85
+
86
+		  $content = '';
87
+		  if ($phpcsFile->tokenizerType === 'PHP') {
88
+				$content = '<?php ';
89
+		  }
90
+
91
+		  for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
92
+				if ($tokens[$stackPtr]['code'] !== $tokens[$i]['code']) {
93
+					 break;
94
+				}
95
+
96
+				/*
97 97
                 Trim as much off the comment as possible so we don't
98 98
                 have additional whitespace tokens or comment tokens
99 99
             */
100 100
 
101
-            $tokenContent = trim($tokens[$i]['content']);
101
+				$tokenContent = trim($tokens[$i]['content']);
102 102
 
103
-            if (substr($tokenContent, 0, 2) === '//') {
104
-                $tokenContent = substr($tokenContent, 2);
105
-            }
103
+				if (substr($tokenContent, 0, 2) === '//') {
104
+					 $tokenContent = substr($tokenContent, 2);
105
+				}
106 106
 
107
-            if (substr($tokenContent, 0, 1) === '#') {
108
-                $tokenContent = substr($tokenContent, 1);
109
-            }
107
+				if (substr($tokenContent, 0, 1) === '#') {
108
+					 $tokenContent = substr($tokenContent, 1);
109
+				}
110 110
 
111
-            if (substr($tokenContent, 0, 3) === '/**') {
112
-                $tokenContent = substr($tokenContent, 3);
113
-            }
111
+				if (substr($tokenContent, 0, 3) === '/**') {
112
+					 $tokenContent = substr($tokenContent, 3);
113
+				}
114 114
 
115
-            if (substr($tokenContent, 0, 2) === '/*') {
116
-                $tokenContent = substr($tokenContent, 2);
117
-            }
115
+				if (substr($tokenContent, 0, 2) === '/*') {
116
+					 $tokenContent = substr($tokenContent, 2);
117
+				}
118 118
 
119
-            if (substr($tokenContent, -2) === '*/') {
120
-                $tokenContent = substr($tokenContent, 0, -2);
121
-            }
119
+				if (substr($tokenContent, -2) === '*/') {
120
+					 $tokenContent = substr($tokenContent, 0, -2);
121
+				}
122 122
 
123
-            if (substr($tokenContent, 0, 1) === '*') {
124
-                $tokenContent = substr($tokenContent, 1);
125
-            }
123
+				if (substr($tokenContent, 0, 1) === '*') {
124
+					 $tokenContent = substr($tokenContent, 1);
125
+				}
126 126
 
127
-            $content .= $tokenContent.$phpcsFile->eolChar;
128
-        }//end for
127
+				$content .= $tokenContent.$phpcsFile->eolChar;
128
+		  }//end for
129 129
 
130
-        $content = trim($content);
130
+		  $content = trim($content);
131 131
 
132
-        if ($phpcsFile->tokenizerType === 'PHP') {
133
-            $content .= ' ?>';
134
-        }
132
+		  if ($phpcsFile->tokenizerType === 'PHP') {
133
+				$content .= ' ?>';
134
+		  }
135 135
 
136
-        // Quite a few comments use multiple dashes, equals signs etc
137
-        // to frame comments and licence headers.
138
-        $content = preg_replace('/[-=*]+/', '-', $content);
136
+		  // Quite a few comments use multiple dashes, equals signs etc
137
+		  // to frame comments and licence headers.
138
+		  $content = preg_replace('/[-=*]+/', '-', $content);
139 139
 
140
-        // Because we are not really parsing code, the tokenizer can throw all sorts
141
-        // of errors that don't mean anything, so ignore them.
142
-        $oldErrors = ini_get('error_reporting');
143
-        ini_set('error_reporting', 0);
144
-        try {
145
-            $stringTokens = PHP_CodeSniffer_File::tokenizeString($content, $phpcsFile->tokenizer, $phpcsFile->eolChar);
146
-        } catch (PHP_CodeSniffer_Exception $e) {
147
-            // We couldn't check the comment, so ignore it.
148
-            ini_set('error_reporting', $oldErrors);
149
-            return;
150
-        }
140
+		  // Because we are not really parsing code, the tokenizer can throw all sorts
141
+		  // of errors that don't mean anything, so ignore them.
142
+		  $oldErrors = ini_get('error_reporting');
143
+		  ini_set('error_reporting', 0);
144
+		  try {
145
+				$stringTokens = PHP_CodeSniffer_File::tokenizeString($content, $phpcsFile->tokenizer, $phpcsFile->eolChar);
146
+		  } catch (PHP_CodeSniffer_Exception $e) {
147
+				// We couldn't check the comment, so ignore it.
148
+				ini_set('error_reporting', $oldErrors);
149
+				return;
150
+		  }
151 151
 
152
-        ini_set('error_reporting', $oldErrors);
152
+		  ini_set('error_reporting', $oldErrors);
153 153
 
154
-        $emptyTokens = array(
155
-                        T_WHITESPACE              => true,
156
-                        T_STRING                  => true,
157
-                        T_STRING_CONCAT           => true,
158
-                        T_ENCAPSED_AND_WHITESPACE => true,
159
-                        T_NONE                    => true,
160
-                        T_COMMENT                 => true,
161
-                       );
154
+		  $emptyTokens = array(
155
+								T_WHITESPACE              => true,
156
+								T_STRING                  => true,
157
+								T_STRING_CONCAT           => true,
158
+								T_ENCAPSED_AND_WHITESPACE => true,
159
+								T_NONE                    => true,
160
+								T_COMMENT                 => true,
161
+							  );
162 162
 
163
-        $numTokens = count($stringTokens);
163
+		  $numTokens = count($stringTokens);
164 164
 
165
-        /*
165
+		  /*
166 166
             We know what the first two and last two tokens should be
167 167
             (because we put them there) so ignore this comment if those
168 168
             tokens were not parsed correctly. It obviously means this is not
169 169
             valid code.
170 170
         */
171 171
 
172
-        // First token is always the opening PHP tag.
173
-        if ($stringTokens[0]['code'] !== T_OPEN_TAG) {
174
-            return;
175
-        }
176
-
177
-        // Last token is always the closing PHP tag, unless something went wrong.
178
-        if (isset($stringTokens[($numTokens - 1)]) === false
179
-            || $stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG
180
-        ) {
181
-            return;
182
-        }
183
-
184
-        // Second last token is always whitespace or a comment, depending
185
-        // on the code inside the comment.
186
-        if ($phpcsFile->tokenizerType === 'PHP'
187
-            && isset(PHP_CodeSniffer_Tokens::$emptyTokens[$stringTokens[($numTokens - 2)]['code']]) === false
188
-        ) {
189
-            return;
190
-        }
191
-
192
-        $numComment  = 0;
193
-        $numPossible = 0;
194
-        $numCode     = 0;
195
-
196
-        for ($i = 0; $i < $numTokens; $i++) {
197
-            if (isset($emptyTokens[$stringTokens[$i]['code']]) === true) {
198
-                // Looks like comment.
199
-                $numComment++;
200
-            } else if (in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true
201
-                || in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$arithmeticTokens) === true
202
-                || $stringTokens[$i]['code'] === T_GOTO_LABEL
203
-            ) {
204
-                // Commented out HTML/XML and other docs contain a lot of these
205
-                // characters, so it is best to not use them directly.
206
-                $numPossible++;
207
-            } else {
208
-                // Looks like code.
209
-                $numCode++;
210
-            }
211
-        }
212
-
213
-        // We subtract 3 from the token number so we ignore the start/end tokens
214
-        // and their surrounding whitespace. We take 2 off the number of code
215
-        // tokens so we ignore the start/end tokens.
216
-        if ($numTokens > 3) {
217
-            $numTokens -= 3;
218
-        }
219
-
220
-        if ($numCode >= 2) {
221
-            $numCode -= 2;
222
-        }
223
-
224
-        $percentCode = ceil((($numCode / $numTokens) * 100));
225
-        if ($percentCode > $this->maxPercentage) {
226
-            // Just in case.
227
-            $percentCode = min(100, $percentCode);
228
-
229
-            $error = 'This comment is %s%% valid code; is this commented out code?';
230
-            $data  = array($percentCode);
231
-            $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
232
-        }
233
-
234
-    }//end process()
172
+		  // First token is always the opening PHP tag.
173
+		  if ($stringTokens[0]['code'] !== T_OPEN_TAG) {
174
+				return;
175
+		  }
176
+
177
+		  // Last token is always the closing PHP tag, unless something went wrong.
178
+		  if (isset($stringTokens[($numTokens - 1)]) === false
179
+				|| $stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG
180
+		  ) {
181
+				return;
182
+		  }
183
+
184
+		  // Second last token is always whitespace or a comment, depending
185
+		  // on the code inside the comment.
186
+		  if ($phpcsFile->tokenizerType === 'PHP'
187
+				&& isset(PHP_CodeSniffer_Tokens::$emptyTokens[$stringTokens[($numTokens - 2)]['code']]) === false
188
+		  ) {
189
+				return;
190
+		  }
191
+
192
+		  $numComment  = 0;
193
+		  $numPossible = 0;
194
+		  $numCode     = 0;
195
+
196
+		  for ($i = 0; $i < $numTokens; $i++) {
197
+				if (isset($emptyTokens[$stringTokens[$i]['code']]) === true) {
198
+					 // Looks like comment.
199
+					 $numComment++;
200
+				} else if (in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true
201
+					 || in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$arithmeticTokens) === true
202
+					 || $stringTokens[$i]['code'] === T_GOTO_LABEL
203
+				) {
204
+					 // Commented out HTML/XML and other docs contain a lot of these
205
+					 // characters, so it is best to not use them directly.
206
+					 $numPossible++;
207
+				} else {
208
+					 // Looks like code.
209
+					 $numCode++;
210
+				}
211
+		  }
212
+
213
+		  // We subtract 3 from the token number so we ignore the start/end tokens
214
+		  // and their surrounding whitespace. We take 2 off the number of code
215
+		  // tokens so we ignore the start/end tokens.
216
+		  if ($numTokens > 3) {
217
+				$numTokens -= 3;
218
+		  }
219
+
220
+		  if ($numCode >= 2) {
221
+				$numCode -= 2;
222
+		  }
223
+
224
+		  $percentCode = ceil((($numCode / $numTokens) * 100));
225
+		  if ($percentCode > $this->maxPercentage) {
226
+				// Just in case.
227
+				$percentCode = min(100, $percentCode);
228
+
229
+				$error = 'This comment is %s%% valid code; is this commented out code?';
230
+				$data  = array($percentCode);
231
+				$phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
232
+		  }
233
+
234
+	 }//end process()
235 235
 
236 236
 
237 237
 }//end class
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function register()
57 57
     {
58
-        return array(T_COMMENT);
58
+        return array( T_COMMENT );
59 59
 
60 60
     }//end register()
61 61
 
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @return void
71 71
      */
72
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
72
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
73 73
     {
74 74
         $tokens = $phpcsFile->getTokens();
75 75
 
76 76
         // Process whole comment blocks at once, so skip all but the first token.
77
-        if ($stackPtr > 0 && $tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) {
77
+        if ( $stackPtr > 0 && $tokens[ $stackPtr ][ 'code' ] === $tokens[ ( $stackPtr - 1 ) ][ 'code' ] ) {
78 78
             return;
79 79
         }
80 80
 
81 81
         // Ignore comments at the end of code blocks.
82
-        if (substr($tokens[$stackPtr]['content'], 0, 6) === '//end ') {
82
+        if ( substr( $tokens[ $stackPtr ][ 'content' ], 0, 6 ) === '//end ' ) {
83 83
             return;
84 84
         }
85 85
 
86 86
         $content = '';
87
-        if ($phpcsFile->tokenizerType === 'PHP') {
87
+        if ( $phpcsFile->tokenizerType === 'PHP' ) {
88 88
             $content = '<?php ';
89 89
         }
90 90
 
91
-        for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
92
-            if ($tokens[$stackPtr]['code'] !== $tokens[$i]['code']) {
91
+        for ( $i = $stackPtr; $i < $phpcsFile->numTokens; $i++ ) {
92
+            if ( $tokens[ $stackPtr ][ 'code' ] !== $tokens[ $i ][ 'code' ] ) {
93 93
                 break;
94 94
             }
95 95
 
@@ -98,58 +98,58 @@  discard block
 block discarded – undo
98 98
                 have additional whitespace tokens or comment tokens
99 99
             */
100 100
 
101
-            $tokenContent = trim($tokens[$i]['content']);
101
+            $tokenContent = trim( $tokens[ $i ][ 'content' ] );
102 102
 
103
-            if (substr($tokenContent, 0, 2) === '//') {
104
-                $tokenContent = substr($tokenContent, 2);
103
+            if ( substr( $tokenContent, 0, 2 ) === '//' ) {
104
+                $tokenContent = substr( $tokenContent, 2 );
105 105
             }
106 106
 
107
-            if (substr($tokenContent, 0, 1) === '#') {
108
-                $tokenContent = substr($tokenContent, 1);
107
+            if ( substr( $tokenContent, 0, 1 ) === '#' ) {
108
+                $tokenContent = substr( $tokenContent, 1 );
109 109
             }
110 110
 
111
-            if (substr($tokenContent, 0, 3) === '/**') {
112
-                $tokenContent = substr($tokenContent, 3);
111
+            if ( substr( $tokenContent, 0, 3 ) === '/**' ) {
112
+                $tokenContent = substr( $tokenContent, 3 );
113 113
             }
114 114
 
115
-            if (substr($tokenContent, 0, 2) === '/*') {
116
-                $tokenContent = substr($tokenContent, 2);
115
+            if ( substr( $tokenContent, 0, 2 ) === '/*' ) {
116
+                $tokenContent = substr( $tokenContent, 2 );
117 117
             }
118 118
 
119
-            if (substr($tokenContent, -2) === '*/') {
120
-                $tokenContent = substr($tokenContent, 0, -2);
119
+            if ( substr( $tokenContent, -2 ) === '*/' ) {
120
+                $tokenContent = substr( $tokenContent, 0, -2 );
121 121
             }
122 122
 
123
-            if (substr($tokenContent, 0, 1) === '*') {
124
-                $tokenContent = substr($tokenContent, 1);
123
+            if ( substr( $tokenContent, 0, 1 ) === '*' ) {
124
+                $tokenContent = substr( $tokenContent, 1 );
125 125
             }
126 126
 
127
-            $content .= $tokenContent.$phpcsFile->eolChar;
127
+            $content .= $tokenContent . $phpcsFile->eolChar;
128 128
         }//end for
129 129
 
130
-        $content = trim($content);
130
+        $content = trim( $content );
131 131
 
132
-        if ($phpcsFile->tokenizerType === 'PHP') {
132
+        if ( $phpcsFile->tokenizerType === 'PHP' ) {
133 133
             $content .= ' ?>';
134 134
         }
135 135
 
136 136
         // Quite a few comments use multiple dashes, equals signs etc
137 137
         // to frame comments and licence headers.
138
-        $content = preg_replace('/[-=*]+/', '-', $content);
138
+        $content = preg_replace( '/[-=*]+/', '-', $content );
139 139
 
140 140
         // Because we are not really parsing code, the tokenizer can throw all sorts
141 141
         // of errors that don't mean anything, so ignore them.
142
-        $oldErrors = ini_get('error_reporting');
143
-        ini_set('error_reporting', 0);
142
+        $oldErrors = ini_get( 'error_reporting' );
143
+        ini_set( 'error_reporting', 0 );
144 144
         try {
145
-            $stringTokens = PHP_CodeSniffer_File::tokenizeString($content, $phpcsFile->tokenizer, $phpcsFile->eolChar);
146
-        } catch (PHP_CodeSniffer_Exception $e) {
145
+            $stringTokens = PHP_CodeSniffer_File::tokenizeString( $content, $phpcsFile->tokenizer, $phpcsFile->eolChar );
146
+        } catch ( PHP_CodeSniffer_Exception $e ) {
147 147
             // We couldn't check the comment, so ignore it.
148
-            ini_set('error_reporting', $oldErrors);
148
+            ini_set( 'error_reporting', $oldErrors );
149 149
             return;
150 150
         }
151 151
 
152
-        ini_set('error_reporting', $oldErrors);
152
+        ini_set( 'error_reporting', $oldErrors );
153 153
 
154 154
         $emptyTokens = array(
155 155
                         T_WHITESPACE              => true,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                         T_COMMENT                 => true,
161 161
                        );
162 162
 
163
-        $numTokens = count($stringTokens);
163
+        $numTokens = count( $stringTokens );
164 164
 
165 165
         /*
166 166
             We know what the first two and last two tokens should be
@@ -170,21 +170,21 @@  discard block
 block discarded – undo
170 170
         */
171 171
 
172 172
         // First token is always the opening PHP tag.
173
-        if ($stringTokens[0]['code'] !== T_OPEN_TAG) {
173
+        if ( $stringTokens[ 0 ][ 'code' ] !== T_OPEN_TAG ) {
174 174
             return;
175 175
         }
176 176
 
177 177
         // Last token is always the closing PHP tag, unless something went wrong.
178
-        if (isset($stringTokens[($numTokens - 1)]) === false
179
-            || $stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG
178
+        if ( isset( $stringTokens[ ( $numTokens - 1 ) ] ) === false
179
+            || $stringTokens[ ( $numTokens - 1 ) ][ 'code' ] !== T_CLOSE_TAG
180 180
         ) {
181 181
             return;
182 182
         }
183 183
 
184 184
         // Second last token is always whitespace or a comment, depending
185 185
         // on the code inside the comment.
186
-        if ($phpcsFile->tokenizerType === 'PHP'
187
-            && isset(PHP_CodeSniffer_Tokens::$emptyTokens[$stringTokens[($numTokens - 2)]['code']]) === false
186
+        if ( $phpcsFile->tokenizerType === 'PHP'
187
+            && isset( PHP_CodeSniffer_Tokens::$emptyTokens[ $stringTokens[ ( $numTokens - 2 ) ][ 'code' ] ] ) === false
188 188
         ) {
189 189
             return;
190 190
         }
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
         $numPossible = 0;
194 194
         $numCode     = 0;
195 195
 
196
-        for ($i = 0; $i < $numTokens; $i++) {
197
-            if (isset($emptyTokens[$stringTokens[$i]['code']]) === true) {
196
+        for ( $i = 0; $i < $numTokens; $i++ ) {
197
+            if ( isset( $emptyTokens[ $stringTokens[ $i ][ 'code' ] ] ) === true ) {
198 198
                 // Looks like comment.
199 199
                 $numComment++;
200
-            } else if (in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true
201
-                || in_array($stringTokens[$i]['code'], PHP_CodeSniffer_Tokens::$arithmeticTokens) === true
202
-                || $stringTokens[$i]['code'] === T_GOTO_LABEL
200
+            } else if ( in_array( $stringTokens[ $i ][ 'code' ], PHP_CodeSniffer_Tokens::$comparisonTokens ) === true
201
+                || in_array( $stringTokens[ $i ][ 'code' ], PHP_CodeSniffer_Tokens::$arithmeticTokens ) === true
202
+                || $stringTokens[ $i ][ 'code' ] === T_GOTO_LABEL
203 203
             ) {
204 204
                 // Commented out HTML/XML and other docs contain a lot of these
205 205
                 // characters, so it is best to not use them directly.
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
         // We subtract 3 from the token number so we ignore the start/end tokens
214 214
         // and their surrounding whitespace. We take 2 off the number of code
215 215
         // tokens so we ignore the start/end tokens.
216
-        if ($numTokens > 3) {
216
+        if ( $numTokens > 3 ) {
217 217
             $numTokens -= 3;
218 218
         }
219 219
 
220
-        if ($numCode >= 2) {
220
+        if ( $numCode >= 2 ) {
221 221
             $numCode -= 2;
222 222
         }
223 223
 
224
-        $percentCode = ceil((($numCode / $numTokens) * 100));
225
-        if ($percentCode > $this->maxPercentage) {
224
+        $percentCode = ceil( ( ( $numCode / $numTokens ) * 100 ) );
225
+        if ( $percentCode > $this->maxPercentage ) {
226 226
             // Just in case.
227
-            $percentCode = min(100, $percentCode);
227
+            $percentCode = min( 100, $percentCode );
228 228
 
229 229
             $error = 'This comment is %s%% valid code; is this commented out code?';
230
-            $data  = array($percentCode);
231
-            $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
230
+            $data  = array( $percentCode );
231
+            $phpcsFile->addWarning( $error, $stackPtr, 'Found', $data );
232 232
         }
233 233
 
234 234
     }//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_CommentedOutCodeSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Squiz_Sniffs_PHP_CommentedOutCodeSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
     /**
34 33
      * A list of tokenizers this sniff supports.
@@ -53,8 +52,7 @@  discard block
 block discarded – undo
53 52
      *
54 53
      * @return array
55 54
      */
56
-    public function register()
57
-    {
55
+    public function register() {
58 56
         return array(T_COMMENT);
59 57
 
60 58
     }//end register()
@@ -69,8 +67,7 @@  discard block
 block discarded – undo
69 67
      *
70 68
      * @return void
71 69
      */
72
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
73
-    {
70
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
74 71
         $tokens = $phpcsFile->getTokens();
75 72
 
76 73
         // Process whole comment blocks at once, so skip all but the first token.
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php 3 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -31,111 +31,111 @@
 block discarded – undo
31 31
 class Squiz_Sniffs_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_Sniff
32 32
 {
33 33
 
34
-    /**
35
-     * The number of spaces before and after a string concat.
36
-     *
37
-     * @var int
38
-     */
39
-    public $spacing = 0;
40
-
41
-    /**
42
-     * Allow newlines instead of spaces.
43
-     *
44
-     * @var boolean
45
-     */
46
-    public $ignoreNewlines = false;
47
-
48
-
49
-    /**
50
-     * Returns an array of tokens this test wants to listen for.
51
-     *
52
-     * @return array
53
-     */
54
-    public function register()
55
-    {
56
-        return array(T_STRING_CONCAT);
57
-
58
-    }//end register()
59
-
60
-
61
-    /**
62
-     * Processes this test, when one of its tokens is encountered.
63
-     *
64
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
-     * @param int                  $stackPtr  The position of the current token in the
66
-     *                                        stack passed in $tokens.
67
-     *
68
-     * @return void
69
-     */
70
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
71
-    {
72
-        $this->spacing = (int) $this->spacing;
73
-
74
-        $tokens = $phpcsFile->getTokens();
75
-        if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
76
-            $before = 0;
77
-        } else {
78
-            if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
79
-                $before = 'newline';
80
-            } else {
81
-                $before = $tokens[($stackPtr - 1)]['length'];
82
-            }
83
-        }
84
-
85
-        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
86
-            $after = 0;
87
-        } else {
88
-            if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
89
-                $after = 'newline';
90
-            } else {
91
-                $after = $tokens[($stackPtr + 1)]['length'];
92
-            }
93
-        }
94
-
95
-        $phpcsFile->recordMetric($stackPtr, 'Spacing before string concat', $before);
96
-        $phpcsFile->recordMetric($stackPtr, 'Spacing after string concat', $after);
97
-
98
-        if (($before === $this->spacing || ($before === 'newline' && $this->ignoreNewlines === true))
99
-            && ($after === $this->spacing || ($after === 'newline' && $this->ignoreNewlines === true))
100
-        ) {
101
-            return;
102
-        }
103
-
104
-        if ($this->spacing === 0) {
105
-            $message = 'Concat operator must not be surrounded by spaces';
106
-            $data    = array();
107
-        } else {
108
-            if ($this->spacing > 1) {
109
-                $message = 'Concat operator must be surrounded by %s spaces';
110
-            } else {
111
-                $message = 'Concat operator must be surrounded by a single space';
112
-            }
113
-
114
-            $data = array($this->spacing);
115
-        }
116
-
117
-        $fix = $phpcsFile->addFixableError($message, $stackPtr, 'PaddingFound', $data);
118
-
119
-        if ($fix === true) {
120
-            $padding = str_repeat(' ', $this->spacing);
121
-            if ($before !== 'newline' || $this->ignoreNewlines === false) {
122
-                if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
123
-                    $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
124
-                } else if ($this->spacing > 0) {
125
-                    $phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
126
-                }
127
-            }
128
-
129
-            if ($after !== 'newline' || $this->ignoreNewlines === false) {
130
-                if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
131
-                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), $padding);
132
-                } else if ($this->spacing > 0) {
133
-                    $phpcsFile->fixer->addContent($stackPtr, $padding);
134
-                }
135
-            }
136
-        }
137
-
138
-    }//end process()
34
+	 /**
35
+	  * The number of spaces before and after a string concat.
36
+	  *
37
+	  * @var int
38
+	  */
39
+	 public $spacing = 0;
40
+
41
+	 /**
42
+	  * Allow newlines instead of spaces.
43
+	  *
44
+	  * @var boolean
45
+	  */
46
+	 public $ignoreNewlines = false;
47
+
48
+
49
+	 /**
50
+	  * Returns an array of tokens this test wants to listen for.
51
+	  *
52
+	  * @return array
53
+	  */
54
+	 public function register()
55
+	 {
56
+		  return array(T_STRING_CONCAT);
57
+
58
+	 }//end register()
59
+
60
+
61
+	 /**
62
+	  * Processes this test, when one of its tokens is encountered.
63
+	  *
64
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
+	  * @param int                  $stackPtr  The position of the current token in the
66
+	  *                                        stack passed in $tokens.
67
+	  *
68
+	  * @return void
69
+	  */
70
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
71
+	 {
72
+		  $this->spacing = (int) $this->spacing;
73
+
74
+		  $tokens = $phpcsFile->getTokens();
75
+		  if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
76
+				$before = 0;
77
+		  } else {
78
+				if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
79
+					 $before = 'newline';
80
+				} else {
81
+					 $before = $tokens[($stackPtr - 1)]['length'];
82
+				}
83
+		  }
84
+
85
+		  if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
86
+				$after = 0;
87
+		  } else {
88
+				if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
89
+					 $after = 'newline';
90
+				} else {
91
+					 $after = $tokens[($stackPtr + 1)]['length'];
92
+				}
93
+		  }
94
+
95
+		  $phpcsFile->recordMetric($stackPtr, 'Spacing before string concat', $before);
96
+		  $phpcsFile->recordMetric($stackPtr, 'Spacing after string concat', $after);
97
+
98
+		  if (($before === $this->spacing || ($before === 'newline' && $this->ignoreNewlines === true))
99
+				&& ($after === $this->spacing || ($after === 'newline' && $this->ignoreNewlines === true))
100
+		  ) {
101
+				return;
102
+		  }
103
+
104
+		  if ($this->spacing === 0) {
105
+				$message = 'Concat operator must not be surrounded by spaces';
106
+				$data    = array();
107
+		  } else {
108
+				if ($this->spacing > 1) {
109
+					 $message = 'Concat operator must be surrounded by %s spaces';
110
+				} else {
111
+					 $message = 'Concat operator must be surrounded by a single space';
112
+				}
113
+
114
+				$data = array($this->spacing);
115
+		  }
116
+
117
+		  $fix = $phpcsFile->addFixableError($message, $stackPtr, 'PaddingFound', $data);
118
+
119
+		  if ($fix === true) {
120
+				$padding = str_repeat(' ', $this->spacing);
121
+				if ($before !== 'newline' || $this->ignoreNewlines === false) {
122
+					 if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
123
+						  $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
124
+					 } else if ($this->spacing > 0) {
125
+						  $phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
126
+					 }
127
+				}
128
+
129
+				if ($after !== 'newline' || $this->ignoreNewlines === false) {
130
+					 if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
131
+						  $phpcsFile->fixer->replaceToken(($stackPtr + 1), $padding);
132
+					 } else if ($this->spacing > 0) {
133
+						  $phpcsFile->fixer->addContent($stackPtr, $padding);
134
+					 }
135
+				}
136
+		  }
137
+
138
+	 }//end process()
139 139
 
140 140
 
141 141
 }//end class
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function register()
55 55
     {
56
-        return array(T_STRING_CONCAT);
56
+        return array( T_STRING_CONCAT );
57 57
 
58 58
     }//end register()
59 59
 
@@ -67,70 +67,70 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return void
69 69
      */
70
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
70
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
71 71
     {
72 72
         $this->spacing = (int) $this->spacing;
73 73
 
74 74
         $tokens = $phpcsFile->getTokens();
75
-        if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
75
+        if ( $tokens[ ( $stackPtr - 1 ) ][ 'code' ] !== T_WHITESPACE ) {
76 76
             $before = 0;
77 77
         } else {
78
-            if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
78
+            if ( $tokens[ ( $stackPtr - 2 ) ][ 'line' ] !== $tokens[ $stackPtr ][ 'line' ] ) {
79 79
                 $before = 'newline';
80 80
             } else {
81
-                $before = $tokens[($stackPtr - 1)]['length'];
81
+                $before = $tokens[ ( $stackPtr - 1 ) ][ 'length' ];
82 82
             }
83 83
         }
84 84
 
85
-        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
85
+        if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
86 86
             $after = 0;
87 87
         } else {
88
-            if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
88
+            if ( $tokens[ ( $stackPtr + 2 ) ][ 'line' ] !== $tokens[ $stackPtr ][ 'line' ] ) {
89 89
                 $after = 'newline';
90 90
             } else {
91
-                $after = $tokens[($stackPtr + 1)]['length'];
91
+                $after = $tokens[ ( $stackPtr + 1 ) ][ 'length' ];
92 92
             }
93 93
         }
94 94
 
95
-        $phpcsFile->recordMetric($stackPtr, 'Spacing before string concat', $before);
96
-        $phpcsFile->recordMetric($stackPtr, 'Spacing after string concat', $after);
95
+        $phpcsFile->recordMetric( $stackPtr, 'Spacing before string concat', $before );
96
+        $phpcsFile->recordMetric( $stackPtr, 'Spacing after string concat', $after );
97 97
 
98
-        if (($before === $this->spacing || ($before === 'newline' && $this->ignoreNewlines === true))
99
-            && ($after === $this->spacing || ($after === 'newline' && $this->ignoreNewlines === true))
98
+        if ( ( $before === $this->spacing || ( $before === 'newline' && $this->ignoreNewlines === true ) )
99
+            && ( $after === $this->spacing || ( $after === 'newline' && $this->ignoreNewlines === true ) )
100 100
         ) {
101 101
             return;
102 102
         }
103 103
 
104
-        if ($this->spacing === 0) {
104
+        if ( $this->spacing === 0 ) {
105 105
             $message = 'Concat operator must not be surrounded by spaces';
106 106
             $data    = array();
107 107
         } else {
108
-            if ($this->spacing > 1) {
108
+            if ( $this->spacing > 1 ) {
109 109
                 $message = 'Concat operator must be surrounded by %s spaces';
110 110
             } else {
111 111
                 $message = 'Concat operator must be surrounded by a single space';
112 112
             }
113 113
 
114
-            $data = array($this->spacing);
114
+            $data = array( $this->spacing );
115 115
         }
116 116
 
117
-        $fix = $phpcsFile->addFixableError($message, $stackPtr, 'PaddingFound', $data);
117
+        $fix = $phpcsFile->addFixableError( $message, $stackPtr, 'PaddingFound', $data );
118 118
 
119
-        if ($fix === true) {
120
-            $padding = str_repeat(' ', $this->spacing);
121
-            if ($before !== 'newline' || $this->ignoreNewlines === false) {
122
-                if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
123
-                    $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
124
-                } else if ($this->spacing > 0) {
125
-                    $phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
119
+        if ( $fix === true ) {
120
+            $padding = str_repeat( ' ', $this->spacing );
121
+            if ( $before !== 'newline' || $this->ignoreNewlines === false ) {
122
+                if ( $tokens[ ( $stackPtr - 1 ) ][ 'code' ] === T_WHITESPACE ) {
123
+                    $phpcsFile->fixer->replaceToken( ( $stackPtr - 1 ), $padding );
124
+                } else if ( $this->spacing > 0 ) {
125
+                    $phpcsFile->fixer->addContent( ( $stackPtr - 1 ), $padding );
126 126
                 }
127 127
             }
128 128
 
129
-            if ($after !== 'newline' || $this->ignoreNewlines === false) {
130
-                if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
131
-                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), $padding);
132
-                } else if ($this->spacing > 0) {
133
-                    $phpcsFile->fixer->addContent($stackPtr, $padding);
129
+            if ( $after !== 'newline' || $this->ignoreNewlines === false ) {
130
+                if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) {
131
+                    $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $padding );
132
+                } else if ( $this->spacing > 0 ) {
133
+                    $phpcsFile->fixer->addContent( $stackPtr, $padding );
134 134
                 }
135 135
             }
136 136
         }
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_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_Sniff
32
-{
31
+class Squiz_Sniffs_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_Sniff {
33 32
 
34 33
     /**
35 34
      * The number of spaces before and after a string concat.
@@ -51,8 +50,7 @@  discard block
 block discarded – undo
51 50
      *
52 51
      * @return array
53 52
      */
54
-    public function register()
55
-    {
53
+    public function register() {
56 54
         return array(T_STRING_CONCAT);
57 55
 
58 56
     }//end register()
@@ -67,8 +65,7 @@  discard block
 block discarded – undo
67 65
      *
68 66
      * @return void
69 67
      */
70
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
71
-    {
68
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
72 69
         $this->spacing = (int) $this->spacing;
73 70
 
74 71
         $tokens = $phpcsFile->getTokens();
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php 3 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -31,123 +31,123 @@
 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(
42
-                T_CONSTANT_ENCAPSED_STRING,
43
-                T_DOUBLE_QUOTED_STRING,
44
-               );
45
-
46
-    }//end register()
47
-
48
-
49
-    /**
50
-     * Processes this test, when one of its tokens is encountered.
51
-     *
52
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
-     * @param int                  $stackPtr  The position of the current token
54
-     *                                        in the stack passed in $tokens.
55
-     *
56
-     * @return void
57
-     */
58
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
59
-    {
60
-        $tokens = $phpcsFile->getTokens();
61
-
62
-        // We are only interested in the first token in a multi-line string.
63
-        if ($tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) {
64
-            return;
65
-        }
66
-
67
-        $workingString   = $tokens[$stackPtr]['content'];
68
-        $lastStringToken = $stackPtr;
69
-
70
-        $i = ($stackPtr + 1);
71
-        if (isset($tokens[$i]) === true) {
72
-            while ($i < $phpcsFile->numTokens
73
-                && $tokens[$i]['code'] === $tokens[$stackPtr]['code']
74
-            ) {
75
-                $workingString  .= $tokens[$i]['content'];
76
-                $lastStringToken = $i;
77
-                $i++;
78
-            }
79
-        }
80
-
81
-        // Check if it's a double quoted string.
82
-        if (strpos($workingString, '"') === false) {
83
-            return;
84
-        }
85
-
86
-        // Make sure it's not a part of a string started in a previous line.
87
-        // If it is, then we have already checked it.
88
-        if ($workingString[0] !== '"') {
89
-            return;
90
-        }
91
-
92
-        // The use of variables in double quoted strings is not allowed.
93
-        if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING) {
94
-            $stringTokens = token_get_all('<?php '.$workingString);
95
-            foreach ($stringTokens as $token) {
96
-                if (is_array($token) === true && $token[0] === T_VARIABLE) {
97
-                    $error = 'Variable "%s" not allowed in double quoted string; use concatenation instead';
98
-                    $data  = array($token[1]);
99
-                    $phpcsFile->addError($error, $stackPtr, 'ContainsVar', $data);
100
-                }
101
-            }
102
-
103
-            return;
104
-        }//end if
105
-
106
-        $allowedChars = array(
107
-                         '\0',
108
-                         '\1',
109
-                         '\2',
110
-                         '\3',
111
-                         '\4',
112
-                         '\5',
113
-                         '\6',
114
-                         '\7',
115
-                         '\n',
116
-                         '\r',
117
-                         '\f',
118
-                         '\t',
119
-                         '\v',
120
-                         '\x',
121
-                         '\b',
122
-                         '\e',
123
-                         '\u',
124
-                         '\'',
125
-                        );
126
-
127
-        foreach ($allowedChars as $testChar) {
128
-            if (strpos($workingString, $testChar) !== false) {
129
-                return;
130
-            }
131
-        }
132
-
133
-        $error = 'String %s does not require double quotes; use single quotes instead';
134
-        $data  = array(str_replace("\n", '\n', $workingString));
135
-        $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'NotRequired', $data);
136
-
137
-        if ($fix === true) {
138
-            $phpcsFile->fixer->beginChangeset();
139
-            $innerContent = substr($workingString, 1, -1);
140
-            $innerContent = str_replace('\"', '"', $innerContent);
141
-            $phpcsFile->fixer->replaceToken($stackPtr, "'$innerContent'");
142
-            while ($lastStringToken !== $stackPtr) {
143
-                $phpcsFile->fixer->replaceToken($lastStringToken, '');
144
-                $lastStringToken--;
145
-            }
146
-
147
-            $phpcsFile->fixer->endChangeset();
148
-        }
149
-
150
-    }//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(
42
+					 T_CONSTANT_ENCAPSED_STRING,
43
+					 T_DOUBLE_QUOTED_STRING,
44
+					);
45
+
46
+	 }//end register()
47
+
48
+
49
+	 /**
50
+	  * Processes this test, when one of its tokens is encountered.
51
+	  *
52
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
+	  * @param int                  $stackPtr  The position of the current token
54
+	  *                                        in the stack passed in $tokens.
55
+	  *
56
+	  * @return void
57
+	  */
58
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
59
+	 {
60
+		  $tokens = $phpcsFile->getTokens();
61
+
62
+		  // We are only interested in the first token in a multi-line string.
63
+		  if ($tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) {
64
+				return;
65
+		  }
66
+
67
+		  $workingString   = $tokens[$stackPtr]['content'];
68
+		  $lastStringToken = $stackPtr;
69
+
70
+		  $i = ($stackPtr + 1);
71
+		  if (isset($tokens[$i]) === true) {
72
+				while ($i < $phpcsFile->numTokens
73
+					 && $tokens[$i]['code'] === $tokens[$stackPtr]['code']
74
+				) {
75
+					 $workingString  .= $tokens[$i]['content'];
76
+					 $lastStringToken = $i;
77
+					 $i++;
78
+				}
79
+		  }
80
+
81
+		  // Check if it's a double quoted string.
82
+		  if (strpos($workingString, '"') === false) {
83
+				return;
84
+		  }
85
+
86
+		  // Make sure it's not a part of a string started in a previous line.
87
+		  // If it is, then we have already checked it.
88
+		  if ($workingString[0] !== '"') {
89
+				return;
90
+		  }
91
+
92
+		  // The use of variables in double quoted strings is not allowed.
93
+		  if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING) {
94
+				$stringTokens = token_get_all('<?php '.$workingString);
95
+				foreach ($stringTokens as $token) {
96
+					 if (is_array($token) === true && $token[0] === T_VARIABLE) {
97
+						  $error = 'Variable "%s" not allowed in double quoted string; use concatenation instead';
98
+						  $data  = array($token[1]);
99
+						  $phpcsFile->addError($error, $stackPtr, 'ContainsVar', $data);
100
+					 }
101
+				}
102
+
103
+				return;
104
+		  }//end if
105
+
106
+		  $allowedChars = array(
107
+								 '\0',
108
+								 '\1',
109
+								 '\2',
110
+								 '\3',
111
+								 '\4',
112
+								 '\5',
113
+								 '\6',
114
+								 '\7',
115
+								 '\n',
116
+								 '\r',
117
+								 '\f',
118
+								 '\t',
119
+								 '\v',
120
+								 '\x',
121
+								 '\b',
122
+								 '\e',
123
+								 '\u',
124
+								 '\'',
125
+								);
126
+
127
+		  foreach ($allowedChars as $testChar) {
128
+				if (strpos($workingString, $testChar) !== false) {
129
+					 return;
130
+				}
131
+		  }
132
+
133
+		  $error = 'String %s does not require double quotes; use single quotes instead';
134
+		  $data  = array(str_replace("\n", '\n', $workingString));
135
+		  $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'NotRequired', $data);
136
+
137
+		  if ($fix === true) {
138
+				$phpcsFile->fixer->beginChangeset();
139
+				$innerContent = substr($workingString, 1, -1);
140
+				$innerContent = str_replace('\"', '"', $innerContent);
141
+				$phpcsFile->fixer->replaceToken($stackPtr, "'$innerContent'");
142
+				while ($lastStringToken !== $stackPtr) {
143
+					 $phpcsFile->fixer->replaceToken($lastStringToken, '');
144
+					 $lastStringToken--;
145
+				}
146
+
147
+				$phpcsFile->fixer->endChangeset();
148
+		  }
149
+
150
+	 }//end process()
151 151
 
152 152
 
153 153
 }//end class
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -55,48 +55,48 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
59 59
     {
60 60
         $tokens = $phpcsFile->getTokens();
61 61
 
62 62
         // We are only interested in the first token in a multi-line string.
63
-        if ($tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) {
63
+        if ( $tokens[ $stackPtr ][ 'code' ] === $tokens[ ( $stackPtr - 1 ) ][ 'code' ] ) {
64 64
             return;
65 65
         }
66 66
 
67
-        $workingString   = $tokens[$stackPtr]['content'];
67
+        $workingString   = $tokens[ $stackPtr ][ 'content' ];
68 68
         $lastStringToken = $stackPtr;
69 69
 
70
-        $i = ($stackPtr + 1);
71
-        if (isset($tokens[$i]) === true) {
72
-            while ($i < $phpcsFile->numTokens
73
-                && $tokens[$i]['code'] === $tokens[$stackPtr]['code']
70
+        $i = ( $stackPtr + 1 );
71
+        if ( isset( $tokens[ $i ] ) === true ) {
72
+            while ( $i < $phpcsFile->numTokens
73
+                && $tokens[ $i ][ 'code' ] === $tokens[ $stackPtr ][ 'code' ]
74 74
             ) {
75
-                $workingString  .= $tokens[$i]['content'];
75
+                $workingString  .= $tokens[ $i ][ 'content' ];
76 76
                 $lastStringToken = $i;
77 77
                 $i++;
78 78
             }
79 79
         }
80 80
 
81 81
         // Check if it's a double quoted string.
82
-        if (strpos($workingString, '"') === false) {
82
+        if ( strpos( $workingString, '"' ) === false ) {
83 83
             return;
84 84
         }
85 85
 
86 86
         // Make sure it's not a part of a string started in a previous line.
87 87
         // If it is, then we have already checked it.
88
-        if ($workingString[0] !== '"') {
88
+        if ( $workingString[ 0 ] !== '"' ) {
89 89
             return;
90 90
         }
91 91
 
92 92
         // The use of variables in double quoted strings is not allowed.
93
-        if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING) {
94
-            $stringTokens = token_get_all('<?php '.$workingString);
95
-            foreach ($stringTokens as $token) {
96
-                if (is_array($token) === true && $token[0] === T_VARIABLE) {
93
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_DOUBLE_QUOTED_STRING ) {
94
+            $stringTokens = token_get_all( '<?php ' . $workingString );
95
+            foreach ( $stringTokens as $token ) {
96
+                if ( is_array( $token ) === true && $token[ 0 ] === T_VARIABLE ) {
97 97
                     $error = 'Variable "%s" not allowed in double quoted string; use concatenation instead';
98
-                    $data  = array($token[1]);
99
-                    $phpcsFile->addError($error, $stackPtr, 'ContainsVar', $data);
98
+                    $data  = array( $token[ 1 ] );
99
+                    $phpcsFile->addError( $error, $stackPtr, 'ContainsVar', $data );
100 100
                 }
101 101
             }
102 102
 
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
                          '\'',
125 125
                         );
126 126
 
127
-        foreach ($allowedChars as $testChar) {
128
-            if (strpos($workingString, $testChar) !== false) {
127
+        foreach ( $allowedChars as $testChar ) {
128
+            if ( strpos( $workingString, $testChar ) !== false ) {
129 129
                 return;
130 130
             }
131 131
         }
132 132
 
133 133
         $error = 'String %s does not require double quotes; use single quotes instead';
134
-        $data  = array(str_replace("\n", '\n', $workingString));
135
-        $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'NotRequired', $data);
134
+        $data  = array( str_replace( "\n", '\n', $workingString ) );
135
+        $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'NotRequired', $data );
136 136
 
137
-        if ($fix === true) {
137
+        if ( $fix === true ) {
138 138
             $phpcsFile->fixer->beginChangeset();
139
-            $innerContent = substr($workingString, 1, -1);
140
-            $innerContent = str_replace('\"', '"', $innerContent);
141
-            $phpcsFile->fixer->replaceToken($stackPtr, "'$innerContent'");
142
-            while ($lastStringToken !== $stackPtr) {
143
-                $phpcsFile->fixer->replaceToken($lastStringToken, '');
139
+            $innerContent = substr( $workingString, 1, -1 );
140
+            $innerContent = str_replace( '\"', '"', $innerContent );
141
+            $phpcsFile->fixer->replaceToken( $stackPtr, "'$innerContent'" );
142
+            while ( $lastStringToken !== $stackPtr ) {
143
+                $phpcsFile->fixer->replaceToken( $lastStringToken, '' );
144 144
                 $lastStringToken--;
145 145
             }
146 146
 
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_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Squiz_Sniffs_Strings_DoubleQuoteUsageSniff 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(
42 40
                 T_CONSTANT_ENCAPSED_STRING,
43 41
                 T_DOUBLE_QUOTED_STRING,
@@ -55,8 +53,7 @@  discard block
 block discarded – undo
55 53
      *
56 54
      * @return void
57 55
      */
58
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
59
-    {
56
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
60 57
         $tokens = $phpcsFile->getTokens();
61 58
 
62 59
         // We are only interested in the first token in a multi-line string.
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php 3 patches
Indentation   +55 added lines, -55 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('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
17
+	 throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
18 18
 }
19 19
 
20 20
 /**
@@ -36,60 +36,60 @@  discard block
 block discarded – undo
36 36
 {
37 37
 
38 38
 
39
-    /**
40
-     * Constructs the test with the tokens it wishes to listen for.
41
-     */
42
-    public function __construct()
43
-    {
44
-        parent::__construct(array(T_CLASS), array(T_FUNCTION));
45
-
46
-    }//end __construct()
47
-
48
-
49
-    /**
50
-     * Processes this test, when one of its tokens is encountered.
51
-     *
52
-     * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned.
53
-     * @param int                  $stackPtr  The position of the current token in the
54
-     *                                        stack passed in $tokens.
55
-     * @param int                  $currScope A pointer to the start of the scope.
56
-     *
57
-     * @return void
58
-     */
59
-    public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
60
-    {
61
-        $tokens   = $phpcsFile->getTokens();
62
-        $function = $tokens[($stackPtr + 2)];
63
-
64
-        if ($function['code'] !== T_STRING) {
65
-            return;
66
-        }
67
-
68
-        $functionName = $function['content'];
69
-        $classOpener  = $tokens[$currScope]['scope_condition'];
70
-        $className    = $tokens[($classOpener + 2)]['content'];
71
-
72
-        $methodProps = $phpcsFile->getMethodProperties($stackPtr);
73
-
74
-        if ($methodProps['is_static'] === true) {
75
-            if (isset($tokens[$stackPtr]['scope_closer']) === false) {
76
-                // There is no scope opener or closer, so the function
77
-                // must be abstract.
78
-                return;
79
-            }
80
-
81
-            $thisUsage = $stackPtr;
82
-            while (($thisUsage = $phpcsFile->findNext(array(T_VARIABLE), ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) {
83
-                if ($thisUsage === false) {
84
-                    return;
85
-                }
86
-
87
-                $error = 'Usage of "$this" in static methods will cause runtime errors';
88
-                $phpcsFile->addError($error, $thisUsage, 'Found');
89
-            }
90
-        }//end if
91
-
92
-    }//end processTokenWithinScope()
39
+	 /**
40
+	  * Constructs the test with the tokens it wishes to listen for.
41
+	  */
42
+	 public function __construct()
43
+	 {
44
+		  parent::__construct(array(T_CLASS), array(T_FUNCTION));
45
+
46
+	 }//end __construct()
47
+
48
+
49
+	 /**
50
+	  * Processes this test, when one of its tokens is encountered.
51
+	  *
52
+	  * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned.
53
+	  * @param int                  $stackPtr  The position of the current token in the
54
+	  *                                        stack passed in $tokens.
55
+	  * @param int                  $currScope A pointer to the start of the scope.
56
+	  *
57
+	  * @return void
58
+	  */
59
+	 public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
60
+	 {
61
+		  $tokens   = $phpcsFile->getTokens();
62
+		  $function = $tokens[($stackPtr + 2)];
63
+
64
+		  if ($function['code'] !== T_STRING) {
65
+				return;
66
+		  }
67
+
68
+		  $functionName = $function['content'];
69
+		  $classOpener  = $tokens[$currScope]['scope_condition'];
70
+		  $className    = $tokens[($classOpener + 2)]['content'];
71
+
72
+		  $methodProps = $phpcsFile->getMethodProperties($stackPtr);
73
+
74
+		  if ($methodProps['is_static'] === true) {
75
+				if (isset($tokens[$stackPtr]['scope_closer']) === false) {
76
+					 // There is no scope opener or closer, so the function
77
+					 // must be abstract.
78
+					 return;
79
+				}
80
+
81
+				$thisUsage = $stackPtr;
82
+				while (($thisUsage = $phpcsFile->findNext(array(T_VARIABLE), ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) {
83
+					 if ($thisUsage === false) {
84
+						  return;
85
+					 }
86
+
87
+					 $error = 'Usage of "$this" in static methods will cause runtime errors';
88
+					 $phpcsFile->addError($error, $thisUsage, 'Found');
89
+				}
90
+		  }//end if
91
+
92
+	 }//end processTokenWithinScope()
93 93
 
94 94
 
95 95
 }//end class
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
  * @link      http://pear.php.net/package/PHP_CodeSniffer
14 14
  */
15 15
 
16
-if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
16
+if ( class_exists( 'PHP_CodeSniffer_Standards_AbstractScopeSniff', true ) === false ) {
17
+    throw new PHP_CodeSniffer_Exception( 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found' );
18 18
 }
19 19
 
20 20
 /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __construct()
43 43
     {
44
-        parent::__construct(array(T_CLASS), array(T_FUNCTION));
44
+        parent::__construct( array( T_CLASS ), array( T_FUNCTION ) );
45 45
 
46 46
     }//end __construct()
47 47
 
@@ -56,36 +56,36 @@  discard block
 block discarded – undo
56 56
      *
57 57
      * @return void
58 58
      */
59
-    public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
59
+    public function processTokenWithinScope( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope )
60 60
     {
61 61
         $tokens   = $phpcsFile->getTokens();
62
-        $function = $tokens[($stackPtr + 2)];
62
+        $function = $tokens[ ( $stackPtr + 2 ) ];
63 63
 
64
-        if ($function['code'] !== T_STRING) {
64
+        if ( $function[ 'code' ] !== T_STRING ) {
65 65
             return;
66 66
         }
67 67
 
68
-        $functionName = $function['content'];
69
-        $classOpener  = $tokens[$currScope]['scope_condition'];
70
-        $className    = $tokens[($classOpener + 2)]['content'];
68
+        $functionName = $function[ 'content' ];
69
+        $classOpener  = $tokens[ $currScope ][ 'scope_condition' ];
70
+        $className    = $tokens[ ( $classOpener + 2 ) ][ 'content' ];
71 71
 
72
-        $methodProps = $phpcsFile->getMethodProperties($stackPtr);
72
+        $methodProps = $phpcsFile->getMethodProperties( $stackPtr );
73 73
 
74
-        if ($methodProps['is_static'] === true) {
75
-            if (isset($tokens[$stackPtr]['scope_closer']) === false) {
74
+        if ( $methodProps[ 'is_static' ] === true ) {
75
+            if ( isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) {
76 76
                 // There is no scope opener or closer, so the function
77 77
                 // must be abstract.
78 78
                 return;
79 79
             }
80 80
 
81 81
             $thisUsage = $stackPtr;
82
-            while (($thisUsage = $phpcsFile->findNext(array(T_VARIABLE), ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) {
83
-                if ($thisUsage === false) {
82
+            while ( ( $thisUsage = $phpcsFile->findNext( array( T_VARIABLE ), ( $thisUsage + 1 ), $tokens[ $stackPtr ][ 'scope_closer' ], false, '$this' ) ) !== false ) {
83
+                if ( $thisUsage === false ) {
84 84
                     return;
85 85
                 }
86 86
 
87 87
                 $error = 'Usage of "$this" in static methods will cause runtime errors';
88
-                $phpcsFile->addError($error, $thisUsage, 'Found');
88
+                $phpcsFile->addError( $error, $thisUsage, 'Found' );
89 89
             }
90 90
         }//end if
91 91
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,15 +32,13 @@  discard block
 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_Scope_StaticThisUsageSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
36
-{
35
+class Squiz_Sniffs_Scope_StaticThisUsageSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff {
37 36
 
38 37
 
39 38
     /**
40 39
      * Constructs the test with the tokens it wishes to listen for.
41 40
      */
42
-    public function __construct()
43
-    {
41
+    public function __construct() {
44 42
         parent::__construct(array(T_CLASS), array(T_FUNCTION));
45 43
 
46 44
     }//end __construct()
@@ -56,8 +54,7 @@  discard block
 block discarded – undo
56 54
      *
57 55
      * @return void
58 56
      */
59
-    public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
60
-    {
57
+    public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) {
61 58
         $tokens   = $phpcsFile->getTokens();
62 59
         $function = $tokens[($stackPtr + 2)];
63 60
 
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php 3 patches
Indentation   +51 added lines, -51 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('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found');
17
+	 throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found');
18 18
 }
19 19
 
20 20
 /**
@@ -33,69 +33,69 @@  discard block
 block discarded – undo
33 33
 {
34 34
 
35 35
 
36
-    /**
37
-     * Processes the function tokens within the class.
38
-     *
39
-     * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
40
-     * @param int                  $stackPtr  The position where the token was found.
41
-     *
42
-     * @return void
43
-     */
44
-    protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
45
-    {
46
-        $tokens = $phpcsFile->getTokens();
36
+	 /**
37
+	  * Processes the function tokens within the class.
38
+	  *
39
+	  * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
40
+	  * @param int                  $stackPtr  The position where the token was found.
41
+	  *
42
+	  * @return void
43
+	  */
44
+	 protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
45
+	 {
46
+		  $tokens = $phpcsFile->getTokens();
47 47
 
48
-        $modifier = null;
49
-        for ($i = ($stackPtr - 1); $i > 0; $i--) {
50
-            if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
51
-                break;
52
-            } else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
53
-                $modifier = $i;
54
-                break;
55
-            }
56
-        }
48
+		  $modifier = null;
49
+		  for ($i = ($stackPtr - 1); $i > 0; $i--) {
50
+				if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
51
+					 break;
52
+				} else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
53
+					 $modifier = $i;
54
+					 break;
55
+				}
56
+		  }
57 57
 
58
-        if ($modifier === null) {
59
-            $error = 'Scope modifier not specified for member variable "%s"';
60
-            $data  = array($tokens[$stackPtr]['content']);
61
-            $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
62
-        }
58
+		  if ($modifier === null) {
59
+				$error = 'Scope modifier not specified for member variable "%s"';
60
+				$data  = array($tokens[$stackPtr]['content']);
61
+				$phpcsFile->addError($error, $stackPtr, 'Missing', $data);
62
+		  }
63 63
 
64
-    }//end processMemberVar()
64
+	 }//end processMemberVar()
65 65
 
66 66
 
67
-    /**
68
-     * Processes normal variables.
69
-     *
70
-     * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
71
-     * @param int                  $stackPtr  The position where the token was found.
72
-     *
73
-     * @return void
74
-     */
75
-    protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
76
-    {
77
-        /*
67
+	 /**
68
+	  * Processes normal variables.
69
+	  *
70
+	  * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
71
+	  * @param int                  $stackPtr  The position where the token was found.
72
+	  *
73
+	  * @return void
74
+	  */
75
+	 protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
76
+	 {
77
+		  /*
78 78
             We don't care about normal variables.
79 79
         */
80 80
 
81
-    }//end processVariable()
81
+	 }//end processVariable()
82 82
 
83 83
 
84
-    /**
85
-     * Processes variables in double quoted strings.
86
-     *
87
-     * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
88
-     * @param int                  $stackPtr  The position where the token was found.
89
-     *
90
-     * @return void
91
-     */
92
-    protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
93
-    {
94
-        /*
84
+	 /**
85
+	  * Processes variables in double quoted strings.
86
+	  *
87
+	  * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
88
+	  * @param int                  $stackPtr  The position where the token was found.
89
+	  *
90
+	  * @return void
91
+	  */
92
+	 protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
93
+	 {
94
+		  /*
95 95
             We don't care about normal variables.
96 96
         */
97 97
 
98
-    }//end processVariableInString()
98
+	 }//end processVariableInString()
99 99
 
100 100
 
101 101
 }//end class
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
  * @link      http://pear.php.net/package/PHP_CodeSniffer
14 14
  */
15 15
 
16
-if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found');
16
+if ( class_exists( 'PHP_CodeSniffer_Standards_AbstractVariableSniff', true ) === false ) {
17
+    throw new PHP_CodeSniffer_Exception( 'Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found' );
18 18
 }
19 19
 
20 20
 /**
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return void
43 43
      */
44
-    protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
44
+    protected function processMemberVar( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
45 45
     {
46 46
         $tokens = $phpcsFile->getTokens();
47 47
 
48 48
         $modifier = null;
49
-        for ($i = ($stackPtr - 1); $i > 0; $i--) {
50
-            if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
49
+        for ( $i = ( $stackPtr - 1 ); $i > 0; $i-- ) {
50
+            if ( $tokens[ $i ][ 'line' ] < $tokens[ $stackPtr ][ 'line' ] ) {
51 51
                 break;
52
-            } else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
52
+            } else if ( isset( PHP_CodeSniffer_Tokens::$scopeModifiers[ $tokens[ $i ][ 'code' ] ] ) === true ) {
53 53
                 $modifier = $i;
54 54
                 break;
55 55
             }
56 56
         }
57 57
 
58
-        if ($modifier === null) {
58
+        if ( $modifier === null ) {
59 59
             $error = 'Scope modifier not specified for member variable "%s"';
60
-            $data  = array($tokens[$stackPtr]['content']);
61
-            $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
60
+            $data  = array( $tokens[ $stackPtr ][ 'content' ] );
61
+            $phpcsFile->addError( $error, $stackPtr, 'Missing', $data );
62 62
         }
63 63
 
64 64
     }//end processMemberVar()
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return void
74 74
      */
75
-    protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
75
+    protected function processVariable( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
76 76
     {
77 77
         /*
78 78
             We don't care about normal variables.
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return void
91 91
      */
92
-    protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
92
+    protected function processVariableInString( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
93 93
     {
94 94
         /*
95 95
             We don't care about normal variables.
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 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_Scope_MemberVarScopeSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff
33
-{
32
+class Squiz_Sniffs_Scope_MemberVarScopeSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff {
34 33
 
35 34
 
36 35
     /**
@@ -41,8 +40,7 @@  discard block
 block discarded – undo
41 40
      *
42 41
      * @return void
43 42
      */
44
-    protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
45
-    {
43
+    protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
46 44
         $tokens = $phpcsFile->getTokens();
47 45
 
48 46
         $modifier = null;
@@ -72,8 +70,7 @@  discard block
 block discarded – undo
72 70
      *
73 71
      * @return void
74 72
      */
75
-    protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
76
-    {
73
+    protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
77 74
         /*
78 75
             We don't care about normal variables.
79 76
         */
@@ -89,8 +86,7 @@  discard block
 block discarded – undo
89 86
      *
90 87
      * @return void
91 88
      */
92
-    protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
93
-    {
89
+    protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
94 90
         /*
95 91
             We don't care about normal variables.
96 92
         */
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php 3 patches
Indentation   +44 added lines, -44 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('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
17
+	 throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
18 18
 }
19 19
 
20 20
 /**
@@ -33,57 +33,57 @@  discard block
 block discarded – undo
33 33
 {
34 34
 
35 35
 
36
-    /**
37
-     * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
38
-     */
39
-    public function __construct()
40
-    {
41
-        parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION));
36
+	 /**
37
+	  * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
38
+	  */
39
+	 public function __construct()
40
+	 {
41
+		  parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION));
42 42
 
43
-    }//end __construct()
43
+	 }//end __construct()
44 44
 
45 45
 
46
-    /**
47
-     * Processes the function tokens within the class.
48
-     *
49
-     * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
50
-     * @param int                  $stackPtr  The position where the token was found.
51
-     * @param int                  $currScope The current scope opener token.
52
-     *
53
-     * @return void
54
-     */
55
-    protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
56
-    {
57
-        $tokens = $phpcsFile->getTokens();
46
+	 /**
47
+	  * Processes the function tokens within the class.
48
+	  *
49
+	  * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
50
+	  * @param int                  $stackPtr  The position where the token was found.
51
+	  * @param int                  $currScope The current scope opener token.
52
+	  *
53
+	  * @return void
54
+	  */
55
+	 protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
56
+	 {
57
+		  $tokens = $phpcsFile->getTokens();
58 58
 
59
-        $methodName = $phpcsFile->getDeclarationName($stackPtr);
60
-        if ($methodName === null) {
61
-            // Ignore closures.
62
-            return;
63
-        }
59
+		  $methodName = $phpcsFile->getDeclarationName($stackPtr);
60
+		  if ($methodName === null) {
61
+				// Ignore closures.
62
+				return;
63
+		  }
64 64
 
65
-        if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) {
66
-            // Ignore nested functions.
67
-            return;
68
-        }
65
+		  if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) {
66
+				// Ignore nested functions.
67
+				return;
68
+		  }
69 69
 
70
-        $modifier = null;
71
-        for ($i = ($stackPtr - 1); $i > 0; $i--) {
72
-            if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
73
-                break;
74
-            } else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
75
-                $modifier = $i;
76
-                break;
77
-            }
78
-        }
70
+		  $modifier = null;
71
+		  for ($i = ($stackPtr - 1); $i > 0; $i--) {
72
+				if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
73
+					 break;
74
+				} else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
75
+					 $modifier = $i;
76
+					 break;
77
+				}
78
+		  }
79 79
 
80
-        if ($modifier === null) {
81
-            $error = 'Visibility must be declared on method "%s"';
82
-            $data  = array($methodName);
83
-            $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
84
-        }
80
+		  if ($modifier === null) {
81
+				$error = 'Visibility must be declared on method "%s"';
82
+				$data  = array($methodName);
83
+				$phpcsFile->addError($error, $stackPtr, 'Missing', $data);
84
+		  }
85 85
 
86
-    }//end processTokenWithinScope()
86
+	 }//end processTokenWithinScope()
87 87
 
88 88
 
89 89
 }//end class
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
  * @link      http://pear.php.net/package/PHP_CodeSniffer
14 14
  */
15 15
 
16
-if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
-    throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
16
+if ( class_exists( 'PHP_CodeSniffer_Standards_AbstractScopeSniff', true ) === false ) {
17
+    throw new PHP_CodeSniffer_Exception( 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found' );
18 18
 }
19 19
 
20 20
 /**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function __construct()
40 40
     {
41
-        parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION));
41
+        parent::__construct( array( T_CLASS, T_INTERFACE, T_TRAIT ), array( T_FUNCTION ) );
42 42
 
43 43
     }//end __construct()
44 44
 
@@ -52,35 +52,35 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
55
+    protected function processTokenWithinScope( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope )
56 56
     {
57 57
         $tokens = $phpcsFile->getTokens();
58 58
 
59
-        $methodName = $phpcsFile->getDeclarationName($stackPtr);
60
-        if ($methodName === null) {
59
+        $methodName = $phpcsFile->getDeclarationName( $stackPtr );
60
+        if ( $methodName === null ) {
61 61
             // Ignore closures.
62 62
             return;
63 63
         }
64 64
 
65
-        if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) {
65
+        if ( $phpcsFile->hasCondition( $stackPtr, T_FUNCTION ) === true ) {
66 66
             // Ignore nested functions.
67 67
             return;
68 68
         }
69 69
 
70 70
         $modifier = null;
71
-        for ($i = ($stackPtr - 1); $i > 0; $i--) {
72
-            if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
71
+        for ( $i = ( $stackPtr - 1 ); $i > 0; $i-- ) {
72
+            if ( $tokens[ $i ][ 'line' ] < $tokens[ $stackPtr ][ 'line' ] ) {
73 73
                 break;
74
-            } else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
74
+            } else if ( isset( PHP_CodeSniffer_Tokens::$scopeModifiers[ $tokens[ $i ][ 'code' ] ] ) === true ) {
75 75
                 $modifier = $i;
76 76
                 break;
77 77
             }
78 78
         }
79 79
 
80
-        if ($modifier === null) {
80
+        if ( $modifier === null ) {
81 81
             $error = 'Visibility must be declared on method "%s"';
82
-            $data  = array($methodName);
83
-            $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
82
+            $data  = array( $methodName );
83
+            $phpcsFile->addError( $error, $stackPtr, 'Missing', $data );
84 84
         }
85 85
 
86 86
     }//end processTokenWithinScope()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,15 +29,13 @@  discard block
 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_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
33
-{
32
+class Squiz_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff {
34 33
 
35 34
 
36 35
     /**
37 36
      * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
38 37
      */
39
-    public function __construct()
40
-    {
38
+    public function __construct() {
41 39
         parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION));
42 40
 
43 41
     }//end __construct()
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
      *
53 51
      * @return void
54 52
      */
55
-    protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
56
-    {
53
+    protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) {
57 54
         $tokens = $phpcsFile->getTokens();
58 55
 
59 56
         $methodName = $phpcsFile->getDeclarationName($stackPtr);
Please login to merge, or discard this patch.
php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php 3 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -28,83 +28,83 @@
 block discarded – undo
28 28
 class Squiz_Sniffs_CSS_OpacitySniff implements PHP_CodeSniffer_Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * A list of tokenizers this sniff supports.
33
-     *
34
-     * @var array
35
-     */
36
-    public $supportedTokenizers = array('CSS');
31
+	 /**
32
+	  * A list of tokenizers this sniff supports.
33
+	  *
34
+	  * @var array
35
+	  */
36
+	 public $supportedTokenizers = array('CSS');
37 37
 
38 38
 
39
-    /**
40
-     * Returns the token types that this sniff is interested in.
41
-     *
42
-     * @return int[]
43
-     */
44
-    public function register()
45
-    {
46
-        return array(T_STYLE);
39
+	 /**
40
+	  * Returns the token types that this sniff is interested in.
41
+	  *
42
+	  * @return int[]
43
+	  */
44
+	 public function register()
45
+	 {
46
+		  return array(T_STYLE);
47 47
 
48
-    }//end register()
48
+	 }//end register()
49 49
 
50 50
 
51
-    /**
52
-     * Processes the tokens that this sniff is interested in.
53
-     *
54
-     * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
55
-     * @param int                  $stackPtr  The position in the stack where
56
-     *                                        the token was found.
57
-     *
58
-     * @return void
59
-     */
60
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
-    {
62
-        $tokens = $phpcsFile->getTokens();
51
+	 /**
52
+	  * Processes the tokens that this sniff is interested in.
53
+	  *
54
+	  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
55
+	  * @param int                  $stackPtr  The position in the stack where
56
+	  *                                        the token was found.
57
+	  *
58
+	  * @return void
59
+	  */
60
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
+	 {
62
+		  $tokens = $phpcsFile->getTokens();
63 63
 
64
-        if ($tokens[$stackPtr]['content'] !== 'opacity') {
65
-            return;
66
-        }
64
+		  if ($tokens[$stackPtr]['content'] !== 'opacity') {
65
+				return;
66
+		  }
67 67
 
68
-        $next = $phpcsFile->findNext(array(T_COLON, T_WHITESPACE), ($stackPtr + 1), null, true);
68
+		  $next = $phpcsFile->findNext(array(T_COLON, T_WHITESPACE), ($stackPtr + 1), null, true);
69 69
 
70
-        if ($next === false
71
-            || ($tokens[$next]['code'] !== T_DNUMBER
72
-            && $tokens[$next]['code'] !== T_LNUMBER)
73
-        ) {
74
-            return;
75
-        }
70
+		  if ($next === false
71
+				|| ($tokens[$next]['code'] !== T_DNUMBER
72
+				&& $tokens[$next]['code'] !== T_LNUMBER)
73
+		  ) {
74
+				return;
75
+		  }
76 76
 
77
-        $value = $tokens[$next]['content'];
78
-        if ($tokens[$next]['code'] === T_LNUMBER) {
79
-            if ($value !== '0' && $value !== '1') {
80
-                $error = 'Opacity values must be between 0 and 1';
81
-                $phpcsFile->addError($error, $next, 'Invalid');
82
-            }
83
-        } else {
84
-            if (strlen($value) > 3) {
85
-                $error = 'Opacity values must have a single value after the decimal point';
86
-                $phpcsFile->addError($error, $next, 'DecimalPrecision');
87
-            } else if ($value === '0.0' || $value === '1.0') {
88
-                $error = 'Opacity value does not require decimal point; use %s instead';
89
-                $data  = array($value{0});
90
-                $fix   = $phpcsFile->addFixableError($error, $next, 'PointNotRequired', $data);
91
-                if ($fix === true) {
92
-                    $phpcsFile->fixer->replaceToken($next, $value{0});
93
-                }
94
-            } else if ($value{0} === '.') {
95
-                $error = 'Opacity values must not start with a decimal point; use 0%s instead';
96
-                $data  = array($value);
97
-                $fix   = $phpcsFile->addFixableError($error, $next, 'StartWithPoint', $data);
98
-                if ($fix === true) {
99
-                    $phpcsFile->fixer->replaceToken($next, '0'.$value);
100
-                }
101
-            } else if ($value{0} !== '0') {
102
-                $error = 'Opacity values must be between 0 and 1';
103
-                $phpcsFile->addError($error, $next, 'Invalid');
104
-            }//end if
105
-        }//end if
77
+		  $value = $tokens[$next]['content'];
78
+		  if ($tokens[$next]['code'] === T_LNUMBER) {
79
+				if ($value !== '0' && $value !== '1') {
80
+					 $error = 'Opacity values must be between 0 and 1';
81
+					 $phpcsFile->addError($error, $next, 'Invalid');
82
+				}
83
+		  } else {
84
+				if (strlen($value) > 3) {
85
+					 $error = 'Opacity values must have a single value after the decimal point';
86
+					 $phpcsFile->addError($error, $next, 'DecimalPrecision');
87
+				} else if ($value === '0.0' || $value === '1.0') {
88
+					 $error = 'Opacity value does not require decimal point; use %s instead';
89
+					 $data  = array($value{0});
90
+					 $fix   = $phpcsFile->addFixableError($error, $next, 'PointNotRequired', $data);
91
+					 if ($fix === true) {
92
+						  $phpcsFile->fixer->replaceToken($next, $value{0});
93
+					 }
94
+				} else if ($value{0} === '.') {
95
+					 $error = 'Opacity values must not start with a decimal point; use 0%s instead';
96
+					 $data  = array($value);
97
+					 $fix   = $phpcsFile->addFixableError($error, $next, 'StartWithPoint', $data);
98
+					 if ($fix === true) {
99
+						  $phpcsFile->fixer->replaceToken($next, '0'.$value);
100
+					 }
101
+				} else if ($value{0} !== '0') {
102
+					 $error = 'Opacity values must be between 0 and 1';
103
+					 $phpcsFile->addError($error, $next, 'Invalid');
104
+				}//end if
105
+		  }//end if
106 106
 
107
-    }//end process()
107
+	 }//end process()
108 108
 
109 109
 
110 110
 }//end class
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @var array
35 35
      */
36
-    public $supportedTokenizers = array('CSS');
36
+    public $supportedTokenizers = array( 'CSS' );
37 37
 
38 38
 
39 39
     /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function register()
45 45
     {
46
-        return array(T_STYLE);
46
+        return array( T_STYLE );
47 47
 
48 48
     }//end register()
49 49
 
@@ -57,50 +57,50 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return void
59 59
      */
60
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
60
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
61 61
     {
62 62
         $tokens = $phpcsFile->getTokens();
63 63
 
64
-        if ($tokens[$stackPtr]['content'] !== 'opacity') {
64
+        if ( $tokens[ $stackPtr ][ 'content' ] !== 'opacity' ) {
65 65
             return;
66 66
         }
67 67
 
68
-        $next = $phpcsFile->findNext(array(T_COLON, T_WHITESPACE), ($stackPtr + 1), null, true);
68
+        $next = $phpcsFile->findNext( array( T_COLON, T_WHITESPACE ), ( $stackPtr + 1 ), null, true );
69 69
 
70
-        if ($next === false
71
-            || ($tokens[$next]['code'] !== T_DNUMBER
72
-            && $tokens[$next]['code'] !== T_LNUMBER)
70
+        if ( $next === false
71
+            || ( $tokens[ $next ][ 'code' ] !== T_DNUMBER
72
+            && $tokens[ $next ][ 'code' ] !== T_LNUMBER )
73 73
         ) {
74 74
             return;
75 75
         }
76 76
 
77
-        $value = $tokens[$next]['content'];
78
-        if ($tokens[$next]['code'] === T_LNUMBER) {
79
-            if ($value !== '0' && $value !== '1') {
77
+        $value = $tokens[ $next ][ 'content' ];
78
+        if ( $tokens[ $next ][ 'code' ] === T_LNUMBER ) {
79
+            if ( $value !== '0' && $value !== '1' ) {
80 80
                 $error = 'Opacity values must be between 0 and 1';
81
-                $phpcsFile->addError($error, $next, 'Invalid');
81
+                $phpcsFile->addError( $error, $next, 'Invalid' );
82 82
             }
83 83
         } else {
84
-            if (strlen($value) > 3) {
84
+            if ( strlen( $value ) > 3 ) {
85 85
                 $error = 'Opacity values must have a single value after the decimal point';
86
-                $phpcsFile->addError($error, $next, 'DecimalPrecision');
87
-            } else if ($value === '0.0' || $value === '1.0') {
86
+                $phpcsFile->addError( $error, $next, 'DecimalPrecision' );
87
+            } else if ( $value === '0.0' || $value === '1.0' ) {
88 88
                 $error = 'Opacity value does not require decimal point; use %s instead';
89
-                $data  = array($value{0});
90
-                $fix   = $phpcsFile->addFixableError($error, $next, 'PointNotRequired', $data);
91
-                if ($fix === true) {
92
-                    $phpcsFile->fixer->replaceToken($next, $value{0});
89
+                $data  = array( $value{0});
90
+                $fix   = $phpcsFile->addFixableError( $error, $next, 'PointNotRequired', $data );
91
+                if ( $fix === true ) {
92
+                    $phpcsFile->fixer->replaceToken( $next, $value{0});
93 93
                 }
94
-            } else if ($value{0} === '.') {
94
+            } else if ( $value{0} === '.' ) {
95 95
                 $error = 'Opacity values must not start with a decimal point; use 0%s instead';
96
-                $data  = array($value);
97
-                $fix   = $phpcsFile->addFixableError($error, $next, 'StartWithPoint', $data);
98
-                if ($fix === true) {
99
-                    $phpcsFile->fixer->replaceToken($next, '0'.$value);
96
+                $data  = array( $value );
97
+                $fix   = $phpcsFile->addFixableError( $error, $next, 'StartWithPoint', $data );
98
+                if ( $fix === true ) {
99
+                    $phpcsFile->fixer->replaceToken( $next, '0' . $value );
100 100
                 }
101
-            } else if ($value{0} !== '0') {
101
+            } else if ( $value{0} !== '0' ) {
102 102
                 $error = 'Opacity values must be between 0 and 1';
103
-                $phpcsFile->addError($error, $next, 'Invalid');
103
+                $phpcsFile->addError( $error, $next, 'Invalid' );
104 104
             }//end if
105 105
         }//end if
106 106
 
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_CSS_OpacitySniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Squiz_Sniffs_CSS_OpacitySniff implements PHP_CodeSniffer_Sniff {
30 29
 
31 30
     /**
32 31
      * A list of tokenizers this sniff supports.
@@ -41,8 +40,7 @@  discard block
 block discarded – undo
41 40
      *
42 41
      * @return int[]
43 42
      */
44
-    public function register()
45
-    {
43
+    public function register() {
46 44
         return array(T_STYLE);
47 45
 
48 46
     }//end register()
@@ -57,8 +55,7 @@  discard block
 block discarded – undo
57 55
      *
58 56
      * @return void
59 57
      */
60
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
-    {
58
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
62 59
         $tokens = $phpcsFile->getTokens();
63 60
 
64 61
         if ($tokens[$stackPtr]['content'] !== 'opacity') {
Please login to merge, or discard this patch.
CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php 3 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -28,101 +28,101 @@
 block discarded – undo
28 28
 class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * A list of tokenizers this sniff supports.
33
-     *
34
-     * @var array
35
-     */
36
-    public $supportedTokenizers = array('CSS');
37
-
38
-
39
-    /**
40
-     * Returns the token types that this sniff is interested in.
41
-     *
42
-     * @return int[]
43
-     */
44
-    public function register()
45
-    {
46
-        return array(T_OPEN_TAG);
47
-
48
-    }//end register()
49
-
50
-
51
-    /**
52
-     * Processes the tokens that this sniff is interested in.
53
-     *
54
-     * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
55
-     * @param int                  $stackPtr  The position in the stack where
56
-     *                                        the token was found.
57
-     *
58
-     * @return void
59
-     */
60
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
-    {
62
-        $tokens = $phpcsFile->getTokens();
63
-
64
-        // Find the content of each class definition name.
65
-        $classNames = array();
66
-        $next       = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1));
67
-        if ($next === false) {
68
-            // No class definitions in the file.
69
-            return;
70
-        }
71
-
72
-        // Save the class names in a "scope",
73
-        // to prevent false positives with @media blocks.
74
-        $scope = 'main';
75
-
76
-        $find = array(
77
-                 T_CLOSE_CURLY_BRACKET,
78
-                 T_OPEN_CURLY_BRACKET,
79
-                 T_COMMENT,
80
-                 T_OPEN_TAG,
81
-                );
82
-
83
-        while ($next !== false) {
84
-            $prev = $phpcsFile->findPrevious($find, ($next - 1));
85
-
86
-            // Check if an inner block was closed.
87
-            $beforePrev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prev - 1), null, true);
88
-            if ($beforePrev !== false
89
-                && $tokens[$beforePrev]['code'] === T_CLOSE_CURLY_BRACKET
90
-            ) {
91
-                $scope = 'main';
92
-            }
93
-
94
-            // Create a sorted name for the class so we can compare classes
95
-            // even when the individual names are all over the place.
96
-            $name = '';
97
-            for ($i = ($prev + 1); $i < $next; $i++) {
98
-                $name .= $tokens[$i]['content'];
99
-            }
100
-
101
-            $name = trim($name);
102
-            $name = str_replace("\n", ' ', $name);
103
-            $name = preg_replace('|[\s]+|', ' ', $name);
104
-            $name = str_replace(', ', ',', $name);
105
-
106
-            $names = explode(',', $name);
107
-            sort($names);
108
-            $name = implode(',', $names);
109
-
110
-            if ($name{0} === '@') {
111
-                // Media block has its own "scope".
112
-                $scope = $name;
113
-            } else if (isset($classNames[$scope][$name]) === true) {
114
-                $first = $classNames[$scope][$name];
115
-                $error = 'Duplicate class definition found; first defined on line %s';
116
-                $data  = array($tokens[$first]['line']);
117
-                $phpcsFile->addError($error, $next, 'Found', $data);
118
-            } else {
119
-                $classNames[$scope][$name] = $next;
120
-            }
121
-
122
-            $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1));
123
-        }//end while
124
-
125
-    }//end process()
31
+	 /**
32
+	  * A list of tokenizers this sniff supports.
33
+	  *
34
+	  * @var array
35
+	  */
36
+	 public $supportedTokenizers = array('CSS');
37
+
38
+
39
+	 /**
40
+	  * Returns the token types that this sniff is interested in.
41
+	  *
42
+	  * @return int[]
43
+	  */
44
+	 public function register()
45
+	 {
46
+		  return array(T_OPEN_TAG);
47
+
48
+	 }//end register()
49
+
50
+
51
+	 /**
52
+	  * Processes the tokens that this sniff is interested in.
53
+	  *
54
+	  * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
55
+	  * @param int                  $stackPtr  The position in the stack where
56
+	  *                                        the token was found.
57
+	  *
58
+	  * @return void
59
+	  */
60
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
+	 {
62
+		  $tokens = $phpcsFile->getTokens();
63
+
64
+		  // Find the content of each class definition name.
65
+		  $classNames = array();
66
+		  $next       = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1));
67
+		  if ($next === false) {
68
+				// No class definitions in the file.
69
+				return;
70
+		  }
71
+
72
+		  // Save the class names in a "scope",
73
+		  // to prevent false positives with @media blocks.
74
+		  $scope = 'main';
75
+
76
+		  $find = array(
77
+					  T_CLOSE_CURLY_BRACKET,
78
+					  T_OPEN_CURLY_BRACKET,
79
+					  T_COMMENT,
80
+					  T_OPEN_TAG,
81
+					 );
82
+
83
+		  while ($next !== false) {
84
+				$prev = $phpcsFile->findPrevious($find, ($next - 1));
85
+
86
+				// Check if an inner block was closed.
87
+				$beforePrev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prev - 1), null, true);
88
+				if ($beforePrev !== false
89
+					 && $tokens[$beforePrev]['code'] === T_CLOSE_CURLY_BRACKET
90
+				) {
91
+					 $scope = 'main';
92
+				}
93
+
94
+				// Create a sorted name for the class so we can compare classes
95
+				// even when the individual names are all over the place.
96
+				$name = '';
97
+				for ($i = ($prev + 1); $i < $next; $i++) {
98
+					 $name .= $tokens[$i]['content'];
99
+				}
100
+
101
+				$name = trim($name);
102
+				$name = str_replace("\n", ' ', $name);
103
+				$name = preg_replace('|[\s]+|', ' ', $name);
104
+				$name = str_replace(', ', ',', $name);
105
+
106
+				$names = explode(',', $name);
107
+				sort($names);
108
+				$name = implode(',', $names);
109
+
110
+				if ($name{0} === '@') {
111
+					 // Media block has its own "scope".
112
+					 $scope = $name;
113
+				} else if (isset($classNames[$scope][$name]) === true) {
114
+					 $first = $classNames[$scope][$name];
115
+					 $error = 'Duplicate class definition found; first defined on line %s';
116
+					 $data  = array($tokens[$first]['line']);
117
+					 $phpcsFile->addError($error, $next, 'Found', $data);
118
+				} else {
119
+					 $classNames[$scope][$name] = $next;
120
+				}
121
+
122
+				$next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1));
123
+		  }//end while
124
+
125
+	 }//end process()
126 126
 
127 127
 
128 128
 }//end class
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @var array
35 35
      */
36
-    public $supportedTokenizers = array('CSS');
36
+    public $supportedTokenizers = array( 'CSS' );
37 37
 
38 38
 
39 39
     /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function register()
45 45
     {
46
-        return array(T_OPEN_TAG);
46
+        return array( T_OPEN_TAG );
47 47
 
48 48
     }//end register()
49 49
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return void
59 59
      */
60
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
60
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
61 61
     {
62 62
         $tokens = $phpcsFile->getTokens();
63 63
 
64 64
         // Find the content of each class definition name.
65 65
         $classNames = array();
66
-        $next       = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1));
67
-        if ($next === false) {
66
+        $next       = $phpcsFile->findNext( T_OPEN_CURLY_BRACKET, ( $stackPtr + 1 ) );
67
+        if ( $next === false ) {
68 68
             // No class definitions in the file.
69 69
             return;
70 70
         }
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
                  T_OPEN_TAG,
81 81
                 );
82 82
 
83
-        while ($next !== false) {
84
-            $prev = $phpcsFile->findPrevious($find, ($next - 1));
83
+        while ( $next !== false ) {
84
+            $prev = $phpcsFile->findPrevious( $find, ( $next - 1 ) );
85 85
 
86 86
             // Check if an inner block was closed.
87
-            $beforePrev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prev - 1), null, true);
88
-            if ($beforePrev !== false
89
-                && $tokens[$beforePrev]['code'] === T_CLOSE_CURLY_BRACKET
87
+            $beforePrev = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $prev - 1 ), null, true );
88
+            if ( $beforePrev !== false
89
+                && $tokens[ $beforePrev ][ 'code' ] === T_CLOSE_CURLY_BRACKET
90 90
             ) {
91 91
                 $scope = 'main';
92 92
             }
@@ -94,32 +94,32 @@  discard block
 block discarded – undo
94 94
             // Create a sorted name for the class so we can compare classes
95 95
             // even when the individual names are all over the place.
96 96
             $name = '';
97
-            for ($i = ($prev + 1); $i < $next; $i++) {
98
-                $name .= $tokens[$i]['content'];
97
+            for ( $i = ( $prev + 1 ); $i < $next; $i++ ) {
98
+                $name .= $tokens[ $i ][ 'content' ];
99 99
             }
100 100
 
101
-            $name = trim($name);
102
-            $name = str_replace("\n", ' ', $name);
103
-            $name = preg_replace('|[\s]+|', ' ', $name);
104
-            $name = str_replace(', ', ',', $name);
101
+            $name = trim( $name );
102
+            $name = str_replace( "\n", ' ', $name );
103
+            $name = preg_replace( '|[\s]+|', ' ', $name );
104
+            $name = str_replace( ', ', ',', $name );
105 105
 
106
-            $names = explode(',', $name);
107
-            sort($names);
108
-            $name = implode(',', $names);
106
+            $names = explode( ',', $name );
107
+            sort( $names );
108
+            $name = implode( ',', $names );
109 109
 
110
-            if ($name{0} === '@') {
110
+            if ( $name{0} === '@' ) {
111 111
                 // Media block has its own "scope".
112 112
                 $scope = $name;
113
-            } else if (isset($classNames[$scope][$name]) === true) {
114
-                $first = $classNames[$scope][$name];
113
+            } else if ( isset( $classNames[ $scope ][ $name ] ) === true ) {
114
+                $first = $classNames[ $scope ][ $name ];
115 115
                 $error = 'Duplicate class definition found; first defined on line %s';
116
-                $data  = array($tokens[$first]['line']);
117
-                $phpcsFile->addError($error, $next, 'Found', $data);
116
+                $data  = array( $tokens[ $first ][ 'line' ] );
117
+                $phpcsFile->addError( $error, $next, 'Found', $data );
118 118
             } else {
119
-                $classNames[$scope][$name] = $next;
119
+                $classNames[ $scope ][ $name ] = $next;
120 120
             }
121 121
 
122
-            $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1));
122
+            $next = $phpcsFile->findNext( T_OPEN_CURLY_BRACKET, ( $next + 1 ) );
123 123
         }//end while
124 124
 
125 125
     }//end process()
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_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_Sniff {
30 29
 
31 30
     /**
32 31
      * A list of tokenizers this sniff supports.
@@ -41,8 +40,7 @@  discard block
 block discarded – undo
41 40
      *
42 41
      * @return int[]
43 42
      */
44
-    public function register()
45
-    {
43
+    public function register() {
46 44
         return array(T_OPEN_TAG);
47 45
 
48 46
     }//end register()
@@ -57,8 +55,7 @@  discard block
 block discarded – undo
57 55
      *
58 56
      * @return void
59 57
      */
60
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
-    {
58
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
62 59
         $tokens = $phpcsFile->getTokens();
63 60
 
64 61
         // Find the content of each class definition name.
Please login to merge, or discard this patch.