GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 699b70...879176 )
by Chris
13:23
created
PSR2R/Sniffs/ControlStructures/ConditionalExpressionOrderSniff.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -24,64 +24,64 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @inheritDoc
26 26
 	 */
27
-	public function process(PHP_CodeSniffer_File $phpCsFile, $stackPointer) {
27
+	public function process( PHP_CodeSniffer_File $phpCsFile, $stackPointer ) {
28 28
 		$tokens = $phpCsFile->getTokens();
29 29
 
30
-		$prevIndex = $phpCsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPointer - 1), null, true);
31
-		if (!$this->isGivenKind([T_CLOSE_SHORT_ARRAY, T_TRUE, T_FALSE, T_NULL, T_LNUMBER, T_CONSTANT_ENCAPSED_STRING], $tokens[$prevIndex])) {
30
+		$prevIndex = $phpCsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPointer - 1 ), null, true );
31
+		if ( ! $this->isGivenKind( [ T_CLOSE_SHORT_ARRAY, T_TRUE, T_FALSE, T_NULL, T_LNUMBER, T_CONSTANT_ENCAPSED_STRING ], $tokens[ $prevIndex ] ) ) {
32 32
 			return;
33 33
 		}
34 34
 
35 35
 		$leftIndexEnd = $prevIndex;
36 36
 
37
-		if ($this->isGivenKind(T_CLOSE_SHORT_ARRAY, $tokens[$prevIndex])) {
38
-			$prevIndex = $tokens[$prevIndex]['bracket_opener'];
37
+		if ( $this->isGivenKind( T_CLOSE_SHORT_ARRAY, $tokens[ $prevIndex ] ) ) {
38
+			$prevIndex = $tokens[ $prevIndex ][ 'bracket_opener' ];
39 39
 		}
40 40
 
41 41
 		$leftIndexStart = $prevIndex;
42 42
 
43
-		$prevIndex = $phpCsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prevIndex - 1), null, true);
44
-		if (!$prevIndex) {
43
+		$prevIndex = $phpCsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, ( $prevIndex - 1 ), null, true );
44
+		if ( ! $prevIndex ) {
45 45
 			return;
46 46
 		}
47
-		if ($this->isGivenKind(PHP_CodeSniffer_Tokens::$arithmeticTokens, $tokens[$prevIndex])) {
47
+		if ( $this->isGivenKind( PHP_CodeSniffer_Tokens::$arithmeticTokens, $tokens[ $prevIndex ] ) ) {
48 48
 			return;
49 49
 		}
50
-		if ($this->isGivenKind([T_STRING_CONCAT], $tokens[$prevIndex])) {
50
+		if ( $this->isGivenKind( [ T_STRING_CONCAT ], $tokens[ $prevIndex ] ) ) {
51 51
 			return;
52 52
 		}
53 53
 
54 54
 		$fixable = true;
55 55
 		$error = 'Usage of Yoda conditions is not allowed. Switch the expression order.';
56
-		$prevContent = $tokens[$prevIndex]['content'];
56
+		$prevContent = $tokens[ $prevIndex ][ 'content' ];
57 57
 
58
-		if (!$this->isGivenKind(PHP_CodeSniffer_Tokens::$assignmentTokens, $tokens[$prevIndex])
59
-			&& !$this->isGivenKind(PHP_CodeSniffer_Tokens::$booleanOperators, $tokens[$prevIndex])
58
+		if ( ! $this->isGivenKind( PHP_CodeSniffer_Tokens::$assignmentTokens, $tokens[ $prevIndex ] )
59
+			&& ! $this->isGivenKind( PHP_CodeSniffer_Tokens::$booleanOperators, $tokens[ $prevIndex ] )
60 60
 			&& $prevContent !== '('
61 61
 			&& $prevContent !== ','
62 62
 		) {
63 63
 			// Not fixable
64
-			$phpCsFile->addError($error, $stackPointer);
64
+			$phpCsFile->addError( $error, $stackPointer );
65 65
 			return;
66 66
 		}
67 67
 
68
-		$rightIndexStart = $phpCsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPointer + 1, null, true);
68
+		$rightIndexStart = $phpCsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $stackPointer + 1, null, true );
69 69
 
70
-		if ($this->isGivenKind(T_OPEN_PARENTHESIS, $tokens[$prevIndex])) {
71
-			$rightIndexEnd = $phpCsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $tokens[$prevIndex]['parenthesis_closer'] - 1, null, true);
70
+		if ( $this->isGivenKind( T_OPEN_PARENTHESIS, $tokens[ $prevIndex ] ) ) {
71
+			$rightIndexEnd = $phpCsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $tokens[ $prevIndex ][ 'parenthesis_closer' ] - 1, null, true );
72 72
 		} else {
73
-			$previousParenthesisOpenerIndex = $phpCsFile->findPrevious(T_OPEN_PARENTHESIS, $prevIndex - 1);
73
+			$previousParenthesisOpenerIndex = $phpCsFile->findPrevious( T_OPEN_PARENTHESIS, $prevIndex - 1 );
74 74
 			$limit = null;
75
-			if ($previousParenthesisOpenerIndex && $tokens[$previousParenthesisOpenerIndex]['parenthesis_closer'] > $rightIndexStart) {
76
-				$limit = $tokens[$previousParenthesisOpenerIndex]['parenthesis_closer'];
75
+			if ( $previousParenthesisOpenerIndex && $tokens[ $previousParenthesisOpenerIndex ][ 'parenthesis_closer' ] > $rightIndexStart ) {
76
+				$limit = $tokens[ $previousParenthesisOpenerIndex ][ 'parenthesis_closer' ];
77 77
 			}
78 78
 
79
-			$rightIndexEnd = $this->detectRightEnd($phpCsFile, $rightIndexStart, $limit);
79
+			$rightIndexEnd = $this->detectRightEnd( $phpCsFile, $rightIndexStart, $limit );
80 80
 		}
81 81
 
82
-		$fix = $phpCsFile->addFixableError($error, $stackPointer);
83
-		if ($fix) {
84
-			$this->applyFix($phpCsFile, $stackPointer, $leftIndexStart, $leftIndexEnd, $rightIndexStart, $rightIndexEnd);
82
+		$fix = $phpCsFile->addFixableError( $error, $stackPointer );
83
+		if ( $fix ) {
84
+			$this->applyFix( $phpCsFile, $stackPointer, $leftIndexStart, $leftIndexEnd, $rightIndexStart, $rightIndexEnd );
85 85
 		}
86 86
 	}
87 87
 
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return int
92 92
 	 */
93
-	protected function getComparisonValue(array $token) {
94
-		$comparisonIndexValue = $token['content'];
95
-		$operatorsToMap = [T_GREATER_THAN, T_LESS_THAN, T_IS_GREATER_OR_EQUAL, T_IS_SMALLER_OR_EQUAL];
96
-		if (in_array($token['code'], $operatorsToMap, true)) {
93
+	protected function getComparisonValue( array $token ) {
94
+		$comparisonIndexValue = $token[ 'content' ];
95
+		$operatorsToMap = [ T_GREATER_THAN, T_LESS_THAN, T_IS_GREATER_OR_EQUAL, T_IS_SMALLER_OR_EQUAL ];
96
+		if ( in_array( $token[ 'code' ], $operatorsToMap, true ) ) {
97 97
 			$mapping = [
98 98
 				T_GREATER_THAN => '<',
99 99
 				T_LESS_THAN => '>',
100 100
 				T_IS_GREATER_OR_EQUAL => '<=',
101 101
 				T_IS_SMALLER_OR_EQUAL => '>=',
102 102
 			];
103
-			$comparisonIndexValue = $mapping[$token['code']];
103
+			$comparisonIndexValue = $mapping[ $token[ 'code' ] ];
104 104
 
105 105
 			return $comparisonIndexValue;
106 106
 		}
@@ -115,38 +115,38 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return int|null
117 117
 	 */
118
-	protected function detectRightEnd(PHP_CodeSniffer_File $phpCsFile, $index, $limit = 0) {
118
+	protected function detectRightEnd( PHP_CodeSniffer_File $phpCsFile, $index, $limit = 0 ) {
119 119
 		$tokens = $phpCsFile->getTokens();
120 120
 
121 121
 		$rightEndIndex = $index;
122 122
 		$nextIndex = $index;
123 123
 		$max = null;
124
-		if ($this->isGivenKind(T_OPEN_PARENTHESIS, $tokens[$index])) {
125
-			$braceEndIndex = $tokens[$index]['parenthesis_closer'];
124
+		if ( $this->isGivenKind( T_OPEN_PARENTHESIS, $tokens[ $index ] ) ) {
125
+			$braceEndIndex = $tokens[ $index ][ 'parenthesis_closer' ];
126 126
 			return $braceEndIndex;
127 127
 		}
128 128
 
129
-		while (true) {
130
-			$nextIndex = $phpCsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextIndex + 1, null, true);
131
-			if (!$nextIndex) {
129
+		while ( true ) {
130
+			$nextIndex = $phpCsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, $nextIndex + 1, null, true );
131
+			if ( ! $nextIndex ) {
132 132
 				return $rightEndIndex;
133 133
 			}
134 134
 
135
-			if ($nextIndex >= $limit) {
135
+			if ( $nextIndex >= $limit ) {
136 136
 				return $rightEndIndex;
137 137
 			}
138 138
 
139
-			if ($this->isGivenKind([T_SEMICOLON, T_COMMA], $tokens[$nextIndex])) {
139
+			if ( $this->isGivenKind( [ T_SEMICOLON, T_COMMA ], $tokens[ $nextIndex ] ) ) {
140 140
 				return $rightEndIndex;
141 141
 			}
142 142
 
143
-			if ($this->isGivenKind(T_OPEN_PARENTHESIS, $tokens[$nextIndex])) {
144
-				$nextIndex = $tokens[$nextIndex]['parenthesis_closer'];
143
+			if ( $this->isGivenKind( T_OPEN_PARENTHESIS, $tokens[ $nextIndex ] ) ) {
144
+				$nextIndex = $tokens[ $nextIndex ][ 'parenthesis_closer' ];
145 145
 				$rightEndIndex = $nextIndex;
146 146
 				continue;
147 147
 			}
148 148
 
149
-			if ($this->isGivenKind(T_CLOSE_PARENTHESIS, $tokens[$nextIndex])
149
+			if ( $this->isGivenKind( T_CLOSE_PARENTHESIS, $tokens[ $nextIndex ] )
150 150
 			) {
151 151
 				return $rightEndIndex;
152 152
 			}
@@ -167,29 +167,29 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return void
169 169
 	 */
170
-	protected function applyFix(PHP_CodeSniffer_File $phpCsFile, $index, $leftIndexStart, $leftIndexEnd, $rightIndexStart, $rightIndexEnd) {
170
+	protected function applyFix( PHP_CodeSniffer_File $phpCsFile, $index, $leftIndexStart, $leftIndexEnd, $rightIndexStart, $rightIndexEnd ) {
171 171
 		$tokens = $phpCsFile->getTokens();
172 172
 
173
-		$token = $tokens[$index];
173
+		$token = $tokens[ $index ];
174 174
 		// Check if we need to inverse comparison operator
175
-		$comparisonValue = $this->getComparisonValue($token);
175
+		$comparisonValue = $this->getComparisonValue( $token );
176 176
 
177 177
 		$phpCsFile->fixer->beginChangeset();
178 178
 
179 179
 		$leftValue = '';
180
-		for ($i = $leftIndexStart; $i <= $leftIndexEnd; ++$i) {
181
-			$leftValue .= $tokens[$i]['content'];
182
-			$phpCsFile->fixer->replaceToken($i, '');
180
+		for ( $i = $leftIndexStart; $i <= $leftIndexEnd; ++$i ) {
181
+			$leftValue .= $tokens[ $i ][ 'content' ];
182
+			$phpCsFile->fixer->replaceToken( $i, '' );
183 183
 		}
184 184
 		$rightValue = '';
185
-		for ($i = $rightIndexStart; $i <= $rightIndexEnd; ++$i) {
186
-			$rightValue .= $tokens[$i]['content'];
187
-			$phpCsFile->fixer->replaceToken($i, '');
185
+		for ( $i = $rightIndexStart; $i <= $rightIndexEnd; ++$i ) {
186
+			$rightValue .= $tokens[ $i ][ 'content' ];
187
+			$phpCsFile->fixer->replaceToken( $i, '' );
188 188
 		}
189 189
 
190
-		$phpCsFile->fixer->replaceToken($index, $comparisonValue);
191
-		$phpCsFile->fixer->replaceToken($leftIndexEnd, $rightValue);
192
-		$phpCsFile->fixer->replaceToken($rightIndexStart, $leftValue);
190
+		$phpCsFile->fixer->replaceToken( $index, $comparisonValue );
191
+		$phpCsFile->fixer->replaceToken( $leftIndexEnd, $rightValue );
192
+		$phpCsFile->fixer->replaceToken( $rightIndexStart, $leftValue );
193 193
 
194 194
 		$phpCsFile->fixer->endChangeset();
195 195
 	}
Please login to merge, or discard this patch.
psr2r-sniffer/PSR2R/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 		return [
41 41
 				T_ELSE,
42 42
 				T_ELSEIF,
43
-			   ];
43
+				];
44 44
 	}
45 45
 
46 46
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -47,26 +47,26 @@
 block discarded – undo
47 47
 	/**
48 48
 	 * @inheritDoc
49 49
 	 */
50
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
50
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
51 51
 		$tokens = $phpcsFile->getTokens();
52 52
 
53
-		if ($tokens[$stackPtr]['code'] === T_ELSEIF) {
54
-			$phpcsFile->recordMetric($stackPtr, 'Use of ELSE IF or ELSEIF', 'elseif');
53
+		if ( $tokens[ $stackPtr ][ 'code' ] === T_ELSEIF ) {
54
+			$phpcsFile->recordMetric( $stackPtr, 'Use of ELSE IF or ELSEIF', 'elseif' );
55 55
 
56 56
 			return;
57 57
 		}
58 58
 
59
-		$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
60
-		if ($tokens[$next]['code'] === T_IF) {
61
-			$phpcsFile->recordMetric($stackPtr, 'Use of ELSE IF or ELSEIF', 'else if');
59
+		$next = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
60
+		if ( $tokens[ $next ][ 'code' ] === T_IF ) {
61
+			$phpcsFile->recordMetric( $stackPtr, 'Use of ELSE IF or ELSEIF', 'else if' );
62 62
 			$error = 'Usage of ELSE IF is discouraged; use ELSEIF instead';
63
-			$fix = $phpcsFile->addFixableWarning($error, $stackPtr, 'NotAllowed');
63
+			$fix = $phpcsFile->addFixableWarning( $error, $stackPtr, 'NotAllowed' );
64 64
 
65
-			if ($fix === true) {
65
+			if ( $fix === true ) {
66 66
 				$phpcsFile->fixer->beginChangeset();
67
-				$phpcsFile->fixer->replaceToken($stackPtr, 'elseif');
68
-				for ($i = ($stackPtr + 1); $i <= $next; $i++) {
69
-					$phpcsFile->fixer->replaceToken($i, '');
67
+				$phpcsFile->fixer->replaceToken( $stackPtr, 'elseif' );
68
+				for ( $i = ( $stackPtr + 1 ); $i <= $next; $i++ ) {
69
+					$phpcsFile->fixer->replaceToken( $i, '' );
70 70
 				}
71 71
 
72 72
 				$phpcsFile->fixer->endChangeset();
Please login to merge, or discard this patch.
psr2r-sniffer/PSR2R/Sniffs/ControlStructures/SwitchDeclarationSniff.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @inheritDoc
43 43
 	 */
44 44
 	public function register() {
45
-		return [T_SWITCH];
45
+		return [ T_SWITCH ];
46 46
 
47 47
 	}
48 48
 
@@ -50,27 +50,27 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * @inheritDoc
52 52
 	 */
53
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
53
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
54 54
 		$tokens = $phpcsFile->getTokens();
55 55
 
56 56
 		// TODO: Auto-detect spaces vs tabs, maybe using a trait method indent($index, $this->indent)
57 57
 		$this->indent = 1;
58 58
 
59 59
 		// We can't process SWITCH statements unless we know where they start and end.
60
-		if (isset($tokens[$stackPtr]['scope_opener']) === false
61
-			|| isset($tokens[$stackPtr]['scope_closer']) === false
60
+		if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === false
61
+			|| isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false
62 62
 		) {
63 63
 			return;
64 64
 		}
65 65
 
66
-		$switch = $tokens[$stackPtr];
66
+		$switch = $tokens[ $stackPtr ];
67 67
 		$nextCase = $stackPtr;
68
-		$caseAlignment = ($switch['column'] + $this->indent);
68
+		$caseAlignment = ( $switch[ 'column' ] + $this->indent );
69 69
 		$caseCount = 0;
70 70
 		$foundDefault = false;
71 71
 
72
-		while (($nextCase = $this->findNextCase($phpcsFile, ($nextCase + 1), $switch['scope_closer'])) !== false) {
73
-			if ($tokens[$nextCase]['code'] === T_DEFAULT) {
72
+		while ( ( $nextCase = $this->findNextCase( $phpcsFile, ( $nextCase + 1 ), $switch[ 'scope_closer' ] ) ) !== false ) {
73
+			if ( $tokens[ $nextCase ][ 'code' ] === T_DEFAULT ) {
74 74
 				$type = 'default';
75 75
 				$foundDefault = true;
76 76
 			} else {
@@ -78,103 +78,103 @@  discard block
 block discarded – undo
78 78
 				$caseCount++;
79 79
 			}
80 80
 
81
-			if ($tokens[$nextCase]['content'] !== strtolower($tokens[$nextCase]['content'])) {
82
-				$expected = strtolower($tokens[$nextCase]['content']);
83
-				$error = strtoupper($type) . ' keyword must be lowercase; expected "%s" but found "%s"';
81
+			if ( $tokens[ $nextCase ][ 'content' ] !== strtolower( $tokens[ $nextCase ][ 'content' ] ) ) {
82
+				$expected = strtolower( $tokens[ $nextCase ][ 'content' ] );
83
+				$error = strtoupper( $type ) . ' keyword must be lowercase; expected "%s" but found "%s"';
84 84
 				$data = [
85 85
 							 $expected,
86
-							 $tokens[$nextCase]['content'],
86
+							 $tokens[ $nextCase ][ 'content' ],
87 87
 							];
88 88
 
89
-				$fix = $phpcsFile->addFixableError($error, $nextCase, $type . 'NotLower', $data);
90
-				if ($fix === true) {
91
-					$phpcsFile->fixer->replaceToken($nextCase, $expected);
89
+				$fix = $phpcsFile->addFixableError( $error, $nextCase, $type . 'NotLower', $data );
90
+				if ( $fix === true ) {
91
+					$phpcsFile->fixer->replaceToken( $nextCase, $expected );
92 92
 				}
93 93
 			}
94 94
 
95
-			if ($type === 'case'
96
-				&& ($tokens[($nextCase + 1)]['code'] !== T_WHITESPACE
97
-				|| $tokens[($nextCase + 1)]['content'] !== ' ')
95
+			if ( $type === 'case'
96
+				&& ( $tokens[ ( $nextCase + 1 ) ][ 'code' ] !== T_WHITESPACE
97
+				|| $tokens[ ( $nextCase + 1 ) ][ 'content' ] !== ' ' )
98 98
 			) {
99 99
 				$error = 'CASE keyword must be followed by a single space';
100
-				$fix = $phpcsFile->addFixableError($error, $nextCase, 'SpacingAfterCase');
101
-				if ($fix === true) {
102
-					if ($tokens[($nextCase + 1)]['code'] !== T_WHITESPACE) {
103
-						$phpcsFile->fixer->addContent($nextCase, ' ');
100
+				$fix = $phpcsFile->addFixableError( $error, $nextCase, 'SpacingAfterCase' );
101
+				if ( $fix === true ) {
102
+					if ( $tokens[ ( $nextCase + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
103
+						$phpcsFile->fixer->addContent( $nextCase, ' ' );
104 104
 					} else {
105
-						$phpcsFile->fixer->replaceToken(($nextCase + 1), ' ');
105
+						$phpcsFile->fixer->replaceToken( ( $nextCase + 1 ), ' ' );
106 106
 					}
107 107
 				}
108 108
 			}
109 109
 
110
-			$opener = $tokens[$nextCase]['scope_opener'];
111
-			if ($tokens[$opener]['code'] === T_COLON) {
112
-				if ($tokens[($opener - 1)]['code'] === T_WHITESPACE) {
113
-					$error = 'There must be no space before the colon in a ' . strtoupper($type) . ' statement';
114
-					$fix = $phpcsFile->addFixableError($error, $nextCase, 'SpaceBeforeColon' . strtoupper($type));
115
-					if ($fix === true) {
116
-						$phpcsFile->fixer->replaceToken(($opener - 1), '');
110
+			$opener = $tokens[ $nextCase ][ 'scope_opener' ];
111
+			if ( $tokens[ $opener ][ 'code' ] === T_COLON ) {
112
+				if ( $tokens[ ( $opener - 1 ) ][ 'code' ] === T_WHITESPACE ) {
113
+					$error = 'There must be no space before the colon in a ' . strtoupper( $type ) . ' statement';
114
+					$fix = $phpcsFile->addFixableError( $error, $nextCase, 'SpaceBeforeColon' . strtoupper( $type ) );
115
+					if ( $fix === true ) {
116
+						$phpcsFile->fixer->replaceToken( ( $opener - 1 ), '' );
117 117
 					}
118 118
 				}
119 119
 
120
-				$next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true);
121
-				if ($tokens[$next]['line'] === $tokens[$opener]['line']
122
-					&& $tokens[$next]['code'] === T_COMMENT
120
+				$next = $phpcsFile->findNext( T_WHITESPACE, ( $opener + 1 ), null, true );
121
+				if ( $tokens[ $next ][ 'line' ] === $tokens[ $opener ][ 'line' ]
122
+					&& $tokens[ $next ][ 'code' ] === T_COMMENT
123 123
 				) {
124 124
 					// Skip comments on the same line.
125
-					$next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
125
+					$next = $phpcsFile->findNext( T_WHITESPACE, ( $next + 1 ), null, true );
126 126
 				}
127 127
 
128
-				if ($tokens[$next]['line'] !== ($tokens[$opener]['line'] + 1)) {
129
-					$error = 'The ' . strtoupper($type) . ' body must start on the line following the statement';
130
-					$fix = $phpcsFile->addFixableError($error, $nextCase, 'SpaceBeforeColon' . strtoupper($type));
131
-					if ($fix === true) {
132
-						if ($tokens[$next]['line'] === $tokens[$opener]['line']) {
133
-							$padding = str_repeat(' ', ($caseAlignment + $this->indent - 1));
134
-							$phpcsFile->fixer->addContentBefore($next, $phpcsFile->eolChar . $padding);
128
+				if ( $tokens[ $next ][ 'line' ] !== ( $tokens[ $opener ][ 'line' ] + 1 ) ) {
129
+					$error = 'The ' . strtoupper( $type ) . ' body must start on the line following the statement';
130
+					$fix = $phpcsFile->addFixableError( $error, $nextCase, 'SpaceBeforeColon' . strtoupper( $type ) );
131
+					if ( $fix === true ) {
132
+						if ( $tokens[ $next ][ 'line' ] === $tokens[ $opener ][ 'line' ] ) {
133
+							$padding = str_repeat( ' ', ( $caseAlignment + $this->indent - 1 ) );
134
+							$phpcsFile->fixer->addContentBefore( $next, $phpcsFile->eolChar . $padding );
135 135
 						} else {
136 136
 							$phpcsFile->fixer->beginChangeset();
137
-							for ($i = ($opener + 1); $i < $next; $i++) {
138
-								if ($tokens[$i]['line'] === $tokens[$next]['line']) {
137
+							for ( $i = ( $opener + 1 ); $i < $next; $i++ ) {
138
+								if ( $tokens[ $i ][ 'line' ] === $tokens[ $next ][ 'line' ] ) {
139 139
 									break;
140 140
 								}
141 141
 
142
-								$phpcsFile->fixer->replaceToken($i, '');
142
+								$phpcsFile->fixer->replaceToken( $i, '' );
143 143
 							}
144 144
 
145
-							$phpcsFile->fixer->addNewLineBefore($i);
145
+							$phpcsFile->fixer->addNewLineBefore( $i );
146 146
 							$phpcsFile->fixer->endChangeset();
147 147
 						}
148 148
 					}
149 149
 				}
150 150
 			} else {
151
-				$error = strtoupper($type) . ' statements must be defined using a colon';
152
-				$phpcsFile->addError($error, $nextCase, 'WrongOpener' . $type);
151
+				$error = strtoupper( $type ) . ' statements must be defined using a colon';
152
+				$phpcsFile->addError( $error, $nextCase, 'WrongOpener' . $type );
153 153
 			}
154 154
 
155
-			$nextCloser = $tokens[$nextCase]['scope_closer'];
156
-			if ($tokens[$nextCloser]['scope_condition'] === $nextCase) {
155
+			$nextCloser = $tokens[ $nextCase ][ 'scope_closer' ];
156
+			if ( $tokens[ $nextCloser ][ 'scope_condition' ] === $nextCase ) {
157 157
 				// Only need to check some things once, even if the
158 158
 				// closer is shared between multiple case statements, or even
159 159
 				// the default case.
160
-				$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($nextCloser - 1), $nextCase, true);
161
-				if ($tokens[$prev]['line'] === $tokens[$nextCloser]['line']) {
160
+				$prev = $phpcsFile->findPrevious( T_WHITESPACE, ( $nextCloser - 1 ), $nextCase, true );
161
+				if ( $tokens[ $prev ][ 'line' ] === $tokens[ $nextCloser ][ 'line' ] ) {
162 162
 					$error = 'Terminating statement must be on a line by itself';
163
-					$fix = $phpcsFile->addFixableError($error, $nextCloser, 'BreakNotNewLine');
164
-					if ($fix === true) {
165
-						$phpcsFile->fixer->addNewLine($prev);
166
-						$phpcsFile->fixer->replaceToken($nextCloser, trim($tokens[$nextCloser]['content']));
163
+					$fix = $phpcsFile->addFixableError( $error, $nextCloser, 'BreakNotNewLine' );
164
+					if ( $fix === true ) {
165
+						$phpcsFile->fixer->addNewLine( $prev );
166
+						$phpcsFile->fixer->replaceToken( $nextCloser, trim( $tokens[ $nextCloser ][ 'content' ] ) );
167 167
 					}
168 168
 				} else {
169
-					$diff = ($caseAlignment + $this->indent - $tokens[$nextCloser]['column']);
170
-					if ($diff !== 0) {
169
+					$diff = ( $caseAlignment + $this->indent - $tokens[ $nextCloser ][ 'column' ] );
170
+					if ( $diff !== 0 ) {
171 171
 						$error = 'Terminating statement must be indented to the same level as the CASE body';
172
-						$fix = $phpcsFile->addFixableError($error, $nextCloser, 'BreakIndent');
173
-						if ($fix === true) {
174
-							if ($diff > 0) {
175
-								$phpcsFile->fixer->addContentBefore($nextCloser, str_repeat(' ', $diff));
172
+						$fix = $phpcsFile->addFixableError( $error, $nextCloser, 'BreakIndent' );
173
+						if ( $fix === true ) {
174
+							if ( $diff > 0 ) {
175
+								$phpcsFile->fixer->addContentBefore( $nextCloser, str_repeat( ' ', $diff ) );
176 176
 							} else {
177
-								$phpcsFile->fixer->substrToken(($nextCloser - 1), 0, $diff);
177
+								$phpcsFile->fixer->substrToken( ( $nextCloser - 1 ), 0, $diff );
178 178
 							}
179 179
 						}
180 180
 					}
@@ -182,25 +182,25 @@  discard block
 block discarded – undo
182 182
 			}
183 183
 
184 184
 			// We only want cases from here on in.
185
-			if ($type !== 'case') {
185
+			if ( $type !== 'case' ) {
186 186
 				continue;
187 187
 			}
188 188
 
189
-			$nextCode = $phpcsFile->findNext(T_WHITESPACE,
190
-				($tokens[$nextCase]['scope_opener'] + 1),
189
+			$nextCode = $phpcsFile->findNext( T_WHITESPACE,
190
+				( $tokens[ $nextCase ][ 'scope_opener' ] + 1 ),
191 191
 				$nextCloser,
192
-				true);
192
+				true );
193 193
 
194
-			if ($tokens[$nextCode]['code'] !== T_CASE && $tokens[$nextCode]['code'] !== T_DEFAULT) {
194
+			if ( $tokens[ $nextCode ][ 'code' ] !== T_CASE && $tokens[ $nextCode ][ 'code' ] !== T_DEFAULT ) {
195 195
 				// This case statement has content. If the next case or default comes
196 196
 				// before the closer, it means we dont have a terminating statement
197 197
 				// and instead need a comment.
198
-				$nextCode = $this->findNextCase($phpcsFile, ($tokens[$nextCase]['scope_opener'] + 1), $nextCloser);
199
-				if ($nextCode !== false) {
200
-					$prevCode = $phpcsFile->findPrevious(T_WHITESPACE, ($nextCode - 1), $nextCase, true);
201
-					if ($tokens[$prevCode]['code'] !== T_COMMENT) {
198
+				$nextCode = $this->findNextCase( $phpcsFile, ( $tokens[ $nextCase ][ 'scope_opener' ] + 1 ), $nextCloser );
199
+				if ( $nextCode !== false ) {
200
+					$prevCode = $phpcsFile->findPrevious( T_WHITESPACE, ( $nextCode - 1 ), $nextCase, true );
201
+					if ( $tokens[ $prevCode ][ 'code' ] !== T_COMMENT ) {
202 202
 						$error = 'There must be a comment when fall-through is intentional in a non-empty case body';
203
-						$phpcsFile->addError($error, $nextCase, 'TerminatingComment');
203
+						$phpcsFile->addError( $error, $nextCase, 'TerminatingComment' );
204 204
 					}
205 205
 				}
206 206
 			}
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return int | bool
222 222
 	 */
223
-	protected function findNextCase(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $end) {
223
+	protected function findNextCase( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $end ) {
224 224
 		$tokens = $phpcsFile->getTokens();
225
-		while (($stackPtr = $phpcsFile->findNext([T_CASE, T_DEFAULT, T_SWITCH], $stackPtr, $end)) !== false) {
225
+		while ( ( $stackPtr = $phpcsFile->findNext( [ T_CASE, T_DEFAULT, T_SWITCH ], $stackPtr, $end ) ) !== false ) {
226 226
 			// Skip nested SWITCH statements; they are handled on their own.
227
-			if ($tokens[$stackPtr]['code'] === T_SWITCH) {
228
-				$stackPtr = $tokens[$stackPtr]['scope_closer'];
227
+			if ( $tokens[ $stackPtr ][ 'code' ] === T_SWITCH ) {
228
+				$stackPtr = $tokens[ $stackPtr ][ 'scope_closer' ];
229 229
 				continue;
230 230
 			}
231 231
 
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/ControlStructures/UnneededElseSniff.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -17,99 +17,99 @@  discard block
 block discarded – undo
17 17
 	 * @inheritDoc
18 18
 	 */
19 19
 	public function register() {
20
-		return [T_ELSE, T_ELSEIF];
20
+		return [ T_ELSE, T_ELSEIF ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
26
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
27 27
 		$tokens = $phpcsFile->getTokens();
28 28
 
29
-		if ($tokens[$stackPtr]['code'] === T_ELSEIF && $this->isNotLastCondition($phpcsFile, $stackPtr)) {
29
+		if ( $tokens[ $stackPtr ][ 'code' ] === T_ELSEIF && $this->isNotLastCondition( $phpcsFile, $stackPtr ) ) {
30 30
 			return;
31 31
 		}
32 32
 
33
-		$prevScopeEndIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
34
-		if (!$prevScopeEndIndex || empty($tokens[$prevScopeEndIndex]['scope_opener'])) {
33
+		$prevScopeEndIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
34
+		if ( ! $prevScopeEndIndex || empty( $tokens[ $prevScopeEndIndex ][ 'scope_opener' ] ) ) {
35 35
 			return;
36 36
 		}
37 37
 
38
-		$scopeStartIndex = $tokens[$prevScopeEndIndex]['scope_opener'];
38
+		$scopeStartIndex = $tokens[ $prevScopeEndIndex ][ 'scope_opener' ];
39 39
 
40
-		$prevParenthesisEndIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($scopeStartIndex - 1), null, true);
41
-		$parenthesisStartIndex = $tokens[$prevParenthesisEndIndex]['parenthesis_opener'];
40
+		$prevParenthesisEndIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $scopeStartIndex - 1 ), null, true );
41
+		$parenthesisStartIndex = $tokens[ $prevParenthesisEndIndex ][ 'parenthesis_opener' ];
42 42
 
43
-		$prevConditionIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($parenthesisStartIndex - 1), null, true);
43
+		$prevConditionIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $parenthesisStartIndex - 1 ), null, true );
44 44
 		// We only do trivial fixes right now
45
-		if ($tokens[$prevConditionIndex]['code'] !== T_IF) {
45
+		if ( $tokens[ $prevConditionIndex ][ 'code' ] !== T_IF ) {
46 46
 			return;
47 47
 		}
48 48
 
49
-		$prevScopeLastTokenIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($prevScopeEndIndex - 1), null, true);
50
-		if ($tokens[$prevScopeLastTokenIndex]['type'] !== 'T_SEMICOLON') {
49
+		$prevScopeLastTokenIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $prevScopeEndIndex - 1 ), null, true );
50
+		if ( $tokens[ $prevScopeLastTokenIndex ][ 'type' ] !== 'T_SEMICOLON' ) {
51 51
 			return;
52 52
 		}
53 53
 
54
-		$returnEarlyIndex = $phpcsFile->findPrevious([T_RETURN, T_CONTINUE, T_BREAK], ($prevScopeLastTokenIndex - 1), $scopeStartIndex + 1);
55
-		if (!$returnEarlyIndex) {
54
+		$returnEarlyIndex = $phpcsFile->findPrevious( [ T_RETURN, T_CONTINUE, T_BREAK ], ( $prevScopeLastTokenIndex - 1 ), $scopeStartIndex + 1 );
55
+		if ( ! $returnEarlyIndex ) {
56 56
 			return;
57 57
 		}
58 58
 
59
-		for ($i = $returnEarlyIndex + 1; $i < $prevScopeLastTokenIndex; $i++) {
60
-			if ($tokens[$i]['type'] === 'T_SEMICOLON') {
59
+		for ( $i = $returnEarlyIndex + 1; $i < $prevScopeLastTokenIndex; $i++ ) {
60
+			if ( $tokens[ $i ][ 'type' ] === 'T_SEMICOLON' ) {
61 61
 				return;
62 62
 			}
63 63
 		}
64 64
 
65
-		$fix = $phpcsFile->addFixableError('Unneeded ' . $tokens[$stackPtr]['type'] . ' detected.', $stackPtr);
66
-		if (!$fix) {
65
+		$fix = $phpcsFile->addFixableError( 'Unneeded ' . $tokens[ $stackPtr ][ 'type' ] . ' detected.', $stackPtr );
66
+		if ( ! $fix ) {
67 67
 			return;
68 68
 		}
69 69
 
70
-		if ($tokens[$stackPtr]['code'] === T_ELSEIF) {
71
-			$this->fixElseIfToIf($phpcsFile, $stackPtr);
70
+		if ( $tokens[ $stackPtr ][ 'code' ] === T_ELSEIF ) {
71
+			$this->fixElseIfToIf( $phpcsFile, $stackPtr );
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		$phpcsFile->fixer->beginChangeset();
76 76
 
77
-		$prevIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
77
+		$prevIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
78 78
 		//$indentationLevel = $tokens[$prevIndex]['column'] - 1;
79
-		$line = $tokens[$prevIndex]['line'];
79
+		$line = $tokens[ $prevIndex ][ 'line' ];
80 80
 
81
-		for ($i = $prevIndex + 1; $i < $stackPtr; $i++) {
82
-			$phpcsFile->fixer->replaceToken($i, '');
81
+		for ( $i = $prevIndex + 1; $i < $stackPtr; $i++ ) {
82
+			$phpcsFile->fixer->replaceToken( $i, '' );
83 83
 		}
84 84
 
85
-		$phpcsFile->fixer->addNewline($prevIndex);
85
+		$phpcsFile->fixer->addNewline( $prevIndex );
86 86
 
87
-		$phpcsFile->fixer->replaceToken($stackPtr, '');
87
+		$phpcsFile->fixer->replaceToken( $stackPtr, '' );
88 88
 
89
-		$nextScopeStartIndex = $tokens[$stackPtr]['scope_opener'];
90
-		$nextScopeEndIndex = $tokens[$stackPtr]['scope_closer'];
89
+		$nextScopeStartIndex = $tokens[ $stackPtr ][ 'scope_opener' ];
90
+		$nextScopeEndIndex = $tokens[ $stackPtr ][ 'scope_closer' ];
91 91
 
92
-		for ($i = $stackPtr + 1; $i < $nextScopeStartIndex; $i++) {
93
-			$phpcsFile->fixer->replaceToken($i, '');
92
+		for ( $i = $stackPtr + 1; $i < $nextScopeStartIndex; $i++ ) {
93
+			$phpcsFile->fixer->replaceToken( $i, '' );
94 94
 		}
95 95
 
96
-		$prevEndIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($nextScopeEndIndex - 1), null, true);
96
+		$prevEndIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $nextScopeEndIndex - 1 ), null, true );
97 97
 
98
-		$phpcsFile->fixer->replaceToken($nextScopeStartIndex, '');
99
-		$phpcsFile->fixer->replaceToken($nextScopeEndIndex, '');
98
+		$phpcsFile->fixer->replaceToken( $nextScopeStartIndex, '' );
99
+		$phpcsFile->fixer->replaceToken( $nextScopeEndIndex, '' );
100 100
 
101
-		for ($i = $prevEndIndex + 1; $i < $nextScopeEndIndex; $i++) {
102
-			$phpcsFile->fixer->replaceToken($i, '');
101
+		for ( $i = $prevEndIndex + 1; $i < $nextScopeEndIndex; $i++ ) {
102
+			$phpcsFile->fixer->replaceToken( $i, '' );
103 103
 		}
104 104
 
105 105
 		// Fix indentation
106 106
 		//$currentLine = $line;
107
-		for ($i = $nextScopeStartIndex + 1; $i < $prevEndIndex; $i++) {
108
-			if ($tokens[$i]['line'] === $line || $tokens[$i]['type'] !== 'T_WHITESPACE') {
107
+		for ( $i = $nextScopeStartIndex + 1; $i < $prevEndIndex; $i++ ) {
108
+			if ( $tokens[ $i ][ 'line' ] === $line || $tokens[ $i ][ 'type' ] !== 'T_WHITESPACE' ) {
109 109
 				continue;
110 110
 			}
111 111
 			//$currentLine = $tokens[$i]['line'];
112
-			$this->outdent($phpcsFile, $i);
112
+			$this->outdent( $phpcsFile, $i );
113 113
 		}
114 114
 
115 115
 		$phpcsFile->fixer->endChangeset();
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
 	 * @param int $stackPtr
121 121
 	 * @return bool
122 122
 	 */
123
-	protected function isNotLastCondition(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
123
+	protected function isNotLastCondition( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
124 124
 		$tokens = $phpcsFile->getTokens();
125 125
 
126 126
 		// Abort if not known
127
-		if (empty($tokens[$stackPtr]['scope_closer'])) {
127
+		if ( empty( $tokens[ $stackPtr ][ 'scope_closer' ] ) ) {
128 128
 			return true;
129 129
 		}
130 130
 
131
-		$nextScopeEndIndex = $tokens[$stackPtr]['scope_closer'];
131
+		$nextScopeEndIndex = $tokens[ $stackPtr ][ 'scope_closer' ];
132 132
 
133
-		$nextConditionStartIndex = $phpcsFile->findNext(T_WHITESPACE, ($nextScopeEndIndex - 1), null, true);
133
+		$nextConditionStartIndex = $phpcsFile->findNext( T_WHITESPACE, ( $nextScopeEndIndex - 1 ), null, true );
134 134
 
135
-		if (in_array($tokens[$nextConditionStartIndex]['code'], [T_ELSEIF, T_ELSE])) {
135
+		if ( in_array( $tokens[ $nextConditionStartIndex ][ 'code' ], [ T_ELSEIF, T_ELSE ] ) ) {
136 136
 			return true;
137 137
 		}
138 138
 
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 	 * @param int $stackPtr
145 145
 	 * @return void
146 146
 	 */
147
-	protected function fixElseIfToIf(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
147
+	protected function fixElseIfToIf( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
148 148
 		$tokens = $phpcsFile->getTokens();
149 149
 
150 150
 		$phpcsFile->fixer->beginChangeset();
151 151
 
152
-		$prevIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
153
-		$indentationLevel = $tokens[$prevIndex]['column'] - 1;
154
-		$indentationCharacter = $this->getIndentationCharacter($this->getIndentationWhitespace($phpcsFile, $prevIndex));
152
+		$prevIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
153
+		$indentationLevel = $tokens[ $prevIndex ][ 'column' ] - 1;
154
+		$indentationCharacter = $this->getIndentationCharacter( $this->getIndentationWhitespace( $phpcsFile, $prevIndex ) );
155 155
 
156
-		$indentation = str_repeat($indentationCharacter, $indentationLevel);
156
+		$indentation = str_repeat( $indentationCharacter, $indentationLevel );
157 157
 
158
-		for ($i = $prevIndex + 1; $i < $stackPtr; $i++) {
159
-			$phpcsFile->fixer->replaceToken($i, '');
158
+		for ( $i = $prevIndex + 1; $i < $stackPtr; $i++ ) {
159
+			$phpcsFile->fixer->replaceToken( $i, '' );
160 160
 		}
161 161
 
162
-		$phpcsFile->fixer->addNewline($prevIndex);
162
+		$phpcsFile->fixer->addNewline( $prevIndex );
163 163
 
164
-		$phpcsFile->fixer->replaceToken($stackPtr, $indentation . 'if');
164
+		$phpcsFile->fixer->replaceToken( $stackPtr, $indentation . 'if' );
165 165
 
166 166
 		$phpcsFile->fixer->endChangeset();
167 167
 	}
Please login to merge, or discard this patch.
PSR2R/Sniffs/ControlStructures/ControlStructureSpacingSniff.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 				T_ELSEIF,
63 63
 				T_TRY,
64 64
 				T_CATCH,
65
-			   ];
65
+				];
66 66
 	}
67 67
 
68 68
 	/**
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -68,72 +68,72 @@
 block discarded – undo
68 68
 	/**
69 69
 	 * @inheritDoc
70 70
 	 */
71
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
72
-		$this->requiredSpacesAfterOpen = (int)$this->requiredSpacesAfterOpen;
73
-		$this->requiredSpacesBeforeClose = (int)$this->requiredSpacesBeforeClose;
71
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
72
+		$this->requiredSpacesAfterOpen = (int) $this->requiredSpacesAfterOpen;
73
+		$this->requiredSpacesBeforeClose = (int) $this->requiredSpacesBeforeClose;
74 74
 		$tokens = $phpcsFile->getTokens();
75 75
 
76
-		if (isset($tokens[$stackPtr]['parenthesis_opener']) === false
77
-			|| isset($tokens[$stackPtr]['parenthesis_closer']) === false
76
+		if ( isset( $tokens[ $stackPtr ][ 'parenthesis_opener' ] ) === false
77
+			|| isset( $tokens[ $stackPtr ][ 'parenthesis_closer' ] ) === false
78 78
 		) {
79 79
 			return;
80 80
 		}
81 81
 
82
-		$parenOpener = $tokens[$stackPtr]['parenthesis_opener'];
83
-		$parenCloser = $tokens[$stackPtr]['parenthesis_closer'];
82
+		$parenOpener = $tokens[ $stackPtr ][ 'parenthesis_opener' ];
83
+		$parenCloser = $tokens[ $stackPtr ][ 'parenthesis_closer' ];
84 84
 		$spaceAfterOpen = 0;
85
-		if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) {
86
-			if (strpos($tokens[($parenOpener + 1)]['content'], $phpcsFile->eolChar) !== false) {
85
+		if ( $tokens[ ( $parenOpener + 1 ) ][ 'code' ] === T_WHITESPACE ) {
86
+			if ( strpos( $tokens[ ( $parenOpener + 1 ) ][ 'content' ], $phpcsFile->eolChar ) !== false ) {
87 87
 				$spaceAfterOpen = 'newline';
88 88
 			} else {
89
-				$spaceAfterOpen = strlen($tokens[($parenOpener + 1)]['content']);
89
+				$spaceAfterOpen = strlen( $tokens[ ( $parenOpener + 1 ) ][ 'content' ] );
90 90
 			}
91 91
 		}
92 92
 
93
-		$phpcsFile->recordMetric($stackPtr, 'Spaces after control structure open parenthesis', $spaceAfterOpen);
93
+		$phpcsFile->recordMetric( $stackPtr, 'Spaces after control structure open parenthesis', $spaceAfterOpen );
94 94
 
95
-		if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line']) {
96
-			if ($spaceAfterOpen !== $this->requiredSpacesAfterOpen) {
95
+		if ( $tokens[ $parenOpener ][ 'line' ] === $tokens[ $parenCloser ][ 'line' ] ) {
96
+			if ( $spaceAfterOpen !== $this->requiredSpacesAfterOpen ) {
97 97
 				$error = 'Expected %s spaces after opening bracket; %s found';
98 98
 				$data = [
99 99
 						  $this->requiredSpacesAfterOpen,
100 100
 						  $spaceAfterOpen,
101 101
 						 ];
102
-				$fix = $phpcsFile->addFixableError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data);
103
-				if ($fix === true) {
104
-					$padding = str_repeat(' ', $this->requiredSpacesAfterOpen);
105
-					if ($spaceAfterOpen === 0) {
106
-						$phpcsFile->fixer->addContent($parenOpener, $padding);
107
-					} elseif ($spaceAfterOpen === 'newline') {
108
-						$phpcsFile->fixer->replaceToken(($parenOpener + 1), '');
102
+				$fix = $phpcsFile->addFixableError( $error, ( $parenOpener + 1 ), 'SpacingAfterOpenBrace', $data );
103
+				if ( $fix === true ) {
104
+					$padding = str_repeat( ' ', $this->requiredSpacesAfterOpen );
105
+					if ( $spaceAfterOpen === 0 ) {
106
+						$phpcsFile->fixer->addContent( $parenOpener, $padding );
107
+					} elseif ( $spaceAfterOpen === 'newline' ) {
108
+						$phpcsFile->fixer->replaceToken( ( $parenOpener + 1 ), '' );
109 109
 					} else {
110
-						$phpcsFile->fixer->replaceToken(($parenOpener + 1), $padding);
110
+						$phpcsFile->fixer->replaceToken( ( $parenOpener + 1 ), $padding );
111 111
 					}
112 112
 				}
113 113
 			}
114 114
 		}
115 115
 
116
-		if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line']) {
116
+		if ( $tokens[ $parenOpener ][ 'line' ] === $tokens[ $parenCloser ][ 'line' ] ) {
117 117
 			$spaceBeforeClose = 0;
118
-			if ($tokens[($parenCloser - 1)]['code'] === T_WHITESPACE) {
119
-				$spaceBeforeClose = strlen(ltrim($tokens[($parenCloser - 1)]['content'], $phpcsFile->eolChar));
118
+			if ( $tokens[ ( $parenCloser - 1 ) ][ 'code' ] === T_WHITESPACE ) {
119
+				$spaceBeforeClose = strlen( ltrim( $tokens[ ( $parenCloser - 1 ) ][ 'content' ], $phpcsFile->eolChar ) );
120 120
 			}
121 121
 
122
-			$phpcsFile->recordMetric($stackPtr, 'Spaces before control structure close parenthesis', $spaceBeforeClose);
122
+			$phpcsFile->recordMetric( $stackPtr, 'Spaces before control structure close parenthesis', $spaceBeforeClose );
123 123
 
124
-			if ($spaceBeforeClose !== $this->requiredSpacesBeforeClose) {
124
+			if ( $spaceBeforeClose !== $this->requiredSpacesBeforeClose ) {
125 125
 				$error = 'Expected %s spaces before closing bracket; %s found';
126 126
 				$data = [
127 127
 						  $this->requiredSpacesBeforeClose,
128 128
 						  $spaceBeforeClose,
129 129
 						 ];
130
-				$fix = $phpcsFile->addFixableError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data);
131
-				if ($fix === true) {
132
-					$padding = str_repeat(' ', $this->requiredSpacesBeforeClose);
133
-					if ($spaceBeforeClose === 0) {
134
-						$phpcsFile->fixer->addContentBefore($parenCloser, $padding);
130
+				$fix = $phpcsFile->addFixableError( $error, ( $parenCloser - 1 ), 'SpaceBeforeCloseBrace', $data );
131
+				if ( $fix === true ) {
132
+					$padding = str_repeat( ' ', $this->requiredSpacesBeforeClose );
133
+					if ( $spaceBeforeClose === 0 ) {
134
+						$phpcsFile->fixer->addContentBefore( $parenCloser, $padding );
135 135
 					} else {
136
-						$phpcsFile->fixer->replaceToken(($parenCloser - 1), $padding);
136
+						$phpcsFile->fixer->replaceToken( ( $parenCloser - 1 ), $padding );
137 137
 					}
138 138
 				}
139 139
 			}
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/ControlStructures/TernarySpacingSniff.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	 * @inheritDoc
19 19
 	 */
20 20
 	public function register() {
21
-		return [T_INLINE_THEN];
21
+		return [ T_INLINE_THEN ];
22 22
 	}
23 23
 
24 24
 	/**
25 25
 	 * @inheritDoc
26 26
 	 */
27
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
28
-		$this->assertSpaceBefore($phpcsFile, $stackPtr);
29
-		$this->checkAfter($phpcsFile, $stackPtr);
27
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
28
+		$this->assertSpaceBefore( $phpcsFile, $stackPtr );
29
+		$this->checkAfter( $phpcsFile, $stackPtr );
30 30
 	}
31 31
 
32 32
 	/**
@@ -34,22 +34,22 @@  discard block
 block discarded – undo
34 34
 	 * @param int $thenIndex
35 35
 	 * @return void
36 36
 	 */
37
-	protected function checkAfter(PHP_CodeSniffer_File $phpcsFile, $thenIndex) {
38
-		$elseIndex = $phpcsFile->findNext(T_INLINE_ELSE, $thenIndex + 1);
39
-		if (!$elseIndex) {
37
+	protected function checkAfter( PHP_CodeSniffer_File $phpcsFile, $thenIndex ) {
38
+		$elseIndex = $phpcsFile->findNext( T_INLINE_ELSE, $thenIndex + 1 );
39
+		if ( ! $elseIndex ) {
40 40
 			return;
41 41
 		}
42 42
 
43 43
 		// Skip for short ternary
44
-		$prevIndex = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $elseIndex - 1, null, true);
45
-		if ($prevIndex === $thenIndex) {
46
-			$this->assertNoSpaceBetween($phpcsFile, $thenIndex, $elseIndex);
44
+		$prevIndex = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$emptyTokens, $elseIndex - 1, null, true );
45
+		if ( $prevIndex === $thenIndex ) {
46
+			$this->assertNoSpaceBetween( $phpcsFile, $thenIndex, $elseIndex );
47 47
 		} else {
48
-			$this->assertSpaceAfter($phpcsFile, $thenIndex);
49
-			$this->assertSpaceBefore($phpcsFile, $elseIndex);
48
+			$this->assertSpaceAfter( $phpcsFile, $thenIndex );
49
+			$this->assertSpaceBefore( $phpcsFile, $elseIndex );
50 50
 		}
51 51
 
52
-		$this->assertSpaceAfter($phpcsFile, $elseIndex);
52
+		$this->assertSpaceAfter( $phpcsFile, $elseIndex );
53 53
 	}
54 54
 
55 55
 	/**
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
 	 * @param int $stackPtr
58 58
 	 * @return void
59 59
 	 */
60
-	protected function assertSpaceBefore(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
61
-		$previous = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
62
-		if ($stackPtr - $previous > 1) {
63
-			$this->assertSingleSpaceBeforeIfNotMultiline($phpcsFile, $stackPtr, $previous);
60
+	protected function assertSpaceBefore( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
61
+		$previous = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
62
+		if ( $stackPtr - $previous > 1 ) {
63
+			$this->assertSingleSpaceBeforeIfNotMultiline( $phpcsFile, $stackPtr, $previous );
64 64
 			return;
65 65
 		}
66 66
 
67 67
 		$tokens = $phpcsFile->getTokens();
68
-		$content = $tokens[$stackPtr]['content'];
68
+		$content = $tokens[ $stackPtr ][ 'content' ];
69 69
 		$error = 'There must be a single space before ternary operator part `' . $content . '`';
70
-		$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeInlineThen');
71
-		if ($fix) {
72
-			$phpcsFile->fixer->addContentBefore($stackPtr, ' ');
70
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceBeforeInlineThen' );
71
+		if ( $fix ) {
72
+			$phpcsFile->fixer->addContentBefore( $stackPtr, ' ' );
73 73
 		}
74 74
 	}
75 75
 
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
 	 * @param int $stackPtr
79 79
 	 * @return void
80 80
 	 */
81
-	protected function assertSpaceAfter(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
82
-		$nextIndex = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
83
-		if ($nextIndex - $stackPtr > 1) {
84
-			$this->assertSingleSpaceAfterIfNotMultiline($phpcsFile, $stackPtr, $nextIndex);
81
+	protected function assertSpaceAfter( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
82
+		$nextIndex = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
83
+		if ( $nextIndex - $stackPtr > 1 ) {
84
+			$this->assertSingleSpaceAfterIfNotMultiline( $phpcsFile, $stackPtr, $nextIndex );
85 85
 			return;
86 86
 		}
87 87
 
88 88
 		$tokens = $phpcsFile->getTokens();
89
-		$content = $tokens[$stackPtr]['content'];
89
+		$content = $tokens[ $stackPtr ][ 'content' ];
90 90
 		$error = 'There must be a single space after ternary operator part `' . $content . '`';
91
-		$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterInlineThen');
92
-		if ($fix) {
93
-			$phpcsFile->fixer->addContent($stackPtr, ' ');
91
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceAfterInlineThen' );
92
+		if ( $fix ) {
93
+			$phpcsFile->fixer->addContent( $stackPtr, ' ' );
94 94
 		}
95 95
 	}
96 96
 
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
 	 * @param int $previous
101 101
 	 * @return void
102 102
 	 */
103
-	protected function assertSingleSpaceBeforeIfNotMultiline(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $previous) {
103
+	protected function assertSingleSpaceBeforeIfNotMultiline( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $previous ) {
104 104
 		$tokens = $phpcsFile->getTokens();
105 105
 
106
-		if ($tokens[$stackPtr]['line'] !== $tokens[$previous]['line']) {
106
+		if ( $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $previous ][ 'line' ] ) {
107 107
 			return;
108 108
 		}
109
-		if ($tokens[$stackPtr - 1]['content'] === ' ') {
109
+		if ( $tokens[ $stackPtr - 1 ][ 'content' ] === ' ' ) {
110 110
 			return;
111 111
 		}
112 112
 
113
-		$error = 'There must be a single space instead of `' . $tokens[$stackPtr - 1]['content'] . '`';
114
-		$fix = $phpcsFile->addFixableError($error, $stackPtr - 1, 'InvalidSpaceBefore');
115
-		if ($fix) {
116
-			$phpcsFile->fixer->replaceToken($stackPtr - 1, ' ');
113
+		$error = 'There must be a single space instead of `' . $tokens[ $stackPtr - 1 ][ 'content' ] . '`';
114
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr - 1, 'InvalidSpaceBefore' );
115
+		if ( $fix ) {
116
+			$phpcsFile->fixer->replaceToken( $stackPtr - 1, ' ' );
117 117
 		}
118 118
 	}
119 119
 
@@ -123,20 +123,20 @@  discard block
 block discarded – undo
123 123
 	 * @param int $next
124 124
 	 * @return void
125 125
 	 */
126
-	protected function assertSingleSpaceAfterIfNotMultiline(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $next) {
126
+	protected function assertSingleSpaceAfterIfNotMultiline( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $next ) {
127 127
 		$tokens = $phpcsFile->getTokens();
128 128
 
129
-		if ($tokens[$stackPtr]['line'] !== $tokens[$next]['line']) {
129
+		if ( $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $next ][ 'line' ] ) {
130 130
 			return;
131 131
 		}
132
-		if ($tokens[$stackPtr + 1]['content'] === ' ') {
132
+		if ( $tokens[ $stackPtr + 1 ][ 'content' ] === ' ' ) {
133 133
 			return;
134 134
 		}
135 135
 
136
-		$error = 'There must be a single space instead of `' . $tokens[$stackPtr + 1]['content'] . '`';
137
-		$fix = $phpcsFile->addFixableError($error, $stackPtr + 1, 'InvalidSpaceAfter');
138
-		if ($fix) {
139
-			$phpcsFile->fixer->replaceToken($stackPtr + 1, ' ');
136
+		$error = 'There must be a single space instead of `' . $tokens[ $stackPtr + 1 ][ 'content' ] . '`';
137
+		$fix = $phpcsFile->addFixableError( $error, $stackPtr + 1, 'InvalidSpaceAfter' );
138
+		if ( $fix ) {
139
+			$phpcsFile->fixer->replaceToken( $stackPtr + 1, ' ' );
140 140
 		}
141 141
 	}
142 142
 
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 * @param int $elseIndex
147 147
 	 * @return void
148 148
 	 */
149
-	protected function assertNoSpaceBetween(PHP_CodeSniffer_File $phpcsFile, $thenIndex, $elseIndex) {
150
-		if ($elseIndex - $thenIndex === 1) {
149
+	protected function assertNoSpaceBetween( PHP_CodeSniffer_File $phpcsFile, $thenIndex, $elseIndex ) {
150
+		if ( $elseIndex - $thenIndex === 1 ) {
151 151
 			return;
152 152
 		}
153 153
 
154 154
 		$error = 'There must be no space between ? and : for short ternary';
155
-		$fix = $phpcsFile->addFixableError($error, $thenIndex, 'SpaceInlineElse');
156
-		if (!$fix) {
155
+		$fix = $phpcsFile->addFixableError( $error, $thenIndex, 'SpaceInlineElse' );
156
+		if ( ! $fix ) {
157 157
 			return;
158 158
 		}
159 159
 
160
-		for ($i = $thenIndex + 1; $i < $elseIndex; ++$i) {
161
-			$phpcsFile->fixer->replaceToken($i, '');
160
+		for ( $i = $thenIndex + 1; $i < $elseIndex; ++$i ) {
161
+			$phpcsFile->fixer->replaceToken( $i, '' );
162 162
 		}
163 163
 	}
164 164
 
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/Methods/MethodDeclarationSniff.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 use PHP_CodeSniffer_Standards_AbstractScopeSniff;
20 20
 use PHP_CodeSniffer_Tokens;
21 21
 
22
-if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
23
-	throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
22
+if ( class_exists( 'PHP_CodeSniffer_Standards_AbstractScopeSniff', true ) === false ) {
23
+	throw new PHP_CodeSniffer_Exception( 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found' );
24 24
 }
25 25
 
26 26
 /**
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
 	 * @inheritDoc
41 41
 	 */
42 42
 	public function __construct() {
43
-		parent::__construct([T_CLASS, T_INTERFACE], [T_FUNCTION]);
43
+		parent::__construct( [ T_CLASS, T_INTERFACE ], [ T_FUNCTION ] );
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @inheritDoc
48 48
 	 */
49
-	protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) {
49
+	protected function processTokenWithinScope( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope ) {
50 50
 		$tokens = $phpcsFile->getTokens();
51 51
 
52
-		$methodName = $phpcsFile->getDeclarationName($stackPtr);
53
-		if ($methodName === null) {
52
+		$methodName = $phpcsFile->getDeclarationName( $stackPtr );
53
+		if ( $methodName === null ) {
54 54
 			// Ignore closures.
55 55
 			return;
56 56
 		}
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 		$final = 0;
62 62
 
63 63
 		$find = PHP_CodeSniffer_Tokens::$methodPrefixes;
64
-		$find[] = T_WHITESPACE;
65
-		$prev = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
64
+		$find[ ] = T_WHITESPACE;
65
+		$prev = $phpcsFile->findPrevious( $find, ( $stackPtr - 1 ), null, true );
66 66
 
67 67
 		$prefix = $stackPtr;
68
-		while (($prefix = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$methodPrefixes, ($prefix - 1), $prev)) !== false) {
69
-			switch ($tokens[$prefix]['code']) {
68
+		while ( ( $prefix = $phpcsFile->findPrevious( PHP_CodeSniffer_Tokens::$methodPrefixes, ( $prefix - 1 ), $prev ) ) !== false ) {
69
+			switch ( $tokens[ $prefix ][ 'code' ] ) {
70 70
 				case T_STATIC:
71 71
 					$static = $prefix;
72 72
 					break;
@@ -82,55 +82,55 @@  discard block
 block discarded – undo
82 82
 			}
83 83
 		}
84 84
 
85
-		$fixes = [];
85
+		$fixes = [ ];
86 86
 
87
-		if ($visibility !== 0 && $final > $visibility) {
87
+		if ( $visibility !== 0 && $final > $visibility ) {
88 88
 			$error = 'The final declaration must precede the visibility declaration';
89
-			$fix = $phpcsFile->addFixableError($error, $final, 'FinalAfterVisibility');
90
-			if ($fix === true) {
91
-				$fixes[$final] = '';
92
-				$fixes[($final + 1)] = '';
93
-				if (isset($fixes[$visibility]) === true) {
94
-					$fixes[$visibility] = 'final ' . $fixes[$visibility];
89
+			$fix = $phpcsFile->addFixableError( $error, $final, 'FinalAfterVisibility' );
90
+			if ( $fix === true ) {
91
+				$fixes[ $final ] = '';
92
+				$fixes[ ( $final + 1 ) ] = '';
93
+				if ( isset( $fixes[ $visibility ] ) === true ) {
94
+					$fixes[ $visibility ] = 'final ' . $fixes[ $visibility ];
95 95
 				} else {
96
-					$fixes[$visibility] = 'final ' . $tokens[$visibility]['content'];
96
+					$fixes[ $visibility ] = 'final ' . $tokens[ $visibility ][ 'content' ];
97 97
 				}
98 98
 			}
99 99
 		}
100 100
 
101
-		if ($visibility !== 0 && $abstract > $visibility) {
101
+		if ( $visibility !== 0 && $abstract > $visibility ) {
102 102
 			$error = 'The abstract declaration must precede the visibility declaration';
103
-			$fix = $phpcsFile->addFixableError($error, $abstract, 'AbstractAfterVisibility');
104
-			if ($fix === true) {
105
-				$fixes[$abstract] = '';
106
-				$fixes[($abstract + 1)] = '';
107
-				if (isset($fixes[$visibility]) === true) {
108
-					$fixes[$visibility] = 'abstract ' . $fixes[$visibility];
103
+			$fix = $phpcsFile->addFixableError( $error, $abstract, 'AbstractAfterVisibility' );
104
+			if ( $fix === true ) {
105
+				$fixes[ $abstract ] = '';
106
+				$fixes[ ( $abstract + 1 ) ] = '';
107
+				if ( isset( $fixes[ $visibility ] ) === true ) {
108
+					$fixes[ $visibility ] = 'abstract ' . $fixes[ $visibility ];
109 109
 				} else {
110
-					$fixes[$visibility] = 'abstract ' . $tokens[$visibility]['content'];
110
+					$fixes[ $visibility ] = 'abstract ' . $tokens[ $visibility ][ 'content' ];
111 111
 				}
112 112
 			}
113 113
 		}
114 114
 
115
-		if ($static !== 0 && $static < $visibility) {
115
+		if ( $static !== 0 && $static < $visibility ) {
116 116
 			$error = 'The static declaration must come after the visibility declaration';
117
-			$fix = $phpcsFile->addFixableError($error, $static, 'StaticBeforeVisibility');
118
-			if ($fix === true) {
119
-				$fixes[$static] = '';
120
-				$fixes[($static + 1)] = '';
121
-				if (isset($fixes[$visibility]) === true) {
122
-					$fixes[$visibility] = $fixes[$visibility] . ' static';
117
+			$fix = $phpcsFile->addFixableError( $error, $static, 'StaticBeforeVisibility' );
118
+			if ( $fix === true ) {
119
+				$fixes[ $static ] = '';
120
+				$fixes[ ( $static + 1 ) ] = '';
121
+				if ( isset( $fixes[ $visibility ] ) === true ) {
122
+					$fixes[ $visibility ] = $fixes[ $visibility ] . ' static';
123 123
 				} else {
124
-					$fixes[$visibility] = $tokens[$visibility]['content'] . ' static';
124
+					$fixes[ $visibility ] = $tokens[ $visibility ][ 'content' ] . ' static';
125 125
 				}
126 126
 			}
127 127
 		}
128 128
 
129 129
 		// Batch all the fixes together to reduce the possibility of conflicts.
130
-		if (empty($fixes) === false) {
130
+		if ( empty( $fixes ) === false ) {
131 131
 			$phpcsFile->fixer->beginChangeset();
132
-			foreach ($fixes as $stackPtr => $content) {
133
-				$phpcsFile->fixer->replaceToken($stackPtr, $content);
132
+			foreach ( $fixes as $stackPtr => $content ) {
133
+				$phpcsFile->fixer->replaceToken( $stackPtr, $content );
134 134
 			}
135 135
 
136 136
 			$phpcsFile->fixer->endChangeset();
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/Methods/MethodMultilineArgumentsSniff.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,59 +17,59 @@
 block discarded – undo
17 17
 	 * @inheritDoc
18 18
 	 */
19 19
 	public function register() {
20
-		return [T_FUNCTION];
20
+		return [ T_FUNCTION ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
26
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
27 27
 		$tokens = $phpcsFile->getTokens();
28 28
 
29
-		$stringIndex = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
30
-		if ($tokens[$stringIndex]['code'] !== T_STRING) {
29
+		$stringIndex = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
30
+		if ( $tokens[ $stringIndex ][ 'code' ] !== T_STRING ) {
31 31
 			return;
32 32
 		}
33 33
 
34
-		$parenthesisStartIndex = $phpcsFile->findNext(T_WHITESPACE, ($stringIndex + 1), null, true);
35
-		if ($tokens[$parenthesisStartIndex]['type'] !== 'T_OPEN_PARENTHESIS') {
34
+		$parenthesisStartIndex = $phpcsFile->findNext( T_WHITESPACE, ( $stringIndex + 1 ), null, true );
35
+		if ( $tokens[ $parenthesisStartIndex ][ 'type' ] !== 'T_OPEN_PARENTHESIS' ) {
36 36
 			return;
37 37
 		}
38 38
 
39
-		$parenthesisEndIndex = $tokens[$parenthesisStartIndex]['parenthesis_closer'];
39
+		$parenthesisEndIndex = $tokens[ $parenthesisStartIndex ][ 'parenthesis_closer' ];
40 40
 
41
-		if ($tokens[$parenthesisEndIndex]['line'] === $tokens[$stackPtr]['line']) {
41
+		if ( $tokens[ $parenthesisEndIndex ][ 'line' ] === $tokens[ $stackPtr ][ 'line' ] ) {
42 42
 			return;
43 43
 		}
44 44
 
45
-		for ($i = $parenthesisStartIndex + 1; $i < $parenthesisEndIndex - 1; $i++) {
46
-			if ($tokens[$i]['code'] !== T_VARIABLE) {
45
+		for ( $i = $parenthesisStartIndex + 1; $i < $parenthesisEndIndex - 1; $i++ ) {
46
+			if ( $tokens[ $i ][ 'code' ] !== T_VARIABLE ) {
47 47
 				continue;
48 48
 			}
49 49
 
50
-			$possibleCommaIndex = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true);
51
-			if (!$possibleCommaIndex || $tokens[$possibleCommaIndex]['type'] !== 'T_COMMA') {
50
+			$possibleCommaIndex = $phpcsFile->findPrevious( T_WHITESPACE, ( $i - 1 ), null, true );
51
+			if ( ! $possibleCommaIndex || $tokens[ $possibleCommaIndex ][ 'type' ] !== 'T_COMMA' ) {
52 52
 				continue;
53 53
 			}
54 54
 
55
-			if ($tokens[$possibleCommaIndex]['line'] !== $tokens[$i]['line']) {
55
+			if ( $tokens[ $possibleCommaIndex ][ 'line' ] !== $tokens[ $i ][ 'line' ] ) {
56 56
 				continue;
57 57
 			}
58 58
 
59 59
 			$error = 'Multiline method arguments must be a single one per line';
60
-			$fix = $phpcsFile->addFixableError($error, $i, 'ContentAfterOpen');
60
+			$fix = $phpcsFile->addFixableError( $error, $i, 'ContentAfterOpen' );
61 61
 
62
-			if ($fix === true) {
63
-				$indentation = $this->getIndentationCharacter($this->getIndentationWhitespace($phpcsFile, $i));
64
-				$indentation = str_repeat($indentation, $this->getIndentationColumn($phpcsFile, $i));
62
+			if ( $fix === true ) {
63
+				$indentation = $this->getIndentationCharacter( $this->getIndentationWhitespace( $phpcsFile, $i ) );
64
+				$indentation = str_repeat( $indentation, $this->getIndentationColumn( $phpcsFile, $i ) );
65 65
 
66 66
 				$phpcsFile->fixer->beginChangeset();
67 67
 
68
-				if ($i - $possibleCommaIndex > 1) {
69
-					$phpcsFile->fixer->replaceToken($i - 1, '');
68
+				if ( $i - $possibleCommaIndex > 1 ) {
69
+					$phpcsFile->fixer->replaceToken( $i - 1, '' );
70 70
 				}
71
-				$phpcsFile->fixer->addNewline($i - 1);
72
-				$phpcsFile->fixer->addContentBefore($i, $indentation);
71
+				$phpcsFile->fixer->addNewline( $i - 1 );
72
+				$phpcsFile->fixer->addContentBefore( $i, $indentation );
73 73
 
74 74
 				$phpcsFile->fixer->endChangeset();
75 75
 			}
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/Commenting/DocBlockVarWithoutNameSniff.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,45 +29,45 @@
 block discarded – undo
29 29
 	 * @inheritDoc
30 30
 	 */
31 31
 	public function register() {
32
-		return [T_DOC_COMMENT_OPEN_TAG];
32
+		return [ T_DOC_COMMENT_OPEN_TAG ];
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	 * @inheritDoc
37 37
 	 */
38
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
38
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
39 39
 		$tokens = $phpcsFile->getTokens();
40 40
 		$docBlockStartIndex = $stackPtr;
41
-		$docBlockEndIndex = $tokens[$stackPtr]['comment_closer'];
41
+		$docBlockEndIndex = $tokens[ $stackPtr ][ 'comment_closer' ];
42 42
 
43
-		$indentationLevel = $this->getIndentationLevel($phpcsFile, $stackPtr);
43
+		$indentationLevel = $this->getIndentationLevel( $phpcsFile, $stackPtr );
44 44
 
45 45
 		// Skip for inline comments
46
-		if ($indentationLevel > 1) {
46
+		if ( $indentationLevel > 1 ) {
47 47
 			return;
48 48
 		}
49 49
 
50
-		for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
51
-			if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
50
+		for ( $i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++ ) {
51
+			if ( $tokens[ $i ][ 'type' ] !== 'T_DOC_COMMENT_TAG' ) {
52 52
 				continue;
53 53
 			}
54
-			if (!in_array($tokens[$i]['content'], ['@var'])) {
54
+			if ( ! in_array( $tokens[ $i ][ 'content' ], [ '@var' ] ) ) {
55 55
 				continue;
56 56
 			}
57 57
 
58 58
 			//$nextIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $i + 1, $docBlockEndIndex, true);
59
-			$nextIndex = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $i + 1, $docBlockEndIndex);
60
-			if (!$nextIndex || strpos($tokens[$nextIndex]['content'], ' ') === false) {
59
+			$nextIndex = $phpcsFile->findNext( T_DOC_COMMENT_STRING, $i + 1, $docBlockEndIndex );
60
+			if ( ! $nextIndex || strpos( $tokens[ $nextIndex ][ 'content' ], ' ' ) === false ) {
61 61
 				continue;
62 62
 			}
63 63
 
64
-			$content = $tokens[$nextIndex]['content'];
65
-			preg_match_all('/ \$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $content, $matches);
64
+			$content = $tokens[ $nextIndex ][ 'content' ];
65
+			preg_match_all( '/ \$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $content, $matches );
66 66
 
67
-			if (isset($matches[0][0])) {
68
-				$fix = $phpcsFile->addFixableError('@var annotations should not contain the variable name.', $i);
69
-				if ($fix) {
70
-					$phpcsFile->fixer->replaceToken($nextIndex, str_replace($matches[0][0], '', $content));
67
+			if ( isset( $matches[ 0 ][ 0 ] ) ) {
68
+				$fix = $phpcsFile->addFixableError( '@var annotations should not contain the variable name.', $i );
69
+				if ( $fix ) {
70
+					$phpcsFile->fixer->replaceToken( $nextIndex, str_replace( $matches[ 0 ][ 0 ], '', $content ) );
71 71
 				}
72 72
 			}
73 73
 		}
Please login to merge, or discard this patch.