66 *
77 * For the full copyright and license information, please view the LICENSE
88 * file that was distributed with this source code.
9+ *
10+ * This file contains code from "phpcs-calisthenics-rules" repository
11+ * found at https://github.com/object-calisthenics
12+ * Copyright (c) 2014 Doctrine Project
13+ * released under MIT license.
914 */
1015
1116namespace Inpsyde \CodingStandard \Sniffs \CodeQuality ;
1520
1621/**
1722 * @package php-coding-standards
18- * @license MIT
23+ * @license http://opensource.org/licenses/MIT MIT
1924 */
2025final class MaxNestingLevelSniff implements Sniff
2126{
@@ -66,7 +71,7 @@ public function register(): array
6671 * @param File $file
6772 * @param int $position
6873 */
69- public function process (File $ file , $ position ): void
74+ public function process (File $ file , $ position )
7075 {
7176 $ this ->file = $ file ;
7277 $ this ->position = $ position ;
@@ -88,7 +93,7 @@ public function process(File $file, $position): void
8893 $ this ->handleNestingLevel ($ this ->nestingLevel );
8994 }
9095
91- private function handleNestingLevel (int $ nestingLevel ): void
96+ private function handleNestingLevel (int $ nestingLevel )
9297 {
9398 if ($ nestingLevel > $ this ->maxNestingLevel ) {
9499 $ levelPluralization = $ this ->maxNestingLevel > 1 ? 's ' : '' ;
@@ -107,7 +112,7 @@ private function handleNestingLevel(int $nestingLevel): void
107112 /**
108113 * @param mixed[] $tokens
109114 */
110- private function iterateTokens (int $ start , int $ end , array $ tokens ): void
115+ private function iterateTokens (int $ start , int $ end , array $ tokens )
111116 {
112117 $ this ->currentPtr = $ start + 1 ;
113118
@@ -122,7 +127,7 @@ private function iterateTokens(int $start, int $end, array $tokens): void
122127 /**
123128 * @param mixed[] $nestedToken
124129 */
125- private function handleToken (array $ nestedToken ): void
130+ private function handleToken (array $ nestedToken )
126131 {
127132 $ this ->handleClosureToken ($ nestedToken );
128133 $ this ->handleCaseToken ($ nestedToken );
@@ -149,7 +154,7 @@ private function subtractFunctionNestingLevel(array $token): int
149154 /**
150155 * @param mixed[] $nestedToken
151156 */
152- private function handleClosureToken (array $ nestedToken ): void
157+ private function handleClosureToken (array $ nestedToken )
153158 {
154159 if ($ nestedToken ['code ' ] === T_CLOSURE ) {
155160 // Move index pointer in case we found a lambda function
@@ -163,7 +168,7 @@ private function handleClosureToken(array $nestedToken): void
163168 /**
164169 * @param mixed[] $nestedToken
165170 */
166- private function handleCaseToken (array $ nestedToken ): void
171+ private function handleCaseToken (array $ nestedToken )
167172 {
168173 if (in_array ($ nestedToken ['code ' ], [T_CASE , T_DEFAULT ])) {
169174 array_push ($ this ->ignoredScopeStack , $ nestedToken );
@@ -172,7 +177,7 @@ private function handleCaseToken(array $nestedToken): void
172177 }
173178 }
174179
175- private function adjustNestingLevelToIgnoredScope (): void
180+ private function adjustNestingLevelToIgnoredScope ()
176181 {
177182 // Iterated through ignored scope stack to find out if
178183 // anything can be popped out and adjust nesting level.
@@ -185,7 +190,7 @@ private function adjustNestingLevelToIgnoredScope(): void
185190 * @param int $key
186191 * @param mixed[] $ignoredScope
187192 */
188- private function unsetScopeIfNotCurrent (int $ key , array $ ignoredScope ): void
193+ private function unsetScopeIfNotCurrent (int $ key , array $ ignoredScope )
189194 {
190195 if ($ ignoredScope ['scope_closer ' ] !== $ this ->currentPtr ) {
191196 return ;
0 commit comments