Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -126,24 +126,24 @@  discard block
 block discarded – undo
126 126
 		 * The return values skip to the end of the array.
127 127
 		 * This prevents the sniff "hanging" on very long configuration arrays.
128 128
 		 */
129
-		if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['bracket_closer'] ) ) {
130
-			return $this->tokens[ $stackPtr ]['bracket_closer'];
131
-		} elseif ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['parenthesis_closer'] ) ) {
132
-			return $this->tokens[ $stackPtr ]['parenthesis_closer'];
129
+		if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ][ 'code' ] && isset( $this->tokens[ $stackPtr ][ 'bracket_closer' ] ) ) {
130
+			return $this->tokens[ $stackPtr ][ 'bracket_closer' ];
131
+		} elseif ( \T_ARRAY === $this->tokens[ $stackPtr ][ 'code' ] && isset( $this->tokens[ $stackPtr ][ 'parenthesis_closer' ] ) ) {
132
+			return $this->tokens[ $stackPtr ][ 'parenthesis_closer' ];
133 133
 		}
134 134
 
135 135
 		/*
136 136
 		 * Deal with misspellings in class/interface/trait names.
137 137
 		 * These are not auto-fixable, but need the attention of a developer.
138 138
 		 */
139
-		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
139
+		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ][ 'code' ] ] ) ) {
140 140
 			$classname = $this->phpcsFile->getDeclarationName( $stackPtr );
141 141
 			if ( empty( $classname ) ) {
142 142
 				return;
143 143
 			}
144 144
 
145 145
 			if ( preg_match_all( self::WP_CLASSNAME_REGEX, $classname, $matches, \PREG_PATTERN_ORDER ) > 0 ) {
146
-				$mispelled = $this->retrieve_misspellings( $matches[1] );
146
+				$mispelled = $this->retrieve_misspellings( $matches[ 1 ] );
147 147
 
148 148
 				if ( ! empty( $mispelled ) ) {
149 149
 					$this->phpcsFile->addWarning(
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 		 */
164 164
 
165 165
 		// Ignore content of docblock @link tags.
166
-		if ( \T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ]['code']
167
-			|| \T_DOC_COMMENT === $this->tokens[ $stackPtr ]['code']
166
+		if ( \T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ][ 'code' ]
167
+			|| \T_DOC_COMMENT === $this->tokens[ $stackPtr ][ 'code' ]
168 168
 		) {
169 169
 
170 170
 			$comment_start = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_OPEN_TAG, ( $stackPtr - 1 ) );
171 171
 			if ( false !== $comment_start ) {
172 172
 				$comment_tag = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_TAG, ( $stackPtr - 1 ), $comment_start );
173
-				if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ]['content'] ) {
173
+				if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ][ 'content' ] ) {
174 174
 					// @link tag, so ignore.
175 175
 					return;
176 176
 				}
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 		}
179 179
 
180 180
 		// Ignore any text strings which are array keys `$var['key']` as this is a false positive in 80% of all cases.
181
-		if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ]['code'] ) {
181
+		if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) {
182 182
 			$prevToken = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
183
-			if ( false !== $prevToken && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ]['code'] ) {
183
+			if ( false !== $prevToken && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ][ 'code' ] ) {
184 184
 				$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
185
-				if ( false !== $nextToken && \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
185
+				if ( false !== $nextToken && \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ][ 'code' ] ) {
186 186
 					return;
187 187
 				}
188 188
 			}
@@ -202,44 +202,44 @@  discard block
 block discarded – undo
202 202
 			\T_OPEN_CURLY_BRACKET,
203 203
 		);
204 204
 		$maybe_const = $this->phpcsFile->findPrevious( $stop_points, ( $stackPtr - 1 ) );
205
-		if ( false !== $maybe_const && \T_CONST === $this->tokens[ $maybe_const ]['code'] ) {
205
+		if ( false !== $maybe_const && \T_CONST === $this->tokens[ $maybe_const ][ 'code' ] ) {
206 206
 			return;
207 207
 		}
208 208
 
209
-		$content = $this->tokens[ $stackPtr ]['content'];
209
+		$content = $this->tokens[ $stackPtr ][ 'content' ];
210 210
 
211 211
 		if ( preg_match_all( self::WP_REGEX, $content, $matches, ( \PREG_PATTERN_ORDER | \PREG_OFFSET_CAPTURE ) ) > 0 ) {
212 212
 			/*
213 213
 			 * Prevent some typical false positives.
214 214
 			 */
215
-			if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
215
+			if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ][ 'code' ] ] ) ) {
216 216
 				$offset = 0;
217
-				foreach ( $matches[1] as $key => $match_data ) {
218
-					$next_offset = ( $match_data[1] + \strlen( $match_data[0] ) );
217
+				foreach ( $matches[ 1 ] as $key => $match_data ) {
218
+					$next_offset = ( $match_data[ 1 ] + \strlen( $match_data[ 0 ] ) );
219 219
 
220 220
 					// Prevent matches on part of a URL.
221
-					if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[0], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
222
-						unset( $matches[1][ $key ] );
223
-					} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[0], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
221
+					if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[ 0 ], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
222
+						unset( $matches[ 1 ][ $key ] );
223
+					} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[ 0 ], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
224 224
 						// Prevent matches on html attributes like: `value="wordpress"`.
225
-						unset( $matches[1][ $key ] );
226
-					} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[0], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
225
+						unset( $matches[ 1 ][ $key ] );
226
+					} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[ 0 ], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
227 227
 						// Prevent matches on xpath queries and such: `\'wordpress\'`.
228
-						unset( $matches[1][ $key ] );
229
-					} elseif ( preg_match( '`(?:\?|&amp;|&)[a-z0-9_]+=' . preg_quote( $match_data[0], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
228
+						unset( $matches[ 1 ][ $key ] );
229
+					} elseif ( preg_match( '`(?:\?|&amp;|&)[a-z0-9_]+=' . preg_quote( $match_data[ 0 ], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
230 230
 						// Prevent matches on url query strings: `?something=wordpress`.
231
-						unset( $matches[1][ $key ] );
231
+						unset( $matches[ 1 ][ $key ] );
232 232
 					}
233 233
 
234 234
 					$offset = $next_offset;
235 235
 				}
236 236
 
237
-				if ( empty( $matches[1] ) ) {
237
+				if ( empty( $matches[ 1 ] ) ) {
238 238
 					return;
239 239
 				}
240 240
 			}
241 241
 
242
-			$mispelled = $this->retrieve_misspellings( $matches[1] );
242
+			$mispelled = $this->retrieve_misspellings( $matches[ 1 ] );
243 243
 
244 244
 			if ( empty( $mispelled ) ) {
245 245
 				return;
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 			if ( true === $fix ) {
259 259
 				// Apply fixes based on offset to ensure we don't replace false positives.
260 260
 				$replacement = $content;
261
-				foreach ( $matches[1] as $match ) {
262
-					$replacement = substr_replace( $replacement, 'WordPress', $match[1], \strlen( $match[0] ) );
261
+				foreach ( $matches[ 1 ] as $match ) {
262
+					$replacement = substr_replace( $replacement, 'WordPress', $match[ 1 ], \strlen( $match[ 0 ] ) );
263 263
 				}
264 264
 
265 265
 				$this->phpcsFile->fixer->replaceToken( $stackPtr, $replacement );
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 		foreach ( $match_stack as $match ) {
279 279
 			// Deal with multi-dimensional arrays when capturing offset.
280 280
 			if ( \is_array( $match ) ) {
281
-				$match = $match[0];
281
+				$match = $match[ 0 ];
282 282
 			}
283 283
 
284 284
 			if ( 'WordPress' !== $match ) {
285
-				$mispelled[] = $match;
285
+				$mispelled[ ] = $match;
286 286
 			}
287 287
 		}
288 288
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@
 block discarded – undo
270 270
 	/**
271 271
 	 * Retrieve a list of misspellings based on an array of matched variations on the target word.
272 272
 	 *
273
-	 * @param array $match_stack Array of matched variations of the target word.
273
+	 * @param string[] $match_stack Array of matched variations of the target word.
274 274
 	 * @return array Array containing only the misspelled variants.
275 275
 	 */
276 276
 	protected function retrieve_misspellings( $match_stack ) {
Please login to merge, or discard this patch.
wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 
142 142
 		$token = $this->tokens[ $stackPtr ];
143 143
 
144
-		if ( \T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
144
+		if ( \T_CLOSE_SQUARE_BRACKET === $token[ 'code' ] ) {
145 145
 			$equal = $this->phpcsFile->findNext( \T_WHITESPACE, ( $stackPtr + 1 ), null, true );
146
-			if ( \T_EQUAL !== $this->tokens[ $equal ]['code'] ) {
146
+			if ( \T_EQUAL !== $this->tokens[ $equal ][ 'code' ] ) {
147 147
 				return; // This is not an assignment!
148 148
 			}
149 149
 		}
@@ -156,28 +156,28 @@  discard block
 block discarded – undo
156 156
 		 * $foo = array( 'bar' => 'taz' );
157 157
 		 * $foo['bar'] = $taz;
158 158
 		 */
159
-		if ( \in_array( $token['code'], array( \T_CLOSE_SQUARE_BRACKET, \T_DOUBLE_ARROW ), true ) ) {
159
+		if ( \in_array( $token[ 'code' ], array( \T_CLOSE_SQUARE_BRACKET, \T_DOUBLE_ARROW ), true ) ) {
160 160
 			$operator = $stackPtr; // T_DOUBLE_ARROW.
161
-			if ( \T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
161
+			if ( \T_CLOSE_SQUARE_BRACKET === $token[ 'code' ] ) {
162 162
 				$operator = $this->phpcsFile->findNext( \T_EQUAL, ( $stackPtr + 1 ) );
163 163
 			}
164 164
 
165 165
 			$keyIdx = $this->phpcsFile->findPrevious( array( \T_WHITESPACE, \T_CLOSE_SQUARE_BRACKET ), ( $operator - 1 ), null, true );
166
-			if ( ! is_numeric( $this->tokens[ $keyIdx ]['content'] ) ) {
167
-				$key            = $this->strip_quotes( $this->tokens[ $keyIdx ]['content'] );
166
+			if ( ! is_numeric( $this->tokens[ $keyIdx ][ 'content' ] ) ) {
167
+				$key            = $this->strip_quotes( $this->tokens[ $keyIdx ][ 'content' ] );
168 168
 				$valStart       = $this->phpcsFile->findNext( array( \T_WHITESPACE ), ( $operator + 1 ), null, true );
169 169
 				$valEnd         = $this->phpcsFile->findNext( array( \T_COMMA, \T_SEMICOLON ), ( $valStart + 1 ), null, false, null, true );
170 170
 				$val            = $this->phpcsFile->getTokensAsString( $valStart, ( $valEnd - $valStart ) );
171 171
 				$val            = $this->strip_quotes( $val );
172
-				$inst[ $key ][] = array( $val, $token['line'] );
172
+				$inst[ $key ][ ] = array( $val, $token[ 'line' ] );
173 173
 			}
174
-		} elseif ( \in_array( $token['code'], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) {
174
+		} elseif ( \in_array( $token[ 'code' ], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) {
175 175
 			// $foo = 'bar=taz&other=thing';
176
-			if ( preg_match_all( '#(?:^|&)([a-z_]+)=([^&]*)#i', $this->strip_quotes( $token['content'] ), $matches ) <= 0 ) {
176
+			if ( preg_match_all( '#(?:^|&)([a-z_]+)=([^&]*)#i', $this->strip_quotes( $token[ 'content' ] ), $matches ) <= 0 ) {
177 177
 				return; // No assignments here, nothing to check.
178 178
 			}
179
-			foreach ( $matches[1] as $i => $_k ) {
180
-				$inst[ $_k ][] = array( $matches[2][ $i ], $token['line'] );
179
+			foreach ( $matches[ 1 ] as $i => $_k ) {
180
+				$inst[ $_k ][ ] = array( $matches[ 2 ][ $i ], $token[ 'line' ] );
181 181
 			}
182 182
 		}
183 183
 
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 				continue;
192 192
 			}
193 193
 
194
-			$callback = ( isset( $group['callback'] ) && is_callable( $group['callback'] ) ) ? $group['callback'] : array( $this, 'callback' );
194
+			$callback = ( isset( $group[ 'callback' ] ) && is_callable( $group[ 'callback' ] ) ) ? $group[ 'callback' ] : array( $this, 'callback' );
195 195
 
196 196
 			foreach ( $inst as $key => $assignments ) {
197 197
 				foreach ( $assignments as $occurance ) {
198 198
 					list( $val, $line ) = $occurance;
199 199
 
200
-					if ( ! \in_array( $key, $group['keys'], true ) ) {
200
+					if ( ! \in_array( $key, $group[ 'keys' ], true ) ) {
201 201
 						continue;
202 202
 					}
203 203
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 					if ( ! isset( $output ) || false === $output ) {
207 207
 						continue;
208 208
 					} elseif ( true === $output ) {
209
-						$message = $group['message'];
209
+						$message = $group[ 'message' ];
210 210
 					} else {
211 211
 						$message = $output;
212 212
 					}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 					$this->addMessage(
215 215
 						$message,
216 216
 						$stackPtr,
217
-						( 'error' === $group['type'] ),
217
+						( 'error' === $group[ 'type' ] ),
218 218
 						$this->string_to_errorcode( $groupName . '_' . $key ),
219 219
 						array( $key, $val )
220 220
 					);
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/AbstractComplexVersionSniff.php 3 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -22,111 +22,111 @@
 block discarded – undo
22 22
 {
23 23
 
24 24
 
25
-    /**
26
-     * Handle the retrieval of relevant information and - if necessary - throwing of an
27
-     * error/warning for an item.
28
-     *
29
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
30
-     * @param int                   $stackPtr  The position of the relevant token in
31
-     *                                         the stack.
32
-     * @param array                 $itemInfo  Base information about the item.
33
-     *
34
-     * @return void
35
-     */
36
-    public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
37
-    {
38
-        $itemArray = $this->getItemArray($itemInfo);
39
-        $errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
40
-
41
-        if ($this->shouldThrowError($errorInfo) === true) {
42
-            $this->addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
43
-        }
44
-    }
45
-
46
-
47
-    /**
48
-     * Determine whether an error/warning should be thrown for an item based on collected information.
49
-     *
50
-     * @param array $errorInfo Detail information about an item.
51
-     *
52
-     * @return bool
53
-     */
54
-    abstract protected function shouldThrowError(array $errorInfo);
55
-
56
-
57
-    /**
58
-     * Get an array of the non-PHP-version array keys used in a sub-array.
59
-     *
60
-     * @return array
61
-     */
62
-    protected function getNonVersionArrayKeys()
63
-    {
64
-        return array();
65
-    }
66
-
67
-
68
-    /**
69
-     * Retrieve a subset of an item array containing only the array keys which
70
-     * contain PHP version information.
71
-     *
72
-     * @param array $itemArray Version and other information about an item.
73
-     *
74
-     * @return array Array with only the version information.
75
-     */
76
-    protected function getVersionArray(array $itemArray)
77
-    {
78
-        return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys()));
79
-    }
80
-
81
-
82
-    /**
83
-     * Get the item name to be used for the creation of the error code and in the error message.
84
-     *
85
-     * @param array $itemInfo  Base information about the item.
86
-     * @param array $errorInfo Detail information about an item.
87
-     *
88
-     * @return string
89
-     */
90
-    protected function getItemName(array $itemInfo, array $errorInfo)
91
-    {
92
-        return $itemInfo['name'];
93
-    }
94
-
95
-
96
-    /**
97
-     * Get the error message template for a specific sniff.
98
-     *
99
-     * @return string
100
-     */
101
-    abstract protected function getErrorMsgTemplate();
102
-
103
-
104
-    /**
105
-     * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
106
-     *
107
-     * @param string $error     The error message which was created.
108
-     * @param array  $itemInfo  Base information about the item this error message applies to.
109
-     * @param array  $errorInfo Detail information about an item this error message applies to.
110
-     *
111
-     * @return string
112
-     */
113
-    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
114
-    {
115
-        return $error;
116
-    }
117
-
118
-
119
-    /**
120
-     * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
121
-     *
122
-     * @param array $data      The error data array which was created.
123
-     * @param array $itemInfo  Base information about the item this error message applies to.
124
-     * @param array $errorInfo Detail information about an item this error message applies to.
125
-     *
126
-     * @return array
127
-     */
128
-    protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
129
-    {
130
-        return $data;
131
-    }
25
+	/**
26
+	 * Handle the retrieval of relevant information and - if necessary - throwing of an
27
+	 * error/warning for an item.
28
+	 *
29
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
30
+	 * @param int                   $stackPtr  The position of the relevant token in
31
+	 *                                         the stack.
32
+	 * @param array                 $itemInfo  Base information about the item.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
37
+	{
38
+		$itemArray = $this->getItemArray($itemInfo);
39
+		$errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
40
+
41
+		if ($this->shouldThrowError($errorInfo) === true) {
42
+			$this->addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
43
+		}
44
+	}
45
+
46
+
47
+	/**
48
+	 * Determine whether an error/warning should be thrown for an item based on collected information.
49
+	 *
50
+	 * @param array $errorInfo Detail information about an item.
51
+	 *
52
+	 * @return bool
53
+	 */
54
+	abstract protected function shouldThrowError(array $errorInfo);
55
+
56
+
57
+	/**
58
+	 * Get an array of the non-PHP-version array keys used in a sub-array.
59
+	 *
60
+	 * @return array
61
+	 */
62
+	protected function getNonVersionArrayKeys()
63
+	{
64
+		return array();
65
+	}
66
+
67
+
68
+	/**
69
+	 * Retrieve a subset of an item array containing only the array keys which
70
+	 * contain PHP version information.
71
+	 *
72
+	 * @param array $itemArray Version and other information about an item.
73
+	 *
74
+	 * @return array Array with only the version information.
75
+	 */
76
+	protected function getVersionArray(array $itemArray)
77
+	{
78
+		return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys()));
79
+	}
80
+
81
+
82
+	/**
83
+	 * Get the item name to be used for the creation of the error code and in the error message.
84
+	 *
85
+	 * @param array $itemInfo  Base information about the item.
86
+	 * @param array $errorInfo Detail information about an item.
87
+	 *
88
+	 * @return string
89
+	 */
90
+	protected function getItemName(array $itemInfo, array $errorInfo)
91
+	{
92
+		return $itemInfo['name'];
93
+	}
94
+
95
+
96
+	/**
97
+	 * Get the error message template for a specific sniff.
98
+	 *
99
+	 * @return string
100
+	 */
101
+	abstract protected function getErrorMsgTemplate();
102
+
103
+
104
+	/**
105
+	 * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
106
+	 *
107
+	 * @param string $error     The error message which was created.
108
+	 * @param array  $itemInfo  Base information about the item this error message applies to.
109
+	 * @param array  $errorInfo Detail information about an item this error message applies to.
110
+	 *
111
+	 * @return string
112
+	 */
113
+	protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
114
+	{
115
+		return $error;
116
+	}
117
+
118
+
119
+	/**
120
+	 * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
121
+	 *
122
+	 * @param array $data      The error data array which was created.
123
+	 * @param array $itemInfo  Base information about the item this error message applies to.
124
+	 * @param array $errorInfo Detail information about an item this error message applies to.
125
+	 *
126
+	 * @return array
127
+	 */
128
+	protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
129
+	{
130
+		return $data;
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @return void
35 35
      */
36
-    public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
36
+    public function handleFeature( File $phpcsFile, $stackPtr, array $itemInfo )
37 37
     {
38
-        $itemArray = $this->getItemArray($itemInfo);
39
-        $errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
38
+        $itemArray = $this->getItemArray( $itemInfo );
39
+        $errorInfo = $this->getErrorInfo( $itemArray, $itemInfo );
40 40
 
41
-        if ($this->shouldThrowError($errorInfo) === true) {
42
-            $this->addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
41
+        if ( $this->shouldThrowError( $errorInfo ) === true ) {
42
+            $this->addError( $phpcsFile, $stackPtr, $itemInfo, $errorInfo );
43 43
         }
44 44
     }
45 45
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return bool
53 53
      */
54
-    abstract protected function shouldThrowError(array $errorInfo);
54
+    abstract protected function shouldThrowError( array $errorInfo );
55 55
 
56 56
 
57 57
     /**
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @return array Array with only the version information.
75 75
      */
76
-    protected function getVersionArray(array $itemArray)
76
+    protected function getVersionArray( array $itemArray )
77 77
     {
78
-        return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys()));
78
+        return array_diff_key( $itemArray, array_flip( $this->getNonVersionArrayKeys() ) );
79 79
     }
80 80
 
81 81
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
      *
88 88
      * @return string
89 89
      */
90
-    protected function getItemName(array $itemInfo, array $errorInfo)
90
+    protected function getItemName( array $itemInfo, array $errorInfo )
91 91
     {
92
-        return $itemInfo['name'];
92
+        return $itemInfo[ 'name' ];
93 93
     }
94 94
 
95 95
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @return string
112 112
      */
113
-    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
113
+    protected function filterErrorMsg( $error, array $itemInfo, array $errorInfo )
114 114
     {
115 115
         return $error;
116 116
     }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      *
126 126
      * @return array
127 127
      */
128
-    protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
128
+    protected function filterErrorData( array $data, array $itemInfo, array $errorInfo )
129 129
     {
130 130
         return $data;
131 131
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@  discard block
 block discarded – undo
18 18
  * @package  PHPCompatibility
19 19
  * @author   Juliette Reinders Folmer <[email protected]>
20 20
  */
21
-abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface
22
-{
21
+abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface {
23 22
 
24 23
 
25 24
     /**
@@ -33,8 +32,7 @@  discard block
 block discarded – undo
33 32
      *
34 33
      * @return void
35 34
      */
36
-    public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
37
-    {
35
+    public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) {
38 36
         $itemArray = $this->getItemArray($itemInfo);
39 37
         $errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
40 38
 
@@ -59,8 +57,7 @@  discard block
 block discarded – undo
59 57
      *
60 58
      * @return array
61 59
      */
62
-    protected function getNonVersionArrayKeys()
63
-    {
60
+    protected function getNonVersionArrayKeys() {
64 61
         return array();
65 62
     }
66 63
 
@@ -73,8 +70,7 @@  discard block
 block discarded – undo
73 70
      *
74 71
      * @return array Array with only the version information.
75 72
      */
76
-    protected function getVersionArray(array $itemArray)
77
-    {
73
+    protected function getVersionArray(array $itemArray) {
78 74
         return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys()));
79 75
     }
80 76
 
@@ -87,8 +83,7 @@  discard block
 block discarded – undo
87 83
      *
88 84
      * @return string
89 85
      */
90
-    protected function getItemName(array $itemInfo, array $errorInfo)
91
-    {
86
+    protected function getItemName(array $itemInfo, array $errorInfo) {
92 87
         return $itemInfo['name'];
93 88
     }
94 89
 
@@ -110,8 +105,7 @@  discard block
 block discarded – undo
110 105
      *
111 106
      * @return string
112 107
      */
113
-    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
114
-    {
108
+    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) {
115 109
         return $error;
116 110
     }
117 111
 
@@ -125,8 +119,7 @@  discard block
 block discarded – undo
125 119
      *
126 120
      * @return array
127 121
      */
128
-    protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
129
-    {
122
+    protected function filterErrorData(array $data, array $itemInfo, array $errorInfo) {
130 123
         return $data;
131 124
     }
132 125
 }
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/AbstractNewFeatureSniff.php 3 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -22,87 +22,87 @@
 block discarded – undo
22 22
 {
23 23
 
24 24
 
25
-    /**
26
-     * Determine whether an error/warning should be thrown for an item based on collected information.
27
-     *
28
-     * @param array $errorInfo Detail information about an item.
29
-     *
30
-     * @return bool
31
-     */
32
-    protected function shouldThrowError(array $errorInfo)
33
-    {
34
-        return ($errorInfo['not_in_version'] !== '');
35
-    }
36
-
37
-
38
-    /**
39
-     * Retrieve the relevant detail (version) information for use in an error message.
40
-     *
41
-     * @param array $itemArray Version and other information about the item.
42
-     * @param array $itemInfo  Base information about the item.
43
-     *
44
-     * @return array
45
-     */
46
-    public function getErrorInfo(array $itemArray, array $itemInfo)
47
-    {
48
-        $errorInfo = array(
49
-            'not_in_version' => '',
50
-            'error'          => true,
51
-        );
52
-
53
-        $versionArray = $this->getVersionArray($itemArray);
54
-
55
-        if (empty($versionArray) === false) {
56
-            foreach ($versionArray as $version => $present) {
57
-                if ($errorInfo['not_in_version'] === '' && $present === false
58
-                    && $this->supportsBelow($version) === true
59
-                ) {
60
-                    $errorInfo['not_in_version'] = $version;
61
-                }
62
-            }
63
-        }
64
-
65
-        return $errorInfo;
66
-    }
67
-
68
-
69
-    /**
70
-     * Get the error message template for this sniff.
71
-     *
72
-     * @return string
73
-     */
74
-    protected function getErrorMsgTemplate()
75
-    {
76
-        return '%s is not present in PHP version %s or earlier';
77
-    }
78
-
79
-
80
-    /**
81
-     * Generates the error or warning for this item.
82
-     *
83
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
84
-     * @param int                   $stackPtr  The position of the relevant token in
85
-     *                                         the stack.
86
-     * @param array                 $itemInfo  Base information about the item.
87
-     * @param array                 $errorInfo Array with detail (version) information
88
-     *                                         relevant to the item.
89
-     *
90
-     * @return void
91
-     */
92
-    public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
93
-    {
94
-        $itemName = $this->getItemName($itemInfo, $errorInfo);
95
-        $error    = $this->getErrorMsgTemplate();
96
-
97
-        $errorCode = $this->stringToErrorCode($itemName) . 'Found';
98
-        $data      = array(
99
-            $itemName,
100
-            $errorInfo['not_in_version'],
101
-        );
102
-
103
-        $error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
104
-        $data  = $this->filterErrorData($data, $itemInfo, $errorInfo);
105
-
106
-        $this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
107
-    }
25
+	/**
26
+	 * Determine whether an error/warning should be thrown for an item based on collected information.
27
+	 *
28
+	 * @param array $errorInfo Detail information about an item.
29
+	 *
30
+	 * @return bool
31
+	 */
32
+	protected function shouldThrowError(array $errorInfo)
33
+	{
34
+		return ($errorInfo['not_in_version'] !== '');
35
+	}
36
+
37
+
38
+	/**
39
+	 * Retrieve the relevant detail (version) information for use in an error message.
40
+	 *
41
+	 * @param array $itemArray Version and other information about the item.
42
+	 * @param array $itemInfo  Base information about the item.
43
+	 *
44
+	 * @return array
45
+	 */
46
+	public function getErrorInfo(array $itemArray, array $itemInfo)
47
+	{
48
+		$errorInfo = array(
49
+			'not_in_version' => '',
50
+			'error'          => true,
51
+		);
52
+
53
+		$versionArray = $this->getVersionArray($itemArray);
54
+
55
+		if (empty($versionArray) === false) {
56
+			foreach ($versionArray as $version => $present) {
57
+				if ($errorInfo['not_in_version'] === '' && $present === false
58
+					&& $this->supportsBelow($version) === true
59
+				) {
60
+					$errorInfo['not_in_version'] = $version;
61
+				}
62
+			}
63
+		}
64
+
65
+		return $errorInfo;
66
+	}
67
+
68
+
69
+	/**
70
+	 * Get the error message template for this sniff.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function getErrorMsgTemplate()
75
+	{
76
+		return '%s is not present in PHP version %s or earlier';
77
+	}
78
+
79
+
80
+	/**
81
+	 * Generates the error or warning for this item.
82
+	 *
83
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
84
+	 * @param int                   $stackPtr  The position of the relevant token in
85
+	 *                                         the stack.
86
+	 * @param array                 $itemInfo  Base information about the item.
87
+	 * @param array                 $errorInfo Array with detail (version) information
88
+	 *                                         relevant to the item.
89
+	 *
90
+	 * @return void
91
+	 */
92
+	public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
93
+	{
94
+		$itemName = $this->getItemName($itemInfo, $errorInfo);
95
+		$error    = $this->getErrorMsgTemplate();
96
+
97
+		$errorCode = $this->stringToErrorCode($itemName) . 'Found';
98
+		$data      = array(
99
+			$itemName,
100
+			$errorInfo['not_in_version'],
101
+		);
102
+
103
+		$error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
104
+		$data  = $this->filterErrorData($data, $itemInfo, $errorInfo);
105
+
106
+		$this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @return bool
31 31
      */
32
-    protected function shouldThrowError(array $errorInfo)
32
+    protected function shouldThrowError( array $errorInfo )
33 33
     {
34
-        return ($errorInfo['not_in_version'] !== '');
34
+        return ( $errorInfo[ 'not_in_version' ] !== '' );
35 35
     }
36 36
 
37 37
 
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @return array
45 45
      */
46
-    public function getErrorInfo(array $itemArray, array $itemInfo)
46
+    public function getErrorInfo( array $itemArray, array $itemInfo )
47 47
     {
48 48
         $errorInfo = array(
49 49
             'not_in_version' => '',
50 50
             'error'          => true,
51 51
         );
52 52
 
53
-        $versionArray = $this->getVersionArray($itemArray);
53
+        $versionArray = $this->getVersionArray( $itemArray );
54 54
 
55
-        if (empty($versionArray) === false) {
56
-            foreach ($versionArray as $version => $present) {
57
-                if ($errorInfo['not_in_version'] === '' && $present === false
58
-                    && $this->supportsBelow($version) === true
55
+        if ( empty( $versionArray ) === false ) {
56
+            foreach ( $versionArray as $version => $present ) {
57
+                if ( $errorInfo[ 'not_in_version' ] === '' && $present === false
58
+                    && $this->supportsBelow( $version ) === true
59 59
                 ) {
60
-                    $errorInfo['not_in_version'] = $version;
60
+                    $errorInfo[ 'not_in_version' ] = $version;
61 61
                 }
62 62
             }
63 63
         }
@@ -89,20 +89,20 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return void
91 91
      */
92
-    public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
92
+    public function addError( File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo )
93 93
     {
94
-        $itemName = $this->getItemName($itemInfo, $errorInfo);
94
+        $itemName = $this->getItemName( $itemInfo, $errorInfo );
95 95
         $error    = $this->getErrorMsgTemplate();
96 96
 
97
-        $errorCode = $this->stringToErrorCode($itemName) . 'Found';
97
+        $errorCode = $this->stringToErrorCode( $itemName ) . 'Found';
98 98
         $data      = array(
99 99
             $itemName,
100
-            $errorInfo['not_in_version'],
100
+            $errorInfo[ 'not_in_version' ],
101 101
         );
102 102
 
103
-        $error = $this->filterErrorMsg($error, $itemInfo, $errorInfo);
104
-        $data  = $this->filterErrorData($data, $itemInfo, $errorInfo);
103
+        $error = $this->filterErrorMsg( $error, $itemInfo, $errorInfo );
104
+        $data  = $this->filterErrorData( $data, $itemInfo, $errorInfo );
105 105
 
106
-        $this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data);
106
+        $this->addMessage( $phpcsFile, $error, $stackPtr, $errorInfo[ 'error' ], $errorCode, $data );
107 107
     }
108 108
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@  discard block
 block discarded – undo
18 18
  * @package  PHPCompatibility
19 19
  * @author   Juliette Reinders Folmer <[email protected]>
20 20
  */
21
-abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff
22
-{
21
+abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff {
23 22
 
24 23
 
25 24
     /**
@@ -29,8 +28,7 @@  discard block
 block discarded – undo
29 28
      *
30 29
      * @return bool
31 30
      */
32
-    protected function shouldThrowError(array $errorInfo)
33
-    {
31
+    protected function shouldThrowError(array $errorInfo) {
34 32
         return ($errorInfo['not_in_version'] !== '');
35 33
     }
36 34
 
@@ -43,8 +41,7 @@  discard block
 block discarded – undo
43 41
      *
44 42
      * @return array
45 43
      */
46
-    public function getErrorInfo(array $itemArray, array $itemInfo)
47
-    {
44
+    public function getErrorInfo(array $itemArray, array $itemInfo) {
48 45
         $errorInfo = array(
49 46
             'not_in_version' => '',
50 47
             'error'          => true,
@@ -71,8 +68,7 @@  discard block
 block discarded – undo
71 68
      *
72 69
      * @return string
73 70
      */
74
-    protected function getErrorMsgTemplate()
75
-    {
71
+    protected function getErrorMsgTemplate() {
76 72
         return '%s is not present in PHP version %s or earlier';
77 73
     }
78 74
 
@@ -89,8 +85,7 @@  discard block
 block discarded – undo
89 85
      *
90 86
      * @return void
91 87
      */
92
-    public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
93
-    {
88
+    public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) {
94 89
         $itemName = $this->getItemName($itemInfo, $errorInfo);
95 90
         $error    = $this->getErrorMsgTemplate();
96 91
 
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/ComplexVersionInterface.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -26,52 +26,52 @@
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    /**
30
-     * Handle the retrieval of relevant information and - if necessary - throwing of an
31
-     * error/warning for an item.
32
-     *
33
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
34
-     * @param int                   $stackPtr  The position of the relevant token in
35
-     *                                         the stack.
36
-     * @param array                 $itemInfo  Base information about the item.
37
-     *
38
-     * @return void
39
-     */
40
-    public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo);
29
+	/**
30
+	 * Handle the retrieval of relevant information and - if necessary - throwing of an
31
+	 * error/warning for an item.
32
+	 *
33
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
34
+	 * @param int                   $stackPtr  The position of the relevant token in
35
+	 *                                         the stack.
36
+	 * @param array                 $itemInfo  Base information about the item.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo);
41 41
 
42 42
 
43
-    /**
44
-     * Get the relevant sub-array for a specific item from a multi-dimensional array.
45
-     *
46
-     * @param array $itemInfo Base information about the item.
47
-     *
48
-     * @return array Version and other information about the item.
49
-     */
50
-    public function getItemArray(array $itemInfo);
43
+	/**
44
+	 * Get the relevant sub-array for a specific item from a multi-dimensional array.
45
+	 *
46
+	 * @param array $itemInfo Base information about the item.
47
+	 *
48
+	 * @return array Version and other information about the item.
49
+	 */
50
+	public function getItemArray(array $itemInfo);
51 51
 
52 52
 
53
-    /**
54
-     * Retrieve the relevant detail (version) information for use in an error message.
55
-     *
56
-     * @param array $itemArray Version and other information about the item.
57
-     * @param array $itemInfo  Base information about the item.
58
-     *
59
-     * @return array
60
-     */
61
-    public function getErrorInfo(array $itemArray, array $itemInfo);
53
+	/**
54
+	 * Retrieve the relevant detail (version) information for use in an error message.
55
+	 *
56
+	 * @param array $itemArray Version and other information about the item.
57
+	 * @param array $itemInfo  Base information about the item.
58
+	 *
59
+	 * @return array
60
+	 */
61
+	public function getErrorInfo(array $itemArray, array $itemInfo);
62 62
 
63 63
 
64
-    /**
65
-     * Generates the error or warning for this item.
66
-     *
67
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
-     * @param int                   $stackPtr  The position of the relevant token in
69
-     *                                         the stack.
70
-     * @param array                 $itemInfo  Base information about the item.
71
-     * @param array                 $errorInfo Array with detail (version) information
72
-     *                                         relevant to the item.
73
-     *
74
-     * @return void
75
-     */
76
-    public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo);
64
+	/**
65
+	 * Generates the error or warning for this item.
66
+	 *
67
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
+	 * @param int                   $stackPtr  The position of the relevant token in
69
+	 *                                         the stack.
70
+	 * @param array                 $itemInfo  Base information about the item.
71
+	 * @param array                 $errorInfo Array with detail (version) information
72
+	 *                                         relevant to the item.
73
+	 *
74
+	 * @return void
75
+	 */
76
+	public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo);
77 77
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return void
39 39
      */
40
-    public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo);
40
+    public function handleFeature( File $phpcsFile, $stackPtr, array $itemInfo );
41 41
 
42 42
 
43 43
     /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return array Version and other information about the item.
49 49
      */
50
-    public function getItemArray(array $itemInfo);
50
+    public function getItemArray( array $itemInfo );
51 51
 
52 52
 
53 53
     /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return array
60 60
      */
61
-    public function getErrorInfo(array $itemArray, array $itemInfo);
61
+    public function getErrorInfo( array $itemArray, array $itemInfo );
62 62
 
63 63
 
64 64
     /**
@@ -73,5 +73,5 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @return void
75 75
      */
76
-    public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo);
76
+    public function addError( File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo );
77 77
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
  * @package  PHPCompatibility
23 23
  * @author   Juliette Reinders Folmer <[email protected]>
24 24
  */
25
-interface ComplexVersionInterface
26
-{
25
+interface ComplexVersionInterface {
27 26
 
28 27
 
29 28
     /**
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/InitialValue/NewConstantArraysUsingConstSniff.php 4 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 class NewConstantArraysUsingConstSniff extends Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * Returns an array of tokens this test wants to listen for.
33
-     *
34
-     * @return array
35
-     */
36
-    public function register()
37
-    {
38
-        return array(\T_CONST);
39
-    }
31
+	/**
32
+	 * Returns an array of tokens this test wants to listen for.
33
+	 *
34
+	 * @return array
35
+	 */
36
+	public function register()
37
+	{
38
+		return array(\T_CONST);
39
+	}
40 40
 
41
-    /**
42
-     * Processes this test, when one of its tokens is encountered.
43
-     *
44
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
45
-     * @param int                   $stackPtr  The position of the current token in the
46
-     *                                         stack passed in $tokens.
47
-     *
48
-     * @return void
49
-     */
50
-    public function process(File $phpcsFile, $stackPtr)
51
-    {
52
-        if ($this->supportsBelow('5.5') !== true) {
53
-            return;
54
-        }
41
+	/**
42
+	 * Processes this test, when one of its tokens is encountered.
43
+	 *
44
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
45
+	 * @param int                   $stackPtr  The position of the current token in the
46
+	 *                                         stack passed in $tokens.
47
+	 *
48
+	 * @return void
49
+	 */
50
+	public function process(File $phpcsFile, $stackPtr)
51
+	{
52
+		if ($this->supportsBelow('5.5') !== true) {
53
+			return;
54
+		}
55 55
 
56
-        $tokens = $phpcsFile->getTokens();
57
-        $find   = array(
58
-            \T_ARRAY            => \T_ARRAY,
59
-            \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
60
-        );
56
+		$tokens = $phpcsFile->getTokens();
57
+		$find   = array(
58
+			\T_ARRAY            => \T_ARRAY,
59
+			\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
60
+		);
61 61
 
62
-        while (($hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true)) !== false) {
63
-            $phpcsFile->addError(
64
-                'Constant arrays using the "const" keyword are not allowed in PHP 5.5 or earlier',
65
-                $hasArray,
66
-                'Found'
67
-            );
62
+		while (($hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true)) !== false) {
63
+			$phpcsFile->addError(
64
+				'Constant arrays using the "const" keyword are not allowed in PHP 5.5 or earlier',
65
+				$hasArray,
66
+				'Found'
67
+			);
68 68
 
69
-            // Skip past the content of the array.
70
-            $stackPtr = $hasArray;
71
-            if ($tokens[$hasArray]['code'] === \T_OPEN_SHORT_ARRAY && isset($tokens[$hasArray]['bracket_closer'])) {
72
-                $stackPtr = $tokens[$hasArray]['bracket_closer'];
73
-            } elseif ($tokens[$hasArray]['code'] === \T_ARRAY && isset($tokens[$hasArray]['parenthesis_closer'])) {
74
-                $stackPtr = $tokens[$hasArray]['parenthesis_closer'];
75
-            }
76
-        }
77
-    }
69
+			// Skip past the content of the array.
70
+			$stackPtr = $hasArray;
71
+			if ($tokens[$hasArray]['code'] === \T_OPEN_SHORT_ARRAY && isset($tokens[$hasArray]['bracket_closer'])) {
72
+				$stackPtr = $tokens[$hasArray]['bracket_closer'];
73
+			} elseif ($tokens[$hasArray]['code'] === \T_ARRAY && isset($tokens[$hasArray]['parenthesis_closer'])) {
74
+				$stackPtr = $tokens[$hasArray]['parenthesis_closer'];
75
+			}
76
+		}
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function register()
37 37
     {
38
-        return array(\T_CONST);
38
+        return array( \T_CONST );
39 39
     }
40 40
 
41 41
     /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return void
49 49
      */
50
-    public function process(File $phpcsFile, $stackPtr)
50
+    public function process( File $phpcsFile, $stackPtr )
51 51
     {
52
-        if ($this->supportsBelow('5.5') !== true) {
52
+        if ( $this->supportsBelow( '5.5' ) !== true ) {
53 53
             return;
54 54
         }
55 55
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
60 60
         );
61 61
 
62
-        while (($hasArray = $phpcsFile->findNext($find, ($stackPtr + 1), null, false, null, true)) !== false) {
62
+        while ( ( $hasArray = $phpcsFile->findNext( $find, ( $stackPtr + 1 ), null, false, null, true ) ) !== false ) {
63 63
             $phpcsFile->addError(
64 64
                 'Constant arrays using the "const" keyword are not allowed in PHP 5.5 or earlier',
65 65
                 $hasArray,
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 
69 69
             // Skip past the content of the array.
70 70
             $stackPtr = $hasArray;
71
-            if ($tokens[$hasArray]['code'] === \T_OPEN_SHORT_ARRAY && isset($tokens[$hasArray]['bracket_closer'])) {
72
-                $stackPtr = $tokens[$hasArray]['bracket_closer'];
73
-            } elseif ($tokens[$hasArray]['code'] === \T_ARRAY && isset($tokens[$hasArray]['parenthesis_closer'])) {
74
-                $stackPtr = $tokens[$hasArray]['parenthesis_closer'];
71
+            if ( $tokens[ $hasArray ][ 'code' ] === \T_OPEN_SHORT_ARRAY && isset( $tokens[ $hasArray ][ 'bracket_closer' ] ) ) {
72
+                $stackPtr = $tokens[ $hasArray ][ 'bracket_closer' ];
73
+            } elseif ( $tokens[ $hasArray ][ 'code' ] === \T_ARRAY && isset( $tokens[ $hasArray ][ 'parenthesis_closer' ] ) ) {
74
+                $stackPtr = $tokens[ $hasArray ][ 'parenthesis_closer' ];
75 75
             }
76 76
         }
77 77
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,16 +25,14 @@  discard block
 block discarded – undo
25 25
  * @package  PHPCompatibility
26 26
  * @author   Juliette Reinders Folmer <[email protected]>
27 27
  */
28
-class NewConstantArraysUsingConstSniff extends Sniff
29
-{
28
+class NewConstantArraysUsingConstSniff extends Sniff {
30 29
 
31 30
     /**
32 31
      * Returns an array of tokens this test wants to listen for.
33 32
      *
34 33
      * @return array
35 34
      */
36
-    public function register()
37
-    {
35
+    public function register() {
38 36
         return array(\T_CONST);
39 37
     }
40 38
 
@@ -47,8 +45,7 @@  discard block
 block discarded – undo
47 45
      *
48 46
      * @return void
49 47
      */
50
-    public function process(File $phpcsFile, $stackPtr)
51
-    {
48
+    public function process(File $phpcsFile, $stackPtr) {
52 49
         if ($this->supportsBelow('5.5') !== true) {
53 50
             return;
54 51
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
     /**
66 66
      * Returns an array of tokens this test wants to listen for.
67 67
      *
68
-     * @return array
68
+     * @return integer[]
69 69
      */
70 70
     public function register()
71 71
     {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/InitialValue/NewConstantArraysUsingDefineSniff.php 4 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -28,70 +28,70 @@
 block discarded – undo
28 28
 class NewConstantArraysUsingDefineSniff extends Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * Returns an array of tokens this test wants to listen for.
33
-     *
34
-     * @return array
35
-     */
36
-    public function register()
37
-    {
38
-        return array(\T_STRING);
39
-    }
31
+	/**
32
+	 * Returns an array of tokens this test wants to listen for.
33
+	 *
34
+	 * @return array
35
+	 */
36
+	public function register()
37
+	{
38
+		return array(\T_STRING);
39
+	}
40 40
 
41
-    /**
42
-     * Processes this test, when one of its tokens is encountered.
43
-     *
44
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
45
-     * @param int                   $stackPtr  The position of the current token in the
46
-     *                                         stack passed in $tokens.
47
-     *
48
-     * @return void
49
-     */
50
-    public function process(File $phpcsFile, $stackPtr)
51
-    {
52
-        if ($this->supportsBelow('5.6') !== true) {
53
-            return;
54
-        }
41
+	/**
42
+	 * Processes this test, when one of its tokens is encountered.
43
+	 *
44
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
45
+	 * @param int                   $stackPtr  The position of the current token in the
46
+	 *                                         stack passed in $tokens.
47
+	 *
48
+	 * @return void
49
+	 */
50
+	public function process(File $phpcsFile, $stackPtr)
51
+	{
52
+		if ($this->supportsBelow('5.6') !== true) {
53
+			return;
54
+		}
55 55
 
56
-        $tokens = $phpcsFile->getTokens();
56
+		$tokens = $phpcsFile->getTokens();
57 57
 
58
-        $ignore = array(
59
-            \T_DOUBLE_COLON    => true,
60
-            \T_OBJECT_OPERATOR => true,
61
-            \T_FUNCTION        => true,
62
-            \T_CONST           => true,
63
-        );
58
+		$ignore = array(
59
+			\T_DOUBLE_COLON    => true,
60
+			\T_OBJECT_OPERATOR => true,
61
+			\T_FUNCTION        => true,
62
+			\T_CONST           => true,
63
+		);
64 64
 
65
-        $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
66
-        if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
67
-            // Not a call to a PHP function.
68
-            return;
69
-        }
65
+		$prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
66
+		if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
67
+			// Not a call to a PHP function.
68
+			return;
69
+		}
70 70
 
71
-        $functionLc = strtolower($tokens[$stackPtr]['content']);
72
-        if ($functionLc !== 'define') {
73
-            return;
74
-        }
71
+		$functionLc = strtolower($tokens[$stackPtr]['content']);
72
+		if ($functionLc !== 'define') {
73
+			return;
74
+		}
75 75
 
76
-        $secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2);
77
-        if (isset($secondParam['start'], $secondParam['end']) === false) {
78
-            return;
79
-        }
76
+		$secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2);
77
+		if (isset($secondParam['start'], $secondParam['end']) === false) {
78
+			return;
79
+		}
80 80
 
81
-        $targetNestingLevel = 0;
82
-        if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
83
-            $targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);
84
-        }
81
+		$targetNestingLevel = 0;
82
+		if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
83
+			$targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);
84
+		}
85 85
 
86
-        $array = $phpcsFile->findNext(array(\T_ARRAY, \T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
87
-        if ($array !== false) {
88
-            if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
89
-                $phpcsFile->addError(
90
-                    'Constant arrays using define are not allowed in PHP 5.6 or earlier',
91
-                    $array,
92
-                    'Found'
93
-                );
94
-            }
95
-        }
96
-    }
86
+		$array = $phpcsFile->findNext(array(\T_ARRAY, \T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
87
+		if ($array !== false) {
88
+			if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
89
+				$phpcsFile->addError(
90
+					'Constant arrays using define are not allowed in PHP 5.6 or earlier',
91
+					$array,
92
+					'Found'
93
+				);
94
+			}
95
+		}
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function register()
37 37
     {
38
-        return array(\T_STRING);
38
+        return array( \T_STRING );
39 39
     }
40 40
 
41 41
     /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return void
49 49
      */
50
-    public function process(File $phpcsFile, $stackPtr)
50
+    public function process( File $phpcsFile, $stackPtr )
51 51
     {
52
-        if ($this->supportsBelow('5.6') !== true) {
52
+        if ( $this->supportsBelow( '5.6' ) !== true ) {
53 53
             return;
54 54
         }
55 55
 
@@ -62,30 +62,30 @@  discard block
 block discarded – undo
62 62
             \T_CONST           => true,
63 63
         );
64 64
 
65
-        $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
66
-        if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
65
+        $prevToken = $phpcsFile->findPrevious( \T_WHITESPACE, ( $stackPtr - 1 ), null, true );
66
+        if ( isset( $ignore[ $tokens[ $prevToken ][ 'code' ] ] ) === true ) {
67 67
             // Not a call to a PHP function.
68 68
             return;
69 69
         }
70 70
 
71
-        $functionLc = strtolower($tokens[$stackPtr]['content']);
72
-        if ($functionLc !== 'define') {
71
+        $functionLc = strtolower( $tokens[ $stackPtr ][ 'content' ] );
72
+        if ( $functionLc !== 'define' ) {
73 73
             return;
74 74
         }
75 75
 
76
-        $secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2);
77
-        if (isset($secondParam['start'], $secondParam['end']) === false) {
76
+        $secondParam = $this->getFunctionCallParameter( $phpcsFile, $stackPtr, 2 );
77
+        if ( isset( $secondParam[ 'start' ], $secondParam[ 'end' ] ) === false ) {
78 78
             return;
79 79
         }
80 80
 
81 81
         $targetNestingLevel = 0;
82
-        if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
83
-            $targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);
82
+        if ( isset( $tokens[ $secondParam[ 'start' ] ][ 'nested_parenthesis' ] ) ) {
83
+            $targetNestingLevel = \count( $tokens[ $secondParam[ 'start' ] ][ 'nested_parenthesis' ] );
84 84
         }
85 85
 
86
-        $array = $phpcsFile->findNext(array(\T_ARRAY, \T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
87
-        if ($array !== false) {
88
-            if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
86
+        $array = $phpcsFile->findNext( array( \T_ARRAY, \T_OPEN_SHORT_ARRAY ), $secondParam[ 'start' ], ( $secondParam[ 'end' ] + 1 ) );
87
+        if ( $array !== false ) {
88
+            if ( ( isset( $tokens[ $array ][ 'nested_parenthesis' ] ) === false && $targetNestingLevel === 0 ) || \count( $tokens[ $array ][ 'nested_parenthesis' ] ) === $targetNestingLevel ) {
89 89
                 $phpcsFile->addError(
90 90
                     'Constant arrays using define are not allowed in PHP 5.6 or earlier',
91 91
                     $array,
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,16 +25,14 @@  discard block
 block discarded – undo
25 25
  * @package  PHPCompatibility
26 26
  * @author   Wim Godden <[email protected]>
27 27
  */
28
-class NewConstantArraysUsingDefineSniff extends Sniff
29
-{
28
+class NewConstantArraysUsingDefineSniff extends Sniff {
30 29
 
31 30
     /**
32 31
      * Returns an array of tokens this test wants to listen for.
33 32
      *
34 33
      * @return array
35 34
      */
36
-    public function register()
37
-    {
35
+    public function register() {
38 36
         return array(\T_STRING);
39 37
     }
40 38
 
@@ -47,8 +45,7 @@  discard block
 block discarded – undo
47 45
      *
48 46
      * @return void
49 47
      */
50
-    public function process(File $phpcsFile, $stackPtr)
51
-    {
48
+    public function process(File $phpcsFile, $stackPtr) {
52 49
         if ($this->supportsBelow('5.6') !== true) {
53 50
             return;
54 51
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
     /**
66 66
      * Returns an array of tokens this test wants to listen for.
67 67
      *
68
-     * @return array
68
+     * @return integer[]
69 69
      */
70 70
     public function register()
71 71
     {
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/InitialValue/NewHeredocSniff.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -35,56 +35,56 @@
 block discarded – undo
35 35
 class NewHeredocSniff extends NewConstantScalarExpressionsSniff
36 36
 {
37 37
 
38
-    /**
39
-     * Error message.
40
-     *
41
-     * @var string
42
-     */
43
-    const ERROR_PHRASE = 'Initializing %s using the Heredoc syntax was not supported in PHP 5.2 or earlier';
38
+	/**
39
+	 * Error message.
40
+	 *
41
+	 * @var string
42
+	 */
43
+	const ERROR_PHRASE = 'Initializing %s using the Heredoc syntax was not supported in PHP 5.2 or earlier';
44 44
 
45
-    /**
46
-     * Partial error phrases to be used in combination with the error message constant.
47
-     *
48
-     * @var array
49
-     */
50
-    protected $errorPhrases = array(
51
-        'const'     => 'constants',
52
-        'property'  => 'class properties',
53
-        'staticvar' => 'static variables',
54
-        'default'   => 'default parameter values',
55
-    );
45
+	/**
46
+	 * Partial error phrases to be used in combination with the error message constant.
47
+	 *
48
+	 * @var array
49
+	 */
50
+	protected $errorPhrases = array(
51
+		'const'     => 'constants',
52
+		'property'  => 'class properties',
53
+		'staticvar' => 'static variables',
54
+		'default'   => 'default parameter values',
55
+	);
56 56
 
57 57
 
58
-    /**
59
-     * Do a version check to determine if this sniff needs to run at all.
60
-     *
61
-     * @return bool
62
-     */
63
-    protected function bowOutEarly()
64
-    {
65
-        return ($this->supportsBelow('5.2') !== true);
66
-    }
58
+	/**
59
+	 * Do a version check to determine if this sniff needs to run at all.
60
+	 *
61
+	 * @return bool
62
+	 */
63
+	protected function bowOutEarly()
64
+	{
65
+		return ($this->supportsBelow('5.2') !== true);
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Is a value declared and does the declared value not contain an heredoc ?
71
-     *
72
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
73
-     * @param int                   $stackPtr  The position of the current token in the
74
-     *                                         stack passed in $tokens.
75
-     * @param int                   $end       The end of the value definition.
76
-     *
77
-     * @return bool True if no heredoc (or assignment) is found, false otherwise.
78
-     */
79
-    protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
80
-    {
81
-        $tokens = $phpcsFile->getTokens();
82
-        $next   = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
83
-        if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
84
-            // No value assigned.
85
-            return true;
86
-        }
69
+	/**
70
+	 * Is a value declared and does the declared value not contain an heredoc ?
71
+	 *
72
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
73
+	 * @param int                   $stackPtr  The position of the current token in the
74
+	 *                                         stack passed in $tokens.
75
+	 * @param int                   $end       The end of the value definition.
76
+	 *
77
+	 * @return bool True if no heredoc (or assignment) is found, false otherwise.
78
+	 */
79
+	protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
80
+	{
81
+		$tokens = $phpcsFile->getTokens();
82
+		$next   = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
83
+		if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
84
+			// No value assigned.
85
+			return true;
86
+		}
87 87
 
88
-        return ($phpcsFile->findNext(\T_START_HEREDOC, ($next + 1), $end, false, null, true) === false);
89
-    }
88
+		return ($phpcsFile->findNext(\T_START_HEREDOC, ($next + 1), $end, false, null, true) === false);
89
+	}
90 90
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     protected function bowOutEarly()
64 64
     {
65
-        return ($this->supportsBelow('5.2') !== true);
65
+        return ( $this->supportsBelow( '5.2' ) !== true );
66 66
     }
67 67
 
68 68
 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
      *
77 77
      * @return bool True if no heredoc (or assignment) is found, false otherwise.
78 78
      */
79
-    protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
79
+    protected function isValidAssignment( File $phpcsFile, $stackPtr, $end )
80 80
     {
81 81
         $tokens = $phpcsFile->getTokens();
82
-        $next   = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
83
-        if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
82
+        $next   = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), $end, true );
83
+        if ( $next === false || $tokens[ $next ][ 'code' ] !== \T_EQUAL ) {
84 84
             // No value assigned.
85 85
             return true;
86 86
         }
87 87
 
88
-        return ($phpcsFile->findNext(\T_START_HEREDOC, ($next + 1), $end, false, null, true) === false);
88
+        return ( $phpcsFile->findNext( \T_START_HEREDOC, ( $next + 1 ), $end, false, null, true ) === false );
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
  * @package  PHPCompatibility
33 33
  * @author   Juliette Reinders Folmer <[email protected]>
34 34
  */
35
-class NewHeredocSniff extends NewConstantScalarExpressionsSniff
36
-{
35
+class NewHeredocSniff extends NewConstantScalarExpressionsSniff {
37 36
 
38 37
     /**
39 38
      * Error message.
@@ -60,8 +59,7 @@  discard block
 block discarded – undo
60 59
      *
61 60
      * @return bool
62 61
      */
63
-    protected function bowOutEarly()
64
-    {
62
+    protected function bowOutEarly() {
65 63
         return ($this->supportsBelow('5.2') !== true);
66 64
     }
67 65
 
@@ -76,8 +74,7 @@  discard block
 block discarded – undo
76 74
      *
77 75
      * @return bool True if no heredoc (or assignment) is found, false otherwise.
78 76
      */
79
-    protected function isValidAssignment(File $phpcsFile, $stackPtr, $end)
80
-    {
77
+    protected function isValidAssignment(File $phpcsFile, $stackPtr, $end) {
81 78
         $tokens = $phpcsFile->getTokens();
82 79
         $next   = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true);
83 80
         if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Classes/NewAnonymousClassesSniff.php 4 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,59 +29,59 @@
 block discarded – undo
29 29
 class NewAnonymousClassesSniff extends Sniff
30 30
 {
31 31
 
32
-    /**
33
-     * Tokens which in various PHP versions indicate the `class` keyword.
34
-     *
35
-     * The dedicated anonymous class token is added from the `register()`
36
-     * method if the token is available.
37
-     *
38
-     * @var array
39
-     */
40
-    private $indicators = array(
41
-        \T_CLASS => \T_CLASS,
42
-    );
32
+	/**
33
+	 * Tokens which in various PHP versions indicate the `class` keyword.
34
+	 *
35
+	 * The dedicated anonymous class token is added from the `register()`
36
+	 * method if the token is available.
37
+	 *
38
+	 * @var array
39
+	 */
40
+	private $indicators = array(
41
+		\T_CLASS => \T_CLASS,
42
+	);
43 43
 
44
-    /**
45
-     * Returns an array of tokens this test wants to listen for.
46
-     *
47
-     * @return array
48
-     */
49
-    public function register()
50
-    {
51
-        if (\defined('T_ANON_CLASS')) {
52
-            $this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
53
-        }
44
+	/**
45
+	 * Returns an array of tokens this test wants to listen for.
46
+	 *
47
+	 * @return array
48
+	 */
49
+	public function register()
50
+	{
51
+		if (\defined('T_ANON_CLASS')) {
52
+			$this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
53
+		}
54 54
 
55
-        return array(\T_NEW);
56
-    }
55
+		return array(\T_NEW);
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * Processes this test, when one of its tokens is encountered.
61
-     *
62
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
63
-     * @param int                   $stackPtr  The position of the current token in the
64
-     *                                         stack passed in $tokens.
65
-     *
66
-     * @return void
67
-     */
68
-    public function process(File $phpcsFile, $stackPtr)
69
-    {
70
-        if ($this->supportsBelow('5.6') === false) {
71
-            return;
72
-        }
59
+	/**
60
+	 * Processes this test, when one of its tokens is encountered.
61
+	 *
62
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
63
+	 * @param int                   $stackPtr  The position of the current token in the
64
+	 *                                         stack passed in $tokens.
65
+	 *
66
+	 * @return void
67
+	 */
68
+	public function process(File $phpcsFile, $stackPtr)
69
+	{
70
+		if ($this->supportsBelow('5.6') === false) {
71
+			return;
72
+		}
73 73
 
74
-        $tokens       = $phpcsFile->getTokens();
75
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
76
-        if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
77
-            return;
78
-        }
74
+		$tokens       = $phpcsFile->getTokens();
75
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
76
+		if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
77
+			return;
78
+		}
79 79
 
80
-        // Still here ? In that case, it is an anonymous class.
81
-        $phpcsFile->addError(
82
-            'Anonymous classes are not supported in PHP 5.6 or earlier',
83
-            $stackPtr,
84
-            'Found'
85
-        );
86
-    }
80
+		// Still here ? In that case, it is an anonymous class.
81
+		$phpcsFile->addError(
82
+			'Anonymous classes are not supported in PHP 5.6 or earlier',
83
+			$stackPtr,
84
+			'Found'
85
+		);
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        if (\defined('T_ANON_CLASS')) {
52
-            $this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
51
+        if ( \defined( 'T_ANON_CLASS' ) ) {
52
+            $this->indicators[ \T_ANON_CLASS ] = \T_ANON_CLASS;
53 53
         }
54 54
 
55
-        return array(\T_NEW);
55
+        return array( \T_NEW );
56 56
     }
57 57
 
58 58
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return void
67 67
      */
68
-    public function process(File $phpcsFile, $stackPtr)
68
+    public function process( File $phpcsFile, $stackPtr )
69 69
     {
70
-        if ($this->supportsBelow('5.6') === false) {
70
+        if ( $this->supportsBelow( '5.6' ) === false ) {
71 71
             return;
72 72
         }
73 73
 
74 74
         $tokens       = $phpcsFile->getTokens();
75
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
76
-        if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
75
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true );
76
+        if ( $nextNonEmpty === false || isset( $this->indicators[ $tokens[ $nextNonEmpty ][ 'code' ] ] ) === false ) {
77 77
             return;
78 78
         }
79 79
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
  * @package  PHPCompatibility
27 27
  * @author   Wim Godden <[email protected]>
28 28
  */
29
-class NewAnonymousClassesSniff extends Sniff
30
-{
29
+class NewAnonymousClassesSniff extends Sniff {
31 30
 
32 31
     /**
33 32
      * Tokens which in various PHP versions indicate the `class` keyword.
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
      *
47 46
      * @return array
48 47
      */
49
-    public function register()
50
-    {
48
+    public function register() {
51 49
         if (\defined('T_ANON_CLASS')) {
52 50
             $this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
53 51
         }
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
      *
66 64
      * @return void
67 65
      */
68
-    public function process(File $phpcsFile, $stackPtr)
69
-    {
66
+    public function process(File $phpcsFile, $stackPtr) {
70 67
         if ($this->supportsBelow('5.6') === false) {
71 68
             return;
72 69
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
     /**
66 66
      * Returns an array of tokens this test wants to listen for.
67 67
      *
68
-     * @return array
68
+     * @return integer[]
69 69
      */
70 70
     public function register()
71 71
     {
Please login to merge, or discard this patch.