Completed
Branch dev (02312e)
by
unknown
11:42 queued 04:50
created
php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,28 +33,28 @@
 block discarded – undo
33 33
     echo 'hi';
34 34
 }
35 35
 
36
-if (!function_exists('YourFunction')) {
36
+if ( ! function_exists('YourFunction')) {
37 37
     // Define a function.
38 38
     function YourFunction() {
39 39
         echo 'hi';
40 40
     }
41 41
 }
42 42
 
43
-if (!class_exists('MyClass')) {
43
+if ( ! class_exists('MyClass')) {
44 44
     // Define a class.
45 45
     class MyClass
46 46
     {
47 47
         function SomeFunction() {}
48 48
     }
49
-} else if (!interface_exists('MyInterface')) {
49
+} else if ( ! interface_exists('MyInterface')) {
50 50
     interface MyInterface {}
51
-} elseif (!interface_exists('MyInterface')) {
51
+} elseif ( ! interface_exists('MyInterface')) {
52 52
     interface MyInterface {}
53 53
 } else {
54 54
     interface MyInterface {}
55 55
 }
56 56
 
57
-if (!interface_exists('MyInterface')) {
57
+if ( ! interface_exists('MyInterface')) {
58 58
     // Define an interface.
59 59
     interface MyInterface {}
60 60
 }
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,62 +10,62 @@
 block discarded – undo
10 10
 declare(ticks=1);
11 11
 
12 12
 declare(ticks=1) {
13
-    echo $i;
13
+	echo $i;
14 14
 }
15 15
 
16 16
 declare(ticks=1) :
17
-    echo $i;
17
+	echo $i;
18 18
 enddeclare;
19 19
 
20 20
 define("MAXSIZE", 100);
21 21
 if (defined('MINSIZE') === false) {
22
-    define("MINSIZE", 10);
22
+	define("MINSIZE", 10);
23 23
 }
24 24
 
25 25
 // Class comment.
26 26
 final class Foo
27 27
 {
28
-    public $myvar = 'foo';
28
+	public $myvar = 'foo';
29 29
 
30
-    // Function comment.
31
-    function Bar() {
32
-        echo 'hi';
33
-    }
30
+	// Function comment.
31
+	function Bar() {
32
+		echo 'hi';
33
+	}
34 34
 }
35 35
 
36 36
 function MyFunction() {
37
-    echo 'hi';
37
+	echo 'hi';
38 38
 }
39 39
 
40 40
 if (!function_exists('YourFunction')) {
41
-    // Define a function.
42
-    function YourFunction() {
43
-        echo 'hi';
44
-    }
41
+	// Define a function.
42
+	function YourFunction() {
43
+		echo 'hi';
44
+	}
45 45
 }
46 46
 
47 47
 if (!class_exists('MyClass')) {
48
-    // Define a class.
49
-    class MyClass
50
-    {
51
-        function SomeFunction() {}
52
-    }
48
+	// Define a class.
49
+	class MyClass
50
+	{
51
+		function SomeFunction() {}
52
+	}
53 53
 } else if (!interface_exists('MyInterface')) {
54
-    interface MyInterface {}
54
+	interface MyInterface {}
55 55
 } elseif (!interface_exists('MyInterface')) {
56
-    interface MyInterface {}
56
+	interface MyInterface {}
57 57
 } else {
58
-    interface MyInterface {}
58
+	interface MyInterface {}
59 59
 }
60 60
 
61 61
 if (!interface_exists('MyInterface')) {
62
-    // Define an interface.
63
-    interface MyInterface {}
62
+	// Define an interface.
63
+	interface MyInterface {}
64 64
 }
65 65
 
66 66
 #[\Attribute]
67 67
 namespace {
68
-    class A {}
68
+	class A {}
69 69
 }
70 70
 
71 71
 defined('APP_BASE_URL') or define('APP_BASE_URL', '/');
Please login to merge, or discard this patch.
src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
      *
26 26
      * @return array<int, int>
27 27
      */
28
-    public function getErrorList($testFile='')
28
+    public function getErrorList($testFile = '')
29 29
     {
30 30
         if ($testFile === 'ClassDeclarationUnitTest.2.inc') {
31 31
             return [];
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -15,43 +15,43 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @param string $testFile The name of the file being tested.
25
-     *
26
-     * @return array<int, int>
27
-     */
28
-    public function getErrorList($testFile='')
29
-    {
30
-        if ($testFile === 'ClassDeclarationUnitTest.2.inc') {
31
-            return [];
32
-        }
33
-
34
-        return [
35
-            2 => 1,
36
-            3 => 2,
37
-        ];
38
-
39
-    }//end getErrorList()
40
-
41
-
42
-    /**
43
-     * Returns the lines where warnings should occur.
44
-     *
45
-     * The key of the array should represent the line number and the value
46
-     * should represent the number of warnings that should occur on that line.
47
-     *
48
-     * @return array<int, int>
49
-     */
50
-    public function getWarningList()
51
-    {
52
-        return [];
53
-
54
-    }//end getWarningList()
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @param string $testFile The name of the file being tested.
25
+	 *
26
+	 * @return array<int, int>
27
+	 */
28
+	public function getErrorList($testFile='')
29
+	{
30
+		if ($testFile === 'ClassDeclarationUnitTest.2.inc') {
31
+			return [];
32
+		}
33
+
34
+		return [
35
+			2 => 1,
36
+			3 => 2,
37
+		];
38
+
39
+	}//end getErrorList()
40
+
41
+
42
+	/**
43
+	 * Returns the lines where warnings should occur.
44
+	 *
45
+	 * The key of the array should represent the line number and the value
46
+	 * should represent the number of warnings that should occur on that line.
47
+	 *
48
+	 * @return array<int, int>
49
+	 */
50
+	public function getWarningList()
51
+	{
52
+		return [];
53
+
54
+	}//end getWarningList()
55 55
 
56 56
 
57 57
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
             ) {
104 104
                 do {
105 105
                     $i = $phpcsFile->findNext(T_PHPCS_ENABLE, ($i + 1));
106
-                } while ($i !== false
106
+                }while ($i !== false
107 107
                     && empty($tokens[$i]['sniffCodes']) === false
108 108
                     && isset($tokens[$i]['sniffCodes']['PSR1']) === false
109 109
                     && isset($tokens[$i]['sniffCodes']['PSR1.Files']) === false
Please login to merge, or discard this patch.
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -17,282 +17,282 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * Returns an array of tokens this test wants to listen for.
22
-     *
23
-     * @return array
24
-     */
25
-    public function register()
26
-    {
27
-        return [T_OPEN_TAG];
28
-
29
-    }//end register()
30
-
31
-
32
-    /**
33
-     * Processes this sniff, when one of its tokens is encountered.
34
-     *
35
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
36
-     * @param int                         $stackPtr  The position of the current token in
37
-     *                                               the token stack.
38
-     *
39
-     * @return void
40
-     */
41
-    public function process(File $phpcsFile, $stackPtr)
42
-    {
43
-        $tokens = $phpcsFile->getTokens();
44
-        $result = $this->searchForConflict($phpcsFile, 0, ($phpcsFile->numTokens - 1), $tokens);
45
-
46
-        if ($result['symbol'] !== null && $result['effect'] !== null) {
47
-            $error = 'A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line %s and the first side effect is on line %s.';
48
-            $data  = [
49
-                $tokens[$result['symbol']]['line'],
50
-                $tokens[$result['effect']]['line'],
51
-            ];
52
-            $phpcsFile->addWarning($error, 0, 'FoundWithSymbols', $data);
53
-            $phpcsFile->recordMetric($stackPtr, 'Declarations and side effects mixed', 'yes');
54
-        } else {
55
-            $phpcsFile->recordMetric($stackPtr, 'Declarations and side effects mixed', 'no');
56
-        }
57
-
58
-        // Ignore the rest of the file.
59
-        return ($phpcsFile->numTokens + 1);
60
-
61
-    }//end process()
62
-
63
-
64
-    /**
65
-     * Searches for symbol declarations and side effects.
66
-     *
67
-     * Returns the positions of both the first symbol declared and the first
68
-     * side effect in the file. A NULL value for either indicates nothing was
69
-     * found.
70
-     *
71
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
72
-     * @param int                         $start     The token to start searching from.
73
-     * @param int                         $end       The token to search to.
74
-     * @param array                       $tokens    The stack of tokens that make up
75
-     *                                               the file.
76
-     *
77
-     * @return array
78
-     */
79
-    private function searchForConflict($phpcsFile, $start, $end, $tokens)
80
-    {
81
-        $symbols = [
82
-            T_CLASS     => T_CLASS,
83
-            T_INTERFACE => T_INTERFACE,
84
-            T_TRAIT     => T_TRAIT,
85
-            T_FUNCTION  => T_FUNCTION,
86
-        ];
87
-
88
-        $conditions = [
89
-            T_IF     => T_IF,
90
-            T_ELSE   => T_ELSE,
91
-            T_ELSEIF => T_ELSEIF,
92
-        ];
93
-
94
-        $checkAnnotations = $phpcsFile->config->annotations;
95
-
96
-        $firstSymbol = null;
97
-        $firstEffect = null;
98
-        for ($i = $start; $i <= $end; $i++) {
99
-            // Respect phpcs:disable comments.
100
-            if ($checkAnnotations === true
101
-                && $tokens[$i]['code'] === T_PHPCS_DISABLE
102
-                && (empty($tokens[$i]['sniffCodes']) === true
103
-                || isset($tokens[$i]['sniffCodes']['PSR1']) === true
104
-                || isset($tokens[$i]['sniffCodes']['PSR1.Files']) === true
105
-                || isset($tokens[$i]['sniffCodes']['PSR1.Files.SideEffects']) === true)
106
-            ) {
107
-                do {
108
-                    $i = $phpcsFile->findNext(T_PHPCS_ENABLE, ($i + 1));
109
-                } while ($i !== false
110
-                    && empty($tokens[$i]['sniffCodes']) === false
111
-                    && isset($tokens[$i]['sniffCodes']['PSR1']) === false
112
-                    && isset($tokens[$i]['sniffCodes']['PSR1.Files']) === false
113
-                    && isset($tokens[$i]['sniffCodes']['PSR1.Files.SideEffects']) === false);
114
-
115
-                if ($i === false) {
116
-                    // The entire rest of the file is disabled,
117
-                    // so return what we have so far.
118
-                    break;
119
-                }
120
-
121
-                continue;
122
-            }
123
-
124
-            // Ignore whitespace and comments.
125
-            if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
126
-                continue;
127
-            }
128
-
129
-            // Ignore PHP tags.
130
-            if ($tokens[$i]['code'] === T_OPEN_TAG
131
-                || $tokens[$i]['code'] === T_CLOSE_TAG
132
-            ) {
133
-                continue;
134
-            }
135
-
136
-            // Ignore shebang.
137
-            if (substr($tokens[$i]['content'], 0, 2) === '#!') {
138
-                continue;
139
-            }
140
-
141
-            // Ignore logical operators.
142
-            if (isset(Tokens::$booleanOperators[$tokens[$i]['code']]) === true) {
143
-                continue;
144
-            }
145
-
146
-            // Ignore entire namespace, declare, const and use statements.
147
-            if ($tokens[$i]['code'] === T_NAMESPACE
148
-                || $tokens[$i]['code'] === T_USE
149
-                || $tokens[$i]['code'] === T_DECLARE
150
-                || $tokens[$i]['code'] === T_CONST
151
-            ) {
152
-                if (isset($tokens[$i]['scope_opener']) === true) {
153
-                    $i = $tokens[$i]['scope_closer'];
154
-                    if ($tokens[$i]['code'] === T_ENDDECLARE) {
155
-                        $semicolon = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
156
-                        if ($semicolon !== false && $tokens[$semicolon]['code'] === T_SEMICOLON) {
157
-                            $i = $semicolon;
158
-                        }
159
-                    }
160
-                } else {
161
-                    $semicolon = $phpcsFile->findNext(T_SEMICOLON, ($i + 1));
162
-                    if ($semicolon !== false) {
163
-                        $i = $semicolon;
164
-                    }
165
-                }
166
-
167
-                continue;
168
-            }
169
-
170
-            // Ignore function/class prefixes.
171
-            if (isset(Tokens::$methodPrefixes[$tokens[$i]['code']]) === true) {
172
-                continue;
173
-            }
174
-
175
-            // Ignore anon classes.
176
-            if ($tokens[$i]['code'] === T_ANON_CLASS) {
177
-                $i = $tokens[$i]['scope_closer'];
178
-                continue;
179
-            }
180
-
181
-            // Ignore attributes.
182
-            if ($tokens[$i]['code'] === T_ATTRIBUTE
183
-                && isset($tokens[$i]['attribute_closer']) === true
184
-            ) {
185
-                $i = $tokens[$i]['attribute_closer'];
186
-                continue;
187
-            }
188
-
189
-            // Detect and skip over symbols.
190
-            if (isset($symbols[$tokens[$i]['code']]) === true
191
-                && isset($tokens[$i]['scope_closer']) === true
192
-            ) {
193
-                if ($firstSymbol === null) {
194
-                    $firstSymbol = $i;
195
-                }
196
-
197
-                $i = $tokens[$i]['scope_closer'];
198
-                continue;
199
-            } else if ($tokens[$i]['code'] === T_STRING
200
-                && strtolower($tokens[$i]['content']) === 'define'
201
-            ) {
202
-                $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
203
-                if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
204
-                    && $tokens[$prev]['code'] !== T_NULLSAFE_OBJECT_OPERATOR
205
-                    && $tokens[$prev]['code'] !== T_DOUBLE_COLON
206
-                    && $tokens[$prev]['code'] !== T_FUNCTION
207
-                ) {
208
-                    if ($firstSymbol === null) {
209
-                        $firstSymbol = $i;
210
-                    }
211
-
212
-                    $semicolon = $phpcsFile->findNext(T_SEMICOLON, ($i + 1));
213
-                    if ($semicolon !== false) {
214
-                        $i = $semicolon;
215
-                    }
216
-
217
-                    continue;
218
-                }
219
-            }//end if
220
-
221
-            // Special case for defined() as it can be used to see
222
-            // if a constant (a symbol) should be defined or not and
223
-            // doesn't need to use a full conditional block.
224
-            if ($tokens[$i]['code'] === T_STRING
225
-                && strtolower($tokens[$i]['content']) === 'defined'
226
-            ) {
227
-                $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
228
-                if ($openBracket !== false
229
-                    && $tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS
230
-                    && isset($tokens[$openBracket]['parenthesis_closer']) === true
231
-                ) {
232
-                    $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
233
-                    if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
234
-                        && $tokens[$prev]['code'] !== T_NULLSAFE_OBJECT_OPERATOR
235
-                        && $tokens[$prev]['code'] !== T_DOUBLE_COLON
236
-                        && $tokens[$prev]['code'] !== T_FUNCTION
237
-                    ) {
238
-                        $i = $tokens[$openBracket]['parenthesis_closer'];
239
-                        continue;
240
-                    }
241
-                }
242
-            }//end if
243
-
244
-            // Conditional statements are allowed in symbol files as long as the
245
-            // contents is only a symbol definition. So don't count these as effects
246
-            // in this case.
247
-            if (isset($conditions[$tokens[$i]['code']]) === true) {
248
-                if (isset($tokens[$i]['scope_opener']) === false) {
249
-                    // Probably an "else if", so just ignore.
250
-                    continue;
251
-                }
252
-
253
-                $result = $this->searchForConflict(
254
-                    $phpcsFile,
255
-                    ($tokens[$i]['scope_opener'] + 1),
256
-                    ($tokens[$i]['scope_closer'] - 1),
257
-                    $tokens
258
-                );
259
-
260
-                if ($result['symbol'] !== null) {
261
-                    if ($firstSymbol === null) {
262
-                        $firstSymbol = $result['symbol'];
263
-                    }
264
-
265
-                    if ($result['effect'] !== null) {
266
-                        // Found a conflict.
267
-                        $firstEffect = $result['effect'];
268
-                        break;
269
-                    }
270
-                }
271
-
272
-                if ($firstEffect === null) {
273
-                    $firstEffect = $result['effect'];
274
-                }
275
-
276
-                $i = $tokens[$i]['scope_closer'];
277
-                continue;
278
-            }//end if
279
-
280
-            if ($firstEffect === null) {
281
-                $firstEffect = $i;
282
-            }
283
-
284
-            if ($firstSymbol !== null) {
285
-                // We have a conflict we have to report, so no point continuing.
286
-                break;
287
-            }
288
-        }//end for
289
-
290
-        return [
291
-            'symbol' => $firstSymbol,
292
-            'effect' => $firstEffect,
293
-        ];
294
-
295
-    }//end searchForConflict()
20
+	/**
21
+	 * Returns an array of tokens this test wants to listen for.
22
+	 *
23
+	 * @return array
24
+	 */
25
+	public function register()
26
+	{
27
+		return [T_OPEN_TAG];
28
+
29
+	}//end register()
30
+
31
+
32
+	/**
33
+	 * Processes this sniff, when one of its tokens is encountered.
34
+	 *
35
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
36
+	 * @param int                         $stackPtr  The position of the current token in
37
+	 *                                               the token stack.
38
+	 *
39
+	 * @return void
40
+	 */
41
+	public function process(File $phpcsFile, $stackPtr)
42
+	{
43
+		$tokens = $phpcsFile->getTokens();
44
+		$result = $this->searchForConflict($phpcsFile, 0, ($phpcsFile->numTokens - 1), $tokens);
45
+
46
+		if ($result['symbol'] !== null && $result['effect'] !== null) {
47
+			$error = 'A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line %s and the first side effect is on line %s.';
48
+			$data  = [
49
+				$tokens[$result['symbol']]['line'],
50
+				$tokens[$result['effect']]['line'],
51
+			];
52
+			$phpcsFile->addWarning($error, 0, 'FoundWithSymbols', $data);
53
+			$phpcsFile->recordMetric($stackPtr, 'Declarations and side effects mixed', 'yes');
54
+		} else {
55
+			$phpcsFile->recordMetric($stackPtr, 'Declarations and side effects mixed', 'no');
56
+		}
57
+
58
+		// Ignore the rest of the file.
59
+		return ($phpcsFile->numTokens + 1);
60
+
61
+	}//end process()
62
+
63
+
64
+	/**
65
+	 * Searches for symbol declarations and side effects.
66
+	 *
67
+	 * Returns the positions of both the first symbol declared and the first
68
+	 * side effect in the file. A NULL value for either indicates nothing was
69
+	 * found.
70
+	 *
71
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
72
+	 * @param int                         $start     The token to start searching from.
73
+	 * @param int                         $end       The token to search to.
74
+	 * @param array                       $tokens    The stack of tokens that make up
75
+	 *                                               the file.
76
+	 *
77
+	 * @return array
78
+	 */
79
+	private function searchForConflict($phpcsFile, $start, $end, $tokens)
80
+	{
81
+		$symbols = [
82
+			T_CLASS     => T_CLASS,
83
+			T_INTERFACE => T_INTERFACE,
84
+			T_TRAIT     => T_TRAIT,
85
+			T_FUNCTION  => T_FUNCTION,
86
+		];
87
+
88
+		$conditions = [
89
+			T_IF     => T_IF,
90
+			T_ELSE   => T_ELSE,
91
+			T_ELSEIF => T_ELSEIF,
92
+		];
93
+
94
+		$checkAnnotations = $phpcsFile->config->annotations;
95
+
96
+		$firstSymbol = null;
97
+		$firstEffect = null;
98
+		for ($i = $start; $i <= $end; $i++) {
99
+			// Respect phpcs:disable comments.
100
+			if ($checkAnnotations === true
101
+				&& $tokens[$i]['code'] === T_PHPCS_DISABLE
102
+				&& (empty($tokens[$i]['sniffCodes']) === true
103
+				|| isset($tokens[$i]['sniffCodes']['PSR1']) === true
104
+				|| isset($tokens[$i]['sniffCodes']['PSR1.Files']) === true
105
+				|| isset($tokens[$i]['sniffCodes']['PSR1.Files.SideEffects']) === true)
106
+			) {
107
+				do {
108
+					$i = $phpcsFile->findNext(T_PHPCS_ENABLE, ($i + 1));
109
+				} while ($i !== false
110
+					&& empty($tokens[$i]['sniffCodes']) === false
111
+					&& isset($tokens[$i]['sniffCodes']['PSR1']) === false
112
+					&& isset($tokens[$i]['sniffCodes']['PSR1.Files']) === false
113
+					&& isset($tokens[$i]['sniffCodes']['PSR1.Files.SideEffects']) === false);
114
+
115
+				if ($i === false) {
116
+					// The entire rest of the file is disabled,
117
+					// so return what we have so far.
118
+					break;
119
+				}
120
+
121
+				continue;
122
+			}
123
+
124
+			// Ignore whitespace and comments.
125
+			if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
126
+				continue;
127
+			}
128
+
129
+			// Ignore PHP tags.
130
+			if ($tokens[$i]['code'] === T_OPEN_TAG
131
+				|| $tokens[$i]['code'] === T_CLOSE_TAG
132
+			) {
133
+				continue;
134
+			}
135
+
136
+			// Ignore shebang.
137
+			if (substr($tokens[$i]['content'], 0, 2) === '#!') {
138
+				continue;
139
+			}
140
+
141
+			// Ignore logical operators.
142
+			if (isset(Tokens::$booleanOperators[$tokens[$i]['code']]) === true) {
143
+				continue;
144
+			}
145
+
146
+			// Ignore entire namespace, declare, const and use statements.
147
+			if ($tokens[$i]['code'] === T_NAMESPACE
148
+				|| $tokens[$i]['code'] === T_USE
149
+				|| $tokens[$i]['code'] === T_DECLARE
150
+				|| $tokens[$i]['code'] === T_CONST
151
+			) {
152
+				if (isset($tokens[$i]['scope_opener']) === true) {
153
+					$i = $tokens[$i]['scope_closer'];
154
+					if ($tokens[$i]['code'] === T_ENDDECLARE) {
155
+						$semicolon = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
156
+						if ($semicolon !== false && $tokens[$semicolon]['code'] === T_SEMICOLON) {
157
+							$i = $semicolon;
158
+						}
159
+					}
160
+				} else {
161
+					$semicolon = $phpcsFile->findNext(T_SEMICOLON, ($i + 1));
162
+					if ($semicolon !== false) {
163
+						$i = $semicolon;
164
+					}
165
+				}
166
+
167
+				continue;
168
+			}
169
+
170
+			// Ignore function/class prefixes.
171
+			if (isset(Tokens::$methodPrefixes[$tokens[$i]['code']]) === true) {
172
+				continue;
173
+			}
174
+
175
+			// Ignore anon classes.
176
+			if ($tokens[$i]['code'] === T_ANON_CLASS) {
177
+				$i = $tokens[$i]['scope_closer'];
178
+				continue;
179
+			}
180
+
181
+			// Ignore attributes.
182
+			if ($tokens[$i]['code'] === T_ATTRIBUTE
183
+				&& isset($tokens[$i]['attribute_closer']) === true
184
+			) {
185
+				$i = $tokens[$i]['attribute_closer'];
186
+				continue;
187
+			}
188
+
189
+			// Detect and skip over symbols.
190
+			if (isset($symbols[$tokens[$i]['code']]) === true
191
+				&& isset($tokens[$i]['scope_closer']) === true
192
+			) {
193
+				if ($firstSymbol === null) {
194
+					$firstSymbol = $i;
195
+				}
196
+
197
+				$i = $tokens[$i]['scope_closer'];
198
+				continue;
199
+			} else if ($tokens[$i]['code'] === T_STRING
200
+				&& strtolower($tokens[$i]['content']) === 'define'
201
+			) {
202
+				$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
203
+				if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
204
+					&& $tokens[$prev]['code'] !== T_NULLSAFE_OBJECT_OPERATOR
205
+					&& $tokens[$prev]['code'] !== T_DOUBLE_COLON
206
+					&& $tokens[$prev]['code'] !== T_FUNCTION
207
+				) {
208
+					if ($firstSymbol === null) {
209
+						$firstSymbol = $i;
210
+					}
211
+
212
+					$semicolon = $phpcsFile->findNext(T_SEMICOLON, ($i + 1));
213
+					if ($semicolon !== false) {
214
+						$i = $semicolon;
215
+					}
216
+
217
+					continue;
218
+				}
219
+			}//end if
220
+
221
+			// Special case for defined() as it can be used to see
222
+			// if a constant (a symbol) should be defined or not and
223
+			// doesn't need to use a full conditional block.
224
+			if ($tokens[$i]['code'] === T_STRING
225
+				&& strtolower($tokens[$i]['content']) === 'defined'
226
+			) {
227
+				$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
228
+				if ($openBracket !== false
229
+					&& $tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS
230
+					&& isset($tokens[$openBracket]['parenthesis_closer']) === true
231
+				) {
232
+					$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
233
+					if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
234
+						&& $tokens[$prev]['code'] !== T_NULLSAFE_OBJECT_OPERATOR
235
+						&& $tokens[$prev]['code'] !== T_DOUBLE_COLON
236
+						&& $tokens[$prev]['code'] !== T_FUNCTION
237
+					) {
238
+						$i = $tokens[$openBracket]['parenthesis_closer'];
239
+						continue;
240
+					}
241
+				}
242
+			}//end if
243
+
244
+			// Conditional statements are allowed in symbol files as long as the
245
+			// contents is only a symbol definition. So don't count these as effects
246
+			// in this case.
247
+			if (isset($conditions[$tokens[$i]['code']]) === true) {
248
+				if (isset($tokens[$i]['scope_opener']) === false) {
249
+					// Probably an "else if", so just ignore.
250
+					continue;
251
+				}
252
+
253
+				$result = $this->searchForConflict(
254
+					$phpcsFile,
255
+					($tokens[$i]['scope_opener'] + 1),
256
+					($tokens[$i]['scope_closer'] - 1),
257
+					$tokens
258
+				);
259
+
260
+				if ($result['symbol'] !== null) {
261
+					if ($firstSymbol === null) {
262
+						$firstSymbol = $result['symbol'];
263
+					}
264
+
265
+					if ($result['effect'] !== null) {
266
+						// Found a conflict.
267
+						$firstEffect = $result['effect'];
268
+						break;
269
+					}
270
+				}
271
+
272
+				if ($firstEffect === null) {
273
+					$firstEffect = $result['effect'];
274
+				}
275
+
276
+				$i = $tokens[$i]['scope_closer'];
277
+				continue;
278
+			}//end if
279
+
280
+			if ($firstEffect === null) {
281
+				$firstEffect = $i;
282
+			}
283
+
284
+			if ($firstSymbol !== null) {
285
+				// We have a conflict we have to report, so no point continuing.
286
+				break;
287
+			}
288
+		}//end for
289
+
290
+		return [
291
+			'symbol' => $firstSymbol,
292
+			'effect' => $firstEffect,
293
+		];
294
+
295
+	}//end searchForConflict()
296 296
 
297 297
 
298 298
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,59 +16,59 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Returns an array of tokens this test wants to listen for.
21
-     *
22
-     * @return array
23
-     */
24
-    public function register()
25
-    {
26
-        return [
27
-            T_CLASS,
28
-            T_INTERFACE,
29
-            T_TRAIT,
30
-        ];
19
+	/**
20
+	 * Returns an array of tokens this test wants to listen for.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function register()
25
+	{
26
+		return [
27
+			T_CLASS,
28
+			T_INTERFACE,
29
+			T_TRAIT,
30
+		];
31 31
 
32
-    }//end register()
32
+	}//end register()
33 33
 
34 34
 
35
-    /**
36
-     * Processes this test, when one of its tokens is encountered.
37
-     *
38
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
-     * @param integer                     $stackPtr  The position of the current token in
40
-     *                                               the token stack.
41
-     *
42
-     * @return void
43
-     */
44
-    public function process(File $phpcsFile, $stackPtr)
45
-    {
46
-        $tokens = $phpcsFile->getTokens();
47
-        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
48
-            return;
49
-        }
35
+	/**
36
+	 * Processes this test, when one of its tokens is encountered.
37
+	 *
38
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
+	 * @param integer                     $stackPtr  The position of the current token in
40
+	 *                                               the token stack.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function process(File $phpcsFile, $stackPtr)
45
+	{
46
+		$tokens = $phpcsFile->getTokens();
47
+		if (isset($tokens[$stackPtr]['scope_closer']) === false) {
48
+			return;
49
+		}
50 50
 
51
-        $errorData = [strtolower($tokens[$stackPtr]['content'])];
51
+		$errorData = [strtolower($tokens[$stackPtr]['content'])];
52 52
 
53
-        $nextClass = $phpcsFile->findNext([T_CLASS, T_INTERFACE, T_TRAIT], ($tokens[$stackPtr]['scope_closer'] + 1));
54
-        if ($nextClass !== false) {
55
-            $error = 'Each %s must be in a file by itself';
56
-            $phpcsFile->addError($error, $nextClass, 'MultipleClasses', $errorData);
57
-            $phpcsFile->recordMetric($stackPtr, 'One class per file', 'no');
58
-        } else {
59
-            $phpcsFile->recordMetric($stackPtr, 'One class per file', 'yes');
60
-        }
53
+		$nextClass = $phpcsFile->findNext([T_CLASS, T_INTERFACE, T_TRAIT], ($tokens[$stackPtr]['scope_closer'] + 1));
54
+		if ($nextClass !== false) {
55
+			$error = 'Each %s must be in a file by itself';
56
+			$phpcsFile->addError($error, $nextClass, 'MultipleClasses', $errorData);
57
+			$phpcsFile->recordMetric($stackPtr, 'One class per file', 'no');
58
+		} else {
59
+			$phpcsFile->recordMetric($stackPtr, 'One class per file', 'yes');
60
+		}
61 61
 
62
-        $namespace = $phpcsFile->findNext([T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT], 0);
63
-        if ($tokens[$namespace]['code'] !== T_NAMESPACE) {
64
-            $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)';
65
-            $phpcsFile->addError($error, $stackPtr, 'MissingNamespace', $errorData);
66
-            $phpcsFile->recordMetric($stackPtr, 'Class defined in namespace', 'no');
67
-        } else {
68
-            $phpcsFile->recordMetric($stackPtr, 'Class defined in namespace', 'yes');
69
-        }
62
+		$namespace = $phpcsFile->findNext([T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT], 0);
63
+		if ($tokens[$namespace]['code'] !== T_NAMESPACE) {
64
+			$error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)';
65
+			$phpcsFile->addError($error, $stackPtr, 'MissingNamespace', $errorData);
66
+			$phpcsFile->recordMetric($stackPtr, 'Class defined in namespace', 'no');
67
+		} else {
68
+			$phpcsFile->recordMetric($stackPtr, 'Class defined in namespace', 'yes');
69
+		}
70 70
 
71
-    }//end process()
71
+	}//end process()
72 72
 
73 73
 
74 74
 }//end class
Please login to merge, or discard this patch.
src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.inc 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -2,69 +2,69 @@
 block discarded – undo
2 2
 
3 3
 function test()
4 4
 {
5
-    // Body here.
5
+	// Body here.
6 6
 }
7 7
 
8 8
 function test()
9 9
 {
10
-    echo 'foo';}
10
+	echo 'foo';}
11 11
 
12 12
 function test()
13 13
 {
14
-    // Body here.
14
+	// Body here.
15 15
 
16 16
 }
17 17
 
18 18
 function test()
19 19
 {
20
-    // Body here.
20
+	// Body here.
21 21
 
22 22
 
23 23
 }
24 24
 
25 25
 class MyClass
26 26
 {
27
-    function test()
28
-    {
29
-        // Body here.
30
-    }
27
+	function test()
28
+	{
29
+		// Body here.
30
+	}
31 31
 
32
-    function test()
33
-    {
34
-        echo 'foo';}
32
+	function test()
33
+	{
34
+		echo 'foo';}
35 35
 
36
-    function test()
37
-    {
38
-        // Body here.
36
+	function test()
37
+	{
38
+		// Body here.
39 39
 
40
-    }
40
+	}
41 41
 
42
-    function test()
43
-    {
44
-        // Body here.
42
+	function test()
43
+	{
44
+		// Body here.
45 45
 
46 46
 
47
-    }
47
+	}
48 48
 }
49 49
 
50 50
 $foo = function test()
51 51
 {
52
-    // Body here.
52
+	// Body here.
53 53
 };
54 54
 
55 55
 $foo = function test()
56 56
 {
57
-     echo 'foo';};
57
+	 echo 'foo';};
58 58
 
59 59
 $foo = function test()
60 60
 {
61
-    // Body here.
61
+	// Body here.
62 62
 
63 63
 };
64 64
 
65 65
 $foo = function test()
66 66
 {
67
-    // Body here.
67
+	// Body here.
68 68
 
69 69
 
70 70
 };
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 function test()
9 9
 {
10
-    echo 'foo';}
10
+    echo 'foo'; }
11 11
 
12 12
 function test()
13 13
 {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     function test()
33 33
     {
34
-        echo 'foo';}
34
+        echo 'foo'; }
35 35
 
36 36
     function test()
37 37
     {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 $foo = function test()
56 56
 {
57
-     echo 'foo';};
57
+     echo 'foo'; };
58 58
 
59 59
 $foo = function test()
60 60
 {
Please login to merge, or discard this patch.
src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -15,41 +15,41 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @return array<int, int>
25
-     */
26
-    public function getErrorList()
27
-    {
28
-        return [
29
-            16 => 1,
30
-            23 => 1,
31
-            40 => 1,
32
-            47 => 1,
33
-            63 => 1,
34
-            70 => 1,
35
-        ];
36
-
37
-    }//end getErrorList()
38
-
39
-
40
-    /**
41
-     * Returns the lines where warnings should occur.
42
-     *
43
-     * The key of the array should represent the line number and the value
44
-     * should represent the number of warnings that should occur on that line.
45
-     *
46
-     * @return array<int, int>
47
-     */
48
-    public function getWarningList()
49
-    {
50
-        return [];
51
-
52
-    }//end getWarningList()
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @return array<int, int>
25
+	 */
26
+	public function getErrorList()
27
+	{
28
+		return [
29
+			16 => 1,
30
+			23 => 1,
31
+			40 => 1,
32
+			47 => 1,
33
+			63 => 1,
34
+			70 => 1,
35
+		];
36
+
37
+	}//end getErrorList()
38
+
39
+
40
+	/**
41
+	 * Returns the lines where warnings should occur.
42
+	 *
43
+	 * The key of the array should represent the line number and the value
44
+	 * should represent the number of warnings that should occur on that line.
45
+	 *
46
+	 * @return array<int, int>
47
+	 */
48
+	public function getWarningList()
49
+	{
50
+		return [];
51
+
52
+	}//end getWarningList()
53 53
 
54 54
 
55 55
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
      *
26 26
      * @return array<int, int>
27 27
      */
28
-    public function getErrorList($testFile='')
28
+    public function getErrorList($testFile = '')
29 29
     {
30 30
         switch ($testFile) {
31 31
         case 'ClosingTagUnitTest.1.inc':
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @param string $testFile The name of the file being tested.
25
-     *
26
-     * @return array<int, int>
27
-     */
28
-    public function getErrorList($testFile='')
29
-    {
30
-        switch ($testFile) {
31
-        case 'ClosingTagUnitTest.1.inc':
32
-            return [11 => 1];
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @param string $testFile The name of the file being tested.
25
+	 *
26
+	 * @return array<int, int>
27
+	 */
28
+	public function getErrorList($testFile='')
29
+	{
30
+		switch ($testFile) {
31
+		case 'ClosingTagUnitTest.1.inc':
32
+			return [11 => 1];
33 33
 
34
-        case 'ClosingTagUnitTest.4.inc':
35
-        case 'ClosingTagUnitTest.5.inc':
36
-            return [1 => 1];
34
+		case 'ClosingTagUnitTest.4.inc':
35
+		case 'ClosingTagUnitTest.5.inc':
36
+			return [1 => 1];
37 37
 
38
-        case 'ClosingTagUnitTest.6.inc':
39
-        case 'ClosingTagUnitTest.7.inc':
40
-            return [5 => 1];
38
+		case 'ClosingTagUnitTest.6.inc':
39
+		case 'ClosingTagUnitTest.7.inc':
40
+			return [5 => 1];
41 41
 
42
-        default:
43
-            return [];
44
-        }
42
+		default:
43
+			return [];
44
+		}
45 45
 
46
-    }//end getErrorList()
46
+	}//end getErrorList()
47 47
 
48 48
 
49
-    /**
50
-     * Returns the lines where warnings should occur.
51
-     *
52
-     * The key of the array should represent the line number and the value
53
-     * should represent the number of warnings that should occur on that line.
54
-     *
55
-     * @return array<int, int>
56
-     */
57
-    public function getWarningList()
58
-    {
59
-        return [];
49
+	/**
50
+	 * Returns the lines where warnings should occur.
51
+	 *
52
+	 * The key of the array should represent the line number and the value
53
+	 * should represent the number of warnings that should occur on that line.
54
+	 *
55
+	 * @return array<int, int>
56
+	 */
57
+	public function getWarningList()
58
+	{
59
+		return [];
60 60
 
61
-    }//end getWarningList()
61
+	}//end getWarningList()
62 62
 
63 63
 
64 64
 }//end class
Please login to merge, or discard this patch.
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,19 +28,19 @@
 block discarded – undo
28 28
     public function getErrorList($testFile='')
29 29
     {
30 30
         switch ($testFile) {
31
-        case 'ClosingTagUnitTest.1.inc':
32
-            return [11 => 1];
31
+        	case 'ClosingTagUnitTest.1.inc':
32
+            	return [11 => 1];
33 33
 
34
-        case 'ClosingTagUnitTest.4.inc':
35
-        case 'ClosingTagUnitTest.5.inc':
36
-            return [1 => 1];
34
+        	case 'ClosingTagUnitTest.4.inc':
35
+        	case 'ClosingTagUnitTest.5.inc':
36
+            	return [1 => 1];
37 37
 
38
-        case 'ClosingTagUnitTest.6.inc':
39
-        case 'ClosingTagUnitTest.7.inc':
40
-            return [5 => 1];
38
+        	case 'ClosingTagUnitTest.6.inc':
39
+        	case 'ClosingTagUnitTest.7.inc':
40
+            	return [5 => 1];
41 41
 
42
-        default:
43
-            return [];
42
+        	default:
43
+            	return [];
44 44
         }
45 45
 
46 46
     }//end getErrorList()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      *
26 26
      * @return array<int, int>
27 27
      */
28
-    public function getErrorList($testFile='')
28
+    public function getErrorList($testFile = '')
29 29
     {
30 30
         switch ($testFile) {
31 31
         case 'EndFileNewlineUnitTest.1.inc':
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return array<int, int>
59 59
      */
60
-    public function getWarningList($testFile='')
60
+    public function getWarningList($testFile = '')
61 61
     {
62 62
         return [];
63 63
 
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -15,52 +15,52 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @param string $testFile The name of the file being tested.
25
-     *
26
-     * @return array<int, int>
27
-     */
28
-    public function getErrorList($testFile='')
29
-    {
30
-        switch ($testFile) {
31
-        case 'EndFileNewlineUnitTest.1.inc':
32
-        case 'EndFileNewlineUnitTest.3.inc':
33
-        case 'EndFileNewlineUnitTest.6.inc':
34
-        case 'EndFileNewlineUnitTest.7.inc':
35
-        case 'EndFileNewlineUnitTest.9.inc':
36
-        case 'EndFileNewlineUnitTest.10.inc':
37
-            return [2 => 1];
38
-        case 'EndFileNewlineUnitTest.11.inc':
39
-        case 'EndFileNewlineUnitTest.12.inc':
40
-        case 'EndFileNewlineUnitTest.13.inc':
41
-            return [1 => 1];
42
-        default:
43
-            return [];
44
-        }//end switch
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @param string $testFile The name of the file being tested.
25
+	 *
26
+	 * @return array<int, int>
27
+	 */
28
+	public function getErrorList($testFile='')
29
+	{
30
+		switch ($testFile) {
31
+		case 'EndFileNewlineUnitTest.1.inc':
32
+		case 'EndFileNewlineUnitTest.3.inc':
33
+		case 'EndFileNewlineUnitTest.6.inc':
34
+		case 'EndFileNewlineUnitTest.7.inc':
35
+		case 'EndFileNewlineUnitTest.9.inc':
36
+		case 'EndFileNewlineUnitTest.10.inc':
37
+			return [2 => 1];
38
+		case 'EndFileNewlineUnitTest.11.inc':
39
+		case 'EndFileNewlineUnitTest.12.inc':
40
+		case 'EndFileNewlineUnitTest.13.inc':
41
+			return [1 => 1];
42
+		default:
43
+			return [];
44
+		}//end switch
45 45
 
46
-    }//end getErrorList()
46
+	}//end getErrorList()
47 47
 
48 48
 
49
-    /**
50
-     * Returns the lines where warnings should occur.
51
-     *
52
-     * The key of the array should represent the line number and the value
53
-     * should represent the number of warnings that should occur on that line.
54
-     *
55
-     * @param string $testFile The name of the file being tested.
56
-     *
57
-     * @return array<int, int>
58
-     */
59
-    public function getWarningList($testFile='')
60
-    {
61
-        return [];
49
+	/**
50
+	 * Returns the lines where warnings should occur.
51
+	 *
52
+	 * The key of the array should represent the line number and the value
53
+	 * should represent the number of warnings that should occur on that line.
54
+	 *
55
+	 * @param string $testFile The name of the file being tested.
56
+	 *
57
+	 * @return array<int, int>
58
+	 */
59
+	public function getWarningList($testFile='')
60
+	{
61
+		return [];
62 62
 
63
-    }//end getWarningList()
63
+	}//end getWarningList()
64 64
 
65 65
 
66 66
 }//end class
Please login to merge, or discard this patch.
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -28,19 +28,19 @@
 block discarded – undo
28 28
     public function getErrorList($testFile='')
29 29
     {
30 30
         switch ($testFile) {
31
-        case 'EndFileNewlineUnitTest.1.inc':
32
-        case 'EndFileNewlineUnitTest.3.inc':
33
-        case 'EndFileNewlineUnitTest.6.inc':
34
-        case 'EndFileNewlineUnitTest.7.inc':
35
-        case 'EndFileNewlineUnitTest.9.inc':
36
-        case 'EndFileNewlineUnitTest.10.inc':
37
-            return [2 => 1];
38
-        case 'EndFileNewlineUnitTest.11.inc':
39
-        case 'EndFileNewlineUnitTest.12.inc':
40
-        case 'EndFileNewlineUnitTest.13.inc':
41
-            return [1 => 1];
42
-        default:
43
-            return [];
31
+        	case 'EndFileNewlineUnitTest.1.inc':
32
+        	case 'EndFileNewlineUnitTest.3.inc':
33
+        	case 'EndFileNewlineUnitTest.6.inc':
34
+        	case 'EndFileNewlineUnitTest.7.inc':
35
+        	case 'EndFileNewlineUnitTest.9.inc':
36
+        	case 'EndFileNewlineUnitTest.10.inc':
37
+            	return [2 => 1];
38
+        	case 'EndFileNewlineUnitTest.11.inc':
39
+        	case 'EndFileNewlineUnitTest.12.inc':
40
+        	case 'EndFileNewlineUnitTest.13.inc':
41
+            	return [1 => 1];
42
+        	default:
43
+            	return [];
44 44
         }//end switch
45 45
 
46 46
     }//end getErrorList()
Please login to merge, or discard this patch.
src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 4 patches
Switch Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 }
35 35
 
36 36
 switch ($foo) {
37
-    case'Foo': {
38
-        echo 'foo';
39
-        break;
40
-        }
37
+    	case'Foo': {
38
+        	echo 'foo';
39
+        	break;
40
+        	}
41 41
 }
42 42
 
43 43
 while ($i < 10) {
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 }
53 53
 
54 54
 switch (true) {
55
-    case is_resource($value):
56
-        throw new Exception('foo');
57
-    case is_object($value):
58
-        return 'object';
55
+    	case is_resource($value):
56
+        	throw new Exception('foo');
57
+    	case is_object($value):
58
+        	return 'object';
59 59
 }
60 60
 
61 61
 switch (0) {
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 }
106 106
 
107 107
 switch ($foo) {
108
-    case 1: $bar = 1; break;
109
-    case 2:
108
+    	case 1: $bar = 1; break;
109
+    	case 2:
110 110
     
111
-        $bar = 2; break;
112
-    case 21:
113
-    case 3: return 3;
114
-    default: $bar = 0;
111
+        	$bar = 2; break;
112
+    	case 21:
113
+    	case 3: return 3;
114
+    	default: $bar = 0;
115 115
 }
116 116
 
117 117
 switch ($foo) {
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 }
147 147
 
148 148
 switch ($foo) {
149
-    case Foo::INTERFACE:
150
-        return self::INTERFACE;
151
-    case Foo::NAMESPACE:
152
-        return self::MODULE;
153
-    case Foo::TRAIT:
154
-    case Foo::ARRAY:
155
-        return self::VALUE;
149
+    	case Foo::INTERFACE:
150
+        	return self::INTERFACE;
151
+    	case Foo::NAMESPACE:
152
+        	return self::MODULE;
153
+    	case Foo::TRAIT:
154
+    	case Foo::ARRAY:
155
+        	return self::VALUE;
156 156
 }
157 157
 
158 158
 // OK: Every clause terminates
Please login to merge, or discard this patch.
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -1,586 +1,586 @@
 block discarded – undo
1 1
 <?php
2 2
 switch ($expr) {
3
-    case 0:
4
-        echo 'First case, with a break';
5
-        break;
6
-    case 1:
7
-        echo 'Second case, which falls through';
8
-        // no break
9
-    case 2:
10
-    case   3:
11
-    Case 4:
12
-        echo 'Third case, return instead of break';
13
-        return;
14
-    Default:
15
-        echo 'Default case';
16
-            break;
3
+	case 0:
4
+		echo 'First case, with a break';
5
+		break;
6
+	case 1:
7
+		echo 'Second case, which falls through';
8
+		// no break
9
+	case 2:
10
+	case   3:
11
+	Case 4:
12
+		echo 'Third case, return instead of break';
13
+		return;
14
+	Default:
15
+		echo 'Default case';
16
+			break;
17 17
 }
18 18
 
19 19
 switch ($expr) {
20
-    case 0:
21
-        echo 'First case,';
20
+	case 0:
21
+		echo 'First case,';
22 22
 
23
-    case 1 :
24
-        echo 'Second case';
25
-        // no break
26
-    case 2:
27
-    case 3:
28
-        echo 'Third case';
29
-    return;
23
+	case 1 :
24
+		echo 'Second case';
25
+		// no break
26
+	case 2:
27
+	case 3:
28
+		echo 'Third case';
29
+	return;
30 30
 
31
-    default:
32
-        echo 'Default case';
33
-    break;
31
+	default:
32
+		echo 'Default case';
33
+	break;
34 34
 }
35 35
 
36 36
 switch ($foo) {
37
-    case'Foo': {
38
-        echo 'foo';
39
-        break;
40
-        }
37
+	case'Foo': {
38
+		echo 'foo';
39
+		break;
40
+		}
41 41
 }
42 42
 
43 43
 while ($i < 10) {
44
-    switch ($foo) {
45
-        case '1':
46
-        case '2':
47
-            ++$i;
48
-            continue 2;
49
-        case '3':
50
-            return $i;
51
-    }
44
+	switch ($foo) {
45
+		case '1':
46
+		case '2':
47
+			++$i;
48
+			continue 2;
49
+		case '3':
50
+			return $i;
51
+	}
52 52
 }
53 53
 
54 54
 switch (true) {
55
-    case is_resource($value):
56
-        throw new Exception('foo');
57
-    case is_object($value):
58
-        return 'object';
55
+	case is_resource($value):
56
+		throw new Exception('foo');
57
+	case is_object($value):
58
+		return 'object';
59 59
 }
60 60
 
61 61
 switch (0) {
62
-    case 0:
63
-        switch (1) {
64
-            case 1:
65
-                echo 'a';
66
-                break;
67
-        }
68
-        break;
62
+	case 0:
63
+		switch (1) {
64
+			case 1:
65
+				echo 'a';
66
+				break;
67
+		}
68
+		break;
69 69
 }
70 70
 
71 71
 switch ($foo) {
72
-    case Foo::ONE:
73
-    case Foo::TWO:
74
-    case Foo::Class:
75
-        break;
72
+	case Foo::ONE:
73
+	case Foo::TWO:
74
+	case Foo::Class:
75
+		break;
76 76
 }
77 77
 
78 78
 switch (true) {
79
-    case $value instanceof StdClass:
80
-        return 1;
81
-    case strpos('_', get_class($value)) !== false:
82
-        break;
79
+	case $value instanceof StdClass:
80
+		return 1;
81
+	case strpos('_', get_class($value)) !== false:
82
+		break;
83 83
 }
84 84
 
85 85
 switch (true) {
86
-    case $value instanceof StdClass:
87
-        if ($value) {
88
-            return null;
89
-        }
86
+	case $value instanceof StdClass:
87
+		if ($value) {
88
+			return null;
89
+		}
90 90
 }
91 91
 
92 92
 use Vendor\Test\FooBar;
93 93
 
94 94
 function test()
95 95
 {
96
-    switch ($val) {
97
-        case 'foo':
98
-            echo 'foo';
99
-            break;
100
-        default:
101
-            echo 'foo';
102
-    }
96
+	switch ($val) {
97
+		case 'foo':
98
+			echo 'foo';
99
+			break;
100
+		default:
101
+			echo 'foo';
102
+	}
103 103
 
104
-    exit;
104
+	exit;
105 105
 }
106 106
 
107 107
 switch ($foo) {
108
-    case 1: $bar = 1; break;
109
-    case 2:
108
+	case 1: $bar = 1; break;
109
+	case 2:
110 110
     
111
-        $bar = 2; break;
112
-    case 21:
113
-    case 3: return 3;
114
-    default: $bar = 0;
111
+		$bar = 2; break;
112
+	case 21:
113
+	case 3: return 3;
114
+	default: $bar = 0;
115 115
 }
116 116
 
117 117
 switch ($foo) {
118
-    case 'foo': // some comment
119
-        echo 'foo';
120
-        break;
121
-    case 'bar':
122
-        // some comment
123
-        echo 'bar';
124
-        break;
125
-    case 'baz': // phpcs:ignore Standard.Category.Sniff
126
-        echo 'baz';
127
-        break;
128
-    case 'boo':
129
-
130
-        // other comment
131
-        echo 'boo';
132
-        break;
133
-    default: // other comment
134
-        echo 'default';
135
-        break;
118
+	case 'foo': // some comment
119
+		echo 'foo';
120
+		break;
121
+	case 'bar':
122
+		// some comment
123
+		echo 'bar';
124
+		break;
125
+	case 'baz': // phpcs:ignore Standard.Category.Sniff
126
+		echo 'baz';
127
+		break;
128
+	case 'boo':
129
+
130
+		// other comment
131
+		echo 'boo';
132
+		break;
133
+	default: // other comment
134
+		echo 'default';
135
+		break;
136 136
 }
137 137
 
138 138
 switch($foo)
139 139
 {
140
-    case ('foo'):
141
-    default:
142
-    {
143
-        $foo = 'foo';
144
-        break;
145
-    }
140
+	case ('foo'):
141
+	default:
142
+	{
143
+		$foo = 'foo';
144
+		break;
145
+	}
146 146
 }
147 147
 
148 148
 switch ($foo) {
149
-    case Foo::INTERFACE:
150
-        return self::INTERFACE;
151
-    case Foo::NAMESPACE:
152
-        return self::MODULE;
153
-    case Foo::TRAIT:
154
-    case Foo::ARRAY:
155
-        return self::VALUE;
149
+	case Foo::INTERFACE:
150
+		return self::INTERFACE;
151
+	case Foo::NAMESPACE:
152
+		return self::MODULE;
153
+	case Foo::TRAIT:
154
+	case Foo::ARRAY:
155
+		return self::VALUE;
156 156
 }
157 157
 
158 158
 // OK: Every clause terminates
159 159
 switch ($foo) {
160
-    case 1:
161
-        if ($bar > 0) {
162
-            return 0;
163
-        } else {
164
-            return 1;
165
-        }
166
-    case 2:
167
-        return 2;
160
+	case 1:
161
+		if ($bar > 0) {
162
+			return 0;
163
+		} else {
164
+			return 1;
165
+		}
166
+	case 2:
167
+		return 2;
168 168
 }
169 169
 
170 170
 // ERROR: No else clause
171 171
 switch ($foo) {
172
-    case 1:
173
-        if ($bar > 0) {
174
-            return 0;
175
-        } elseif ($bar < 0) {
176
-            return 1;
177
-        }
178
-    case 2:
179
-        return 2;
172
+	case 1:
173
+		if ($bar > 0) {
174
+			return 0;
175
+		} elseif ($bar < 0) {
176
+			return 1;
177
+		}
178
+	case 2:
179
+		return 2;
180 180
 }
181 181
 
182 182
 // OK: No fall-through present
183 183
 switch ($foo) {
184
-    case 1:
185
-        if ($bar > 0) {
186
-            return 0;
187
-        } elseif ($bar < 0) {
188
-            return 1;
189
-        }
184
+	case 1:
185
+		if ($bar > 0) {
186
+			return 0;
187
+		} elseif ($bar < 0) {
188
+			return 1;
189
+		}
190 190
 }
191 191
 
192 192
 // ERROR: No else clause (nested)
193 193
 switch ($foo) {
194
-    case 1:
195
-        if ($bar > 0) {
196
-            return 0;
197
-        } else {
198
-            if ($foo > $bar) {
199
-                continue;
200
-            }
201
-        }
202
-    case 2:
203
-        return 2;
194
+	case 1:
195
+		if ($bar > 0) {
196
+			return 0;
197
+		} else {
198
+			if ($foo > $bar) {
199
+				continue;
200
+			}
201
+		}
202
+	case 2:
203
+		return 2;
204 204
 }
205 205
 
206 206
 // OK: Every clause terminates
207 207
 switch ($foo) {
208
-    case 1:
209
-        if ($bar > 0) {
210
-            return 0;
211
-        } else {
212
-            if ($foo > $bar) {
213
-                continue;
214
-            } else {
215
-                break;
216
-            }
217
-        }
218
-    case 2:
219
-        return 2;
208
+	case 1:
209
+		if ($bar > 0) {
210
+			return 0;
211
+		} else {
212
+			if ($foo > $bar) {
213
+				continue;
214
+			} else {
215
+				break;
216
+			}
217
+		}
218
+	case 2:
219
+		return 2;
220 220
 }
221 221
 
222 222
 // ERROR: Non-termination IF clause
223 223
 switch ($foo) {
224
-    case 1:
225
-        if ($bar > 0) {
226
-            $offset = 0;
227
-        } else {
228
-            break;
229
-        }
230
-    case 2:
231
-        return 2;
224
+	case 1:
225
+		if ($bar > 0) {
226
+			$offset = 0;
227
+		} else {
228
+			break;
229
+		}
230
+	case 2:
231
+		return 2;
232 232
 }
233 233
 
234 234
 // ERROR: Non-termination IF clause (nested)
235 235
 switch ($foo) {
236
-    case 1:
237
-        if ($bar > 0) {
238
-            continue;
239
-        } else {
240
-            if ($foo > $bar) {
241
-                $offset = 0;
242
-            } else {
243
-                break;
244
-            }
245
-        }
246
-    case 2:
247
-        return 2;
236
+	case 1:
237
+		if ($bar > 0) {
238
+			continue;
239
+		} else {
240
+			if ($foo > $bar) {
241
+				$offset = 0;
242
+			} else {
243
+				break;
244
+			}
245
+		}
246
+	case 2:
247
+		return 2;
248 248
 }
249 249
 
250 250
 switch ($sContext)
251 251
 {
252
-    case 'SOMETHING':
253
-    case 'CONSTANT':
254
-        do_something();
255
-        break;
256
-    case 'GLOBAL':
257
-    case 'GLOBAL1':
258
-        do_something();
259
-        // Fall through
260
-    default:
261
-    {
262
-        do_something();
263
-    }
252
+	case 'SOMETHING':
253
+	case 'CONSTANT':
254
+		do_something();
255
+		break;
256
+	case 'GLOBAL':
257
+	case 'GLOBAL1':
258
+		do_something();
259
+		// Fall through
260
+	default:
261
+	{
262
+		do_something();
263
+	}
264 264
 }
265 265
 
266 266
 $foo = $foo ?
267
-    function () {
268
-        switch ($a) {
269
-            case 'a':
270
-                break;
271
-        }
272
-    } :
273
-    null;
267
+	function () {
268
+		switch ($a) {
269
+			case 'a':
270
+				break;
271
+		}
272
+	} :
273
+	null;
274 274
 
275 275
 switch ($foo) {
276 276
 case Foo::INTERFACE:
277
-    echo '1';
278
-    return self::INTERFACE;
277
+	echo '1';
278
+	return self::INTERFACE;
279 279
 case Foo::TRAIT:
280 280
 case Foo::ARRAY:
281
-    echo '1';
282
-    return self::VALUE;
281
+	echo '1';
282
+	return self::VALUE;
283 283
 }
284 284
 
285 285
 // OK: Every clause terminates
286 286
 switch ($foo) {
287
-    case 1:
288
-        switch ($bar) {
289
-            case 1:
290
-                return 1;
291
-            default:
292
-                return 3;
293
-        }
294
-    case 2:
295
-        return 2;
287
+	case 1:
288
+		switch ($bar) {
289
+			case 1:
290
+				return 1;
291
+			default:
292
+				return 3;
293
+		}
294
+	case 2:
295
+		return 2;
296 296
 }
297 297
 
298 298
 // KO: Not every clause terminates
299 299
 switch ($foo) {
300
-    case 1:
301
-        switch ($bar) {
302
-            case 1:
303
-                return;
304
-        }
305
-    case 2:
306
-        return 2;
300
+	case 1:
301
+		switch ($bar) {
302
+			case 1:
303
+				return;
304
+		}
305
+	case 2:
306
+		return 2;
307 307
 }
308 308
 
309 309
 // KO: Not every clause terminates
310 310
 switch ($foo) {
311
-    case 1:
312
-        switch ($bar) {
313
-            case 1:
314
-                return;
315
-            default:
316
-                $a = 1;
317
-        }
318
-    case 2:
319
-        return 2;
311
+	case 1:
312
+		switch ($bar) {
313
+			case 1:
314
+				return;
315
+			default:
316
+				$a = 1;
317
+		}
318
+	case 2:
319
+		return 2;
320 320
 }
321 321
 
322 322
 // OK: Every clause terminates
323 323
 switch ($foo) {
324
-    case 1:
325
-        switch ($bar) {
326
-            case 1:
327
-                return 1;
328
-            default:
329
-                throw new \Exception();
330
-        }
331
-    case 2:
332
-        return 2;
324
+	case 1:
325
+		switch ($bar) {
326
+			case 1:
327
+				return 1;
328
+			default:
329
+				throw new \Exception();
330
+		}
331
+	case 2:
332
+		return 2;
333 333
 }
334 334
 
335 335
 switch ($foo) {
336
-    case 1:
337
-        // phpcs:ignore
338
-    case 2:
339
-        return 1;
340
-    case 3:
341
-        return 2;
336
+	case 1:
337
+		// phpcs:ignore
338
+	case 2:
339
+		return 1;
340
+	case 3:
341
+		return 2;
342 342
 }
343 343
 
344 344
 // Issue 3352.
345 345
 switch ( $test ) {
346
-    case 2: // comment followed by empty line
346
+	case 2: // comment followed by empty line
347 347
 
348
-        break;
348
+		break;
349 349
 
350
-    case 3: /* phpcs:ignore Stnd.Cat.SniffName -- Verify correct handling of ignore comments. */
350
+	case 3: /* phpcs:ignore Stnd.Cat.SniffName -- Verify correct handling of ignore comments. */
351 351
 
352 352
 
353 353
 
354
-        break;
354
+		break;
355 355
 
356
-    case 4: /** inline docblock */
356
+	case 4: /** inline docblock */
357 357
 
358 358
 
359 359
 
360
-        break;
360
+		break;
361 361
 
362
-    case 5: /* checking how it handles */ /* two trailing comments */
362
+	case 5: /* checking how it handles */ /* two trailing comments */
363 363
 
364
-        break;
364
+		break;
365 365
 
366
-    case 6:
367
-       // Comment as first content of the body.
366
+	case 6:
367
+	   // Comment as first content of the body.
368 368
 
369
-        break;
369
+		break;
370 370
 
371
-    case 7:
372
-        /* phpcs:ignore Stnd.Cat.SniffName -- Verify correct handling of ignore comments at start of body. */
371
+	case 7:
372
+		/* phpcs:ignore Stnd.Cat.SniffName -- Verify correct handling of ignore comments at start of body. */
373 373
 
374
-        break;
374
+		break;
375 375
 
376
-    case 8:
377
-        /** inline docblock */
376
+	case 8:
377
+		/** inline docblock */
378 378
 
379
-        break;
379
+		break;
380 380
 }
381 381
 
382 382
 // Handle comments correctly.
383 383
 switch ($foo) {
384
-    case 1:
385
-        if ($bar > 0) {
386
-            doSomething();
387
-        }
388
-        // Comment
389
-        else {
390
-            return 1;
391
-        }
392
-    case 2:
393
-        return 2;
384
+	case 1:
385
+		if ($bar > 0) {
386
+			doSomething();
387
+		}
388
+		// Comment
389
+		else {
390
+			return 1;
391
+		}
392
+	case 2:
393
+		return 2;
394 394
 }
395 395
 
396 396
 switch ($foo) {
397
-    case 1:
398
-        if ($bar > 0) /*comment*/ {
399
-            return doSomething();
400
-        }
401
-        else {
402
-            return 1;
403
-        }
404
-    case 2:
405
-        return 2;
397
+	case 1:
398
+		if ($bar > 0) /*comment*/ {
399
+			return doSomething();
400
+		}
401
+		else {
402
+			return 1;
403
+		}
404
+	case 2:
405
+		return 2;
406 406
 }
407 407
 
408 408
 // Issue #3297.
409 409
 // Okay - finally will always be executed, so all branches are covered by the `return` in finally.
410 410
 switch ( $a ) {
411
-    case 1:
412
-        try {
413
-            doSomething();
414
-        } catch (Exception $e) {
415
-            doSomething();
416
-        } catch (AnotherException $e) {
417
-            doSomething();
418
-        } finally {
419
-            return true;
420
-        }
421
-    default:
422
-        $other = $code;
423
-        break;
411
+	case 1:
412
+		try {
413
+			doSomething();
414
+		} catch (Exception $e) {
415
+			doSomething();
416
+		} catch (AnotherException $e) {
417
+			doSomething();
418
+		} finally {
419
+			return true;
420
+		}
421
+	default:
422
+		$other = $code;
423
+		break;
424 424
 }
425 425
 
426 426
 // Okay - all - non-finally - branches have a terminating statement.
427 427
 switch ( $a ) {
428
-    case 1:
429
-        try {
430
-            return false;
431
-        } catch (Exception $e) /*comment*/ {
432
-            return true;
433
-        }
434
-        // Comment
435
-        catch (AnotherException $e) {
436
-            return true;
437
-        } finally {
438
-            doSomething();
439
-        }
440
-    default:
441
-        $other = $code;
442
-        break;
428
+	case 1:
429
+		try {
430
+			return false;
431
+		} catch (Exception $e) /*comment*/ {
432
+			return true;
433
+		}
434
+		// Comment
435
+		catch (AnotherException $e) {
436
+			return true;
437
+		} finally {
438
+			doSomething();
439
+		}
440
+	default:
441
+		$other = $code;
442
+		break;
443 443
 }
444 444
 
445 445
 // Okay - finally will always be executed, so all branches are covered by the `return` in finally.
446 446
 // Non-standard structure order.
447 447
 switch ( $a ) {
448
-    case 1:
449
-        try {
450
-            doSomething();
451
-        } catch (Exception $e) {
452
-            doSomething();
453
-        } finally {
454
-            return true;
455
-        } catch (AnotherException $e) {
456
-            doSomething();
457
-        }
458
-    default:
459
-        $other = $code;
460
-        break;
448
+	case 1:
449
+		try {
450
+			doSomething();
451
+		} catch (Exception $e) {
452
+			doSomething();
453
+		} finally {
454
+			return true;
455
+		} catch (AnotherException $e) {
456
+			doSomething();
457
+		}
458
+	default:
459
+		$other = $code;
460
+		break;
461 461
 }
462 462
 
463 463
 // Okay - all - non-finally - branches have a terminating statement.
464 464
 // Non-standard structure order.
465 465
 switch ( $a ) {
466
-    case 1:
467
-        try {
468
-            return false;
469
-        } finally {
470
-            doSomething();
471
-        } catch (MyException $e) {
472
-            return true;
473
-        } catch (AnotherException $e) {
474
-            return true;
475
-        }
476
-    default:
477
-        $other = $code;
478
-        break;
466
+	case 1:
467
+		try {
468
+			return false;
469
+		} finally {
470
+			doSomething();
471
+		} catch (MyException $e) {
472
+			return true;
473
+		} catch (AnotherException $e) {
474
+			return true;
475
+		}
476
+	default:
477
+		$other = $code;
478
+		break;
479 479
 }
480 480
 
481 481
 // All okay, no finally. Any exception still uncaught will terminate the case anyhow, so we're good.
482 482
 switch ( $a ) {
483
-    case 1:
484
-        try {
485
-            return false;
486
-        } catch (MyException $e) {
487
-            return true;
488
-        } catch (AnotherException $e) {
489
-            return true;
490
-        }
491
-    default:
492
-        $other = $code;
493
-        break;
483
+	case 1:
484
+		try {
485
+			return false;
486
+		} catch (MyException $e) {
487
+			return true;
488
+		} catch (AnotherException $e) {
489
+			return true;
490
+		}
491
+	default:
492
+		$other = $code;
493
+		break;
494 494
 }
495 495
 
496 496
 // All okay, no catch
497 497
 switch ( $a ) {
498
-    case 1:
499
-        try {
500
-            return true;
501
-        } finally {
502
-            doSomething();
503
-        }
504
-    case 2:
505
-        $other = $code;
506
-        break;
498
+	case 1:
499
+		try {
500
+			return true;
501
+		} finally {
502
+			doSomething();
503
+		}
504
+	case 2:
505
+		$other = $code;
506
+		break;
507 507
 }
508 508
 
509 509
 // All okay, try-catch nested in if.
510 510
 switch ( $a ) {
511
-    case 1:
512
-        if ($a) {
513
-            try {
514
-                return true;
515
-            } catch (MyException $e) {
516
-                throw new Exception($e->getMessage());
517
-            }
518
-        } else {
519
-            return true;
520
-        }
521
-    case 2:
522
-        $other = $code;
523
-        break;
511
+	case 1:
512
+		if ($a) {
513
+			try {
514
+				return true;
515
+			} catch (MyException $e) {
516
+				throw new Exception($e->getMessage());
517
+			}
518
+		} else {
519
+			return true;
520
+		}
521
+	case 2:
522
+		$other = $code;
523
+		break;
524 524
 }
525 525
 
526 526
 // Missing fall-through comment.
527 527
 switch ( $a ) {
528
-    case 1:
529
-        try {
530
-            doSomething();
531
-        } finally {
532
-            doSomething();
533
-        }
534
-    case 2:
535
-        $other = $code;
536
-        break;
528
+	case 1:
529
+		try {
530
+			doSomething();
531
+		} finally {
532
+			doSomething();
533
+		}
534
+	case 2:
535
+		$other = $code;
536
+		break;
537 537
 }
538 538
 
539 539
 // Missing fall-through comment. One of the catches does not have a terminating statement.
540 540
 switch ( $a ) {
541
-    case 1:
542
-        try {
543
-            return false;
544
-        } catch (Exception $e) {
545
-            doSomething();
546
-        } catch (AnotherException $e) {
547
-            return true;
548
-        } finally {
549
-            doSomething();
550
-        }
551
-    default:
552
-        $other = $code;
553
-        break;
541
+	case 1:
542
+		try {
543
+			return false;
544
+		} catch (Exception $e) {
545
+			doSomething();
546
+		} catch (AnotherException $e) {
547
+			return true;
548
+		} finally {
549
+			doSomething();
550
+		}
551
+	default:
552
+		$other = $code;
553
+		break;
554 554
 }
555 555
 
556 556
 // Missing fall-through comment. Try does not have a terminating statement.
557 557
 switch ( $a ) {
558
-    case 1:
559
-        try {
560
-            doSomething();
561
-        } finally {
562
-            doSomething();
563
-        } catch (Exception $e) {
564
-            return true;
565
-        } catch (AnotherException $e) {
566
-            return true;
567
-        }
568
-    default:
569
-        $other = $code;
570
-        break;
558
+	case 1:
559
+		try {
560
+			doSomething();
561
+		} finally {
562
+			doSomething();
563
+		} catch (Exception $e) {
564
+			return true;
565
+		} catch (AnotherException $e) {
566
+			return true;
567
+		}
568
+	default:
569
+		$other = $code;
570
+		break;
571 571
 }
572 572
 
573 573
 // Missing fall-through comment. One of the catches does not have a terminating statement.
574 574
 switch ( $a ) {
575
-    case 1:
576
-        try {
577
-            return false;
578
-        } catch (Exception $e) {
579
-            doSomething();
580
-        } catch (AnotherException $e) {
581
-            return true;
582
-        }
583
-    default:
584
-        $other = $code;
585
-        break;
575
+	case 1:
576
+		try {
577
+			return false;
578
+		} catch (Exception $e) {
579
+			doSomething();
580
+		} catch (AnotherException $e) {
581
+			return true;
582
+		}
583
+	default:
584
+		$other = $code;
585
+		break;
586 586
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         break;
136 136
 }
137 137
 
138
-switch($foo)
138
+switch ($foo)
139 139
 {
140 140
     case ('foo'):
141 141
     default:
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 }
265 265
 
266 266
 $foo = $foo ?
267
-    function () {
267
+    function() {
268 268
         switch ($a) {
269 269
             case 'a':
270 270
                 break;
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 }
343 343
 
344 344
 // Issue 3352.
345
-switch ( $test ) {
345
+switch ($test) {
346 346
     case 2: // comment followed by empty line
347 347
 
348 348
         break;
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
 // Issue #3297.
409 409
 // Okay - finally will always be executed, so all branches are covered by the `return` in finally.
410
-switch ( $a ) {
410
+switch ($a) {
411 411
     case 1:
412 412
         try {
413 413
             doSomething();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 }
425 425
 
426 426
 // Okay - all - non-finally - branches have a terminating statement.
427
-switch ( $a ) {
427
+switch ($a) {
428 428
     case 1:
429 429
         try {
430 430
             return false;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 // Okay - finally will always be executed, so all branches are covered by the `return` in finally.
446 446
 // Non-standard structure order.
447
-switch ( $a ) {
447
+switch ($a) {
448 448
     case 1:
449 449
         try {
450 450
             doSomething();
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 
463 463
 // Okay - all - non-finally - branches have a terminating statement.
464 464
 // Non-standard structure order.
465
-switch ( $a ) {
465
+switch ($a) {
466 466
     case 1:
467 467
         try {
468 468
             return false;
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 }
480 480
 
481 481
 // All okay, no finally. Any exception still uncaught will terminate the case anyhow, so we're good.
482
-switch ( $a ) {
482
+switch ($a) {
483 483
     case 1:
484 484
         try {
485 485
             return false;
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 }
495 495
 
496 496
 // All okay, no catch
497
-switch ( $a ) {
497
+switch ($a) {
498 498
     case 1:
499 499
         try {
500 500
             return true;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 }
508 508
 
509 509
 // All okay, try-catch nested in if.
510
-switch ( $a ) {
510
+switch ($a) {
511 511
     case 1:
512 512
         if ($a) {
513 513
             try {
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 }
525 525
 
526 526
 // Missing fall-through comment.
527
-switch ( $a ) {
527
+switch ($a) {
528 528
     case 1:
529 529
         try {
530 530
             doSomething();
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 }
538 538
 
539 539
 // Missing fall-through comment. One of the catches does not have a terminating statement.
540
-switch ( $a ) {
540
+switch ($a) {
541 541
     case 1:
542 542
         try {
543 543
             return false;
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 }
555 555
 
556 556
 // Missing fall-through comment. Try does not have a terminating statement.
557
-switch ( $a ) {
557
+switch ($a) {
558 558
     case 1:
559 559
         try {
560 560
             doSomething();
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 }
572 572
 
573 573
 // Missing fall-through comment. One of the catches does not have a terminating statement.
574
-switch ( $a ) {
574
+switch ($a) {
575 575
     case 1:
576 576
         try {
577 577
             return false;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -395,10 +395,11 @@
 block discarded – undo
395 395
 
396 396
 switch ($foo) {
397 397
     case 1:
398
-        if ($bar > 0) /*comment*/ {
398
+        if ($bar > 0) {
399
+        	/*comment*/ {
399 400
             return doSomething();
400 401
         }
401
-        else {
402
+        } else {
402 403
             return 1;
403 404
         }
404 405
     case 2:
Please login to merge, or discard this patch.