@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly Parser $parser |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function canConfigure(Command $command, \ReflectionClass $reflection): bool |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | |
25 | 25 | public function configure(Command $command, \ReflectionClass $reflection): void |
26 | 26 | { |
27 | - $result = $this->parser->parse((string) $reflection->getConstant('SIGNATURE')); |
|
27 | + $result = $this->parser->parse((string)$reflection->getConstant('SIGNATURE')); |
|
28 | 28 | |
29 | 29 | $command->setName($result->name); |
30 | - $command->setDescription($result->description ?? (string) $reflection->getConstant('DESCRIPTION')); |
|
30 | + $command->setDescription($result->description ?? (string)$reflection->getConstant('DESCRIPTION')); |
|
31 | 31 | |
32 | - foreach ($result->options as $option) { |
|
32 | + foreach ($result->options as $option){ |
|
33 | 33 | $command->getDefinition()->addOption($option); |
34 | 34 | } |
35 | 35 | |
36 | - foreach ($result->arguments as $argument) { |
|
36 | + foreach ($result->arguments as $argument){ |
|
37 | 37 | $command->getDefinition()->addArgument($argument); |
38 | 38 | } |
39 | 39 | } |
@@ -29,11 +29,13 @@ |
||
29 | 29 | $command->setName($result->name); |
30 | 30 | $command->setDescription($result->description ?? (string) $reflection->getConstant('DESCRIPTION')); |
31 | 31 | |
32 | - foreach ($result->options as $option) { |
|
32 | + foreach ($result->options as $option) |
|
33 | + { |
|
33 | 34 | $command->getDefinition()->addOption($option); |
34 | 35 | } |
35 | 36 | |
36 | - foreach ($result->arguments as $argument) { |
|
37 | + foreach ($result->arguments as $argument) |
|
38 | + { |
|
37 | 39 | $command->getDefinition()->addArgument($argument); |
38 | 40 | } |
39 | 41 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | $core = $this->getCore( |
15 | 15 | $this->getStaticLocator([ |
16 | - new class extends Command { |
|
16 | + new class extends Command{ |
|
17 | 17 | protected const SIGNATURE = 'foo:bar {arg?} {--o|option}'; |
18 | 18 | |
19 | 19 | public function perform(): int |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | $argument = $this->argument('arg'); |
22 | 22 | $option = $this->option('option'); |
23 | 23 | |
24 | - if ($argument) { |
|
24 | + if ($argument){ |
|
25 | 25 | $this->write('argument : '.$argument); |
26 | 26 | } |
27 | 27 | |
28 | - if ($option) { |
|
28 | + if ($option){ |
|
29 | 29 | $this->write('option : '.$option); |
30 | 30 | } |
31 | 31 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $core = $this->getCore( |
67 | 67 | $this->getStaticLocator([ |
68 | - new class extends Command { |
|
68 | + new class extends Command{ |
|
69 | 69 | protected const SIGNATURE = 'foo:bar {arg[]?} {--o|option[]=}'; |
70 | 70 | |
71 | 71 | public function perform(): int |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | $argument = (array)$this->argument('arg'); |
74 | 74 | $option = (array)$this->option('option'); |
75 | 75 | |
76 | - if ($argument) { |
|
76 | + if ($argument){ |
|
77 | 77 | $this->write('argument : '.\implode(',', $argument)); |
78 | 78 | } |
79 | 79 | |
80 | - if ($option) { |
|
80 | + if ($option){ |
|
81 | 81 | $this->write('option : '.\implode(',', $option)); |
82 | 82 | } |
83 | 83 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $core = $this->getCore( |
120 | 120 | $this->getStaticLocator([ |
121 | - new class extends Command { |
|
121 | + new class extends Command{ |
|
122 | 122 | protected const SIGNATURE = 'foo:bar |
123 | 123 | {foo : Foo arg description. } |
124 | 124 | {bar=default : Bar arg description. } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $core = $this->getCore( |
169 | 169 | $this->getStaticLocator([ |
170 | - new class extends Command { |
|
170 | + new class extends Command{ |
|
171 | 171 | protected const SIGNATURE = 'foo:bar'; |
172 | 172 | protected const DESCRIPTION = 'baz'; |
173 | 173 |
@@ -13,7 +13,8 @@ discard block |
||
13 | 13 | { |
14 | 14 | $core = $this->getCore( |
15 | 15 | $this->getStaticLocator([ |
16 | - new class extends Command { |
|
16 | + new class extends Command |
|
17 | + { |
|
17 | 18 | protected const SIGNATURE = 'foo:bar {arg?} {--o|option}'; |
18 | 19 | |
19 | 20 | public function perform(): int |
@@ -21,11 +22,13 @@ discard block |
||
21 | 22 | $argument = $this->argument('arg'); |
22 | 23 | $option = $this->option('option'); |
23 | 24 | |
24 | - if ($argument) { |
|
25 | + if ($argument) |
|
26 | + { |
|
25 | 27 | $this->write('argument : '.$argument); |
26 | 28 | } |
27 | 29 | |
28 | - if ($option) { |
|
30 | + if ($option) |
|
31 | + { |
|
29 | 32 | $this->write('option : '.$option); |
30 | 33 | } |
31 | 34 | |
@@ -65,7 +68,8 @@ discard block |
||
65 | 68 | { |
66 | 69 | $core = $this->getCore( |
67 | 70 | $this->getStaticLocator([ |
68 | - new class extends Command { |
|
71 | + new class extends Command |
|
72 | + { |
|
69 | 73 | protected const SIGNATURE = 'foo:bar {arg[]?} {--o|option[]=}'; |
70 | 74 | |
71 | 75 | public function perform(): int |
@@ -73,11 +77,13 @@ discard block |
||
73 | 77 | $argument = (array)$this->argument('arg'); |
74 | 78 | $option = (array)$this->option('option'); |
75 | 79 | |
76 | - if ($argument) { |
|
80 | + if ($argument) |
|
81 | + { |
|
77 | 82 | $this->write('argument : '.\implode(',', $argument)); |
78 | 83 | } |
79 | 84 | |
80 | - if ($option) { |
|
85 | + if ($option) |
|
86 | + { |
|
81 | 87 | $this->write('option : '.\implode(',', $option)); |
82 | 88 | } |
83 | 89 | |
@@ -118,7 +124,8 @@ discard block |
||
118 | 124 | { |
119 | 125 | $core = $this->getCore( |
120 | 126 | $this->getStaticLocator([ |
121 | - new class extends Command { |
|
127 | + new class extends Command |
|
128 | + { |
|
122 | 129 | protected const SIGNATURE = 'foo:bar |
123 | 130 | {foo : Foo arg description. } |
124 | 131 | {bar=default : Bar arg description. } |
@@ -167,7 +174,8 @@ discard block |
||
167 | 174 | { |
168 | 175 | $core = $this->getCore( |
169 | 176 | $this->getStaticLocator([ |
170 | - new class extends Command { |
|
177 | + new class extends Command |
|
178 | + { |
|
171 | 179 | protected const SIGNATURE = 'foo:bar'; |
172 | 180 | protected const DESCRIPTION = 'baz'; |
173 | 181 |
@@ -119,7 +119,7 @@ |
||
119 | 119 | -o, --id[=ID] Id option description. (multiple values allowed) |
120 | 120 | -Q, --quit Quit option description. |
121 | 121 | --naf[=NAF] Naf option description. [default: "default"] |
122 | -HELP, $core->run(command: 'help', input: ['command_name' => 'foo:bar'])->getOutput()->fetch()); |
|
122 | +help, $core->run(command: 'help', input: ['command_name' => 'foo:bar'])->getOutput()->fetch()); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function testDescriptionFromConstant(): void |
@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | public function __construct( |
21 | 21 | public readonly ?string $name = null, |
22 | - public readonly string|array|null $shortcut = null, |
|
22 | + public readonly string | array | null $shortcut = null, |
|
23 | 23 | public readonly ?string $description = null, |
24 | 24 | public readonly ?int $mode = null, |
25 | - public readonly \Closure|array $suggestedValues = [] |
|
26 | - ) { |
|
25 | + public readonly \Closure | array $suggestedValues = [] |
|
26 | + ){ |
|
27 | 27 | } |
28 | 28 | } |
@@ -8,7 +8,8 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct() |
10 | 10 | { |
11 | - $class = new class ('foo', 'bar') { |
|
11 | + $class = new class ('foo', 'bar') |
|
12 | + { |
|
12 | 13 | private function someFunc(): void |
13 | 14 | { |
14 | 15 | } |
@@ -19,13 +19,13 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | } |
22 | -class;FOO; |
|
22 | +class; FOO; |
|
23 | 23 | |
24 | 24 | <<<'class' |
25 | 25 | class FooBar |
26 | 26 | { |
27 | 27 | |
28 | 28 | } |
29 | -class ;FOO; |
|
29 | +class; FOO; |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public function __construct() |
12 | 12 | { |
13 | 13 | <<<class |
14 | -FooBar |
|
14 | +foobar |
|
15 | 15 | class; |
16 | 16 | |
17 | 17 | <<<class |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function __construct( |
115 | 115 | private readonly string $filename |
116 | - ) { |
|
116 | + ){ |
|
117 | 117 | $this->tokens = Tokenizer::getTokens($filename); |
118 | 118 | $this->countTokens = \count($this->tokens); |
119 | 119 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function getClasses(): array |
144 | 144 | { |
145 | - if (!isset($this->declarations['T_CLASS'])) { |
|
145 | + if (!isset($this->declarations['T_CLASS'])){ |
|
146 | 146 | return []; |
147 | 147 | } |
148 | 148 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getEnums(): array |
156 | 156 | { |
157 | - if (!isset($this->declarations['T_ENUM'])) { |
|
157 | + if (!isset($this->declarations['T_ENUM'])){ |
|
158 | 158 | return []; |
159 | 159 | } |
160 | 160 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function getTraits(): array |
168 | 168 | { |
169 | - if (!isset($this->declarations['T_TRAIT'])) { |
|
169 | + if (!isset($this->declarations['T_TRAIT'])){ |
|
170 | 170 | return []; |
171 | 171 | } |
172 | 172 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getInterfaces(): array |
180 | 180 | { |
181 | - if (!isset($this->declarations['T_INTERFACE'])) { |
|
181 | + if (!isset($this->declarations['T_INTERFACE'])){ |
|
182 | 182 | return []; |
183 | 183 | } |
184 | 184 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function getInvocations(): array |
211 | 211 | { |
212 | - if (empty($this->invocations)) { |
|
212 | + if (empty($this->invocations)){ |
|
213 | 213 | $this->locateInvocations($this->getTokens()); |
214 | 214 | } |
215 | 215 | |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected function locateDeclarations() |
239 | 239 | { |
240 | - foreach ($this->getTokens() as $tokenID => $token) { |
|
241 | - if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) { |
|
240 | + foreach ($this->getTokens() as $tokenID => $token){ |
|
241 | + if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)){ |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | |
245 | - switch ($token[self::TOKEN_TYPE]) { |
|
245 | + switch ($token[self::TOKEN_TYPE]){ |
|
246 | 246 | case T_NAMESPACE: |
247 | 247 | $this->registerNamespace($tokenID); |
248 | 248 | break; |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | case T_TRAIT: |
260 | 260 | case T_INTERFACE: |
261 | 261 | case T_ENUM: |
262 | - if ($this->isClassNameConst($tokenID)) { |
|
262 | + if ($this->isClassNameConst($tokenID)){ |
|
263 | 263 | // PHP5.5 ClassName::class constant |
264 | 264 | continue 2; |
265 | 265 | } |
266 | 266 | |
267 | - if ($this->isAnonymousClass($tokenID)) { |
|
267 | + if ($this->isAnonymousClass($tokenID)){ |
|
268 | 268 | // PHP7.0 Anonymous classes new class ('foo', 'bar') |
269 | 269 | continue 2; |
270 | 270 | } |
271 | 271 | |
272 | - if (!$this->isCorrectDeclaration($tokenID)) { |
|
272 | + if (!$this->isCorrectDeclaration($tokenID)){ |
|
273 | 273 | // PHP8.0 Named parameters ->foo(class: 'bar') |
274 | 274 | continue 2; |
275 | 275 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | //Dropping empty namespace |
289 | - if (isset($this->namespaces[''])) { |
|
289 | + if (isset($this->namespaces[''])){ |
|
290 | 290 | $this->namespaces['\\'] = $this->namespaces['']; |
291 | 291 | unset($this->namespaces['']); |
292 | 292 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | $namespace = ''; |
301 | 301 | $localID = $tokenID + 1; |
302 | 302 | |
303 | - do { |
|
303 | + do{ |
|
304 | 304 | $token = $this->tokens[$localID++]; |
305 | - if ($token[self::TOKEN_CODE] === '{') { |
|
305 | + if ($token[self::TOKEN_CODE] === '{'){ |
|
306 | 306 | break; |
307 | 307 | } |
308 | 308 | |
309 | 309 | $namespace .= $token[self::TOKEN_CODE]; |
310 | - } while ( |
|
310 | + }while ( |
|
311 | 311 | isset($this->tokens[$localID]) |
312 | 312 | && $this->tokens[$localID][self::TOKEN_CODE] !== '{' |
313 | 313 | && $this->tokens[$localID][self::TOKEN_CODE] !== ';' |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | $namespace = \trim($namespace); |
318 | 318 | |
319 | 319 | $uses = []; |
320 | - if (isset($this->namespaces[$namespace])) { |
|
320 | + if (isset($this->namespaces[$namespace])){ |
|
321 | 321 | $uses = $this->namespaces[$namespace]; |
322 | 322 | } |
323 | 323 | |
324 | - if ($this->tokens[$localID][self::TOKEN_CODE] === ';') { |
|
324 | + if ($this->tokens[$localID][self::TOKEN_CODE] === ';'){ |
|
325 | 325 | $endingID = \count($this->tokens) - 1; |
326 | - } else { |
|
326 | + }else{ |
|
327 | 327 | $endingID = $this->endingToken($tokenID); |
328 | 328 | } |
329 | 329 | |
@@ -343,20 +343,20 @@ discard block |
||
343 | 343 | |
344 | 344 | $class = ''; |
345 | 345 | $localAlias = null; |
346 | - for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) { |
|
347 | - if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) { |
|
346 | + for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID){ |
|
347 | + if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS){ |
|
348 | 348 | $localAlias = ''; |
349 | 349 | continue; |
350 | 350 | } |
351 | 351 | |
352 | - if ($localAlias === null) { |
|
352 | + if ($localAlias === null){ |
|
353 | 353 | $class .= $this->tokens[$localID][self::TOKEN_CODE]; |
354 | - } else { |
|
354 | + }else{ |
|
355 | 355 | $localAlias .= $this->tokens[$localID][self::TOKEN_CODE]; |
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - if (empty($localAlias)) { |
|
359 | + if (empty($localAlias)){ |
|
360 | 360 | $names = explode('\\', $class); |
361 | 361 | $localAlias = end($names); |
362 | 362 | } |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | */ |
370 | 370 | private function registerFunction(int $tokenID): void |
371 | 371 | { |
372 | - foreach ($this->declarations as $declarations) { |
|
373 | - foreach ($declarations as $location) { |
|
374 | - if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) { |
|
372 | + foreach ($this->declarations as $declarations){ |
|
373 | + foreach ($declarations as $location){ |
|
374 | + if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]){ |
|
375 | 375 | //We are inside class, function is method |
376 | 376 | return; |
377 | 377 | } |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | } |
380 | 380 | |
381 | 381 | $localID = $tokenID + 1; |
382 | - while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) { |
|
382 | + while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING){ |
|
383 | 383 | //Fetching function name |
384 | 384 | ++$localID; |
385 | 385 | } |
386 | 386 | |
387 | 387 | $name = $this->tokens[$localID][self::TOKEN_CODE]; |
388 | - if (!empty($namespace = $this->activeNamespace($tokenID))) { |
|
389 | - $name = $namespace . self::NS_SEPARATOR . $name; |
|
388 | + if (!empty($namespace = $this->activeNamespace($tokenID))){ |
|
389 | + $name = $namespace.self::NS_SEPARATOR.$name; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | $this->functions[$name] = [ |
@@ -402,13 +402,13 @@ discard block |
||
402 | 402 | private function registerDeclaration(int $tokenID, int $tokenType): void |
403 | 403 | { |
404 | 404 | $localID = $tokenID + 1; |
405 | - while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) { |
|
405 | + while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING){ |
|
406 | 406 | ++$localID; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $name = $this->tokens[$localID][self::TOKEN_CODE]; |
410 | - if (!empty($namespace = $this->activeNamespace($tokenID))) { |
|
411 | - $name = $namespace . self::NS_SEPARATOR . $name; |
|
410 | + if (!empty($namespace = $this->activeNamespace($tokenID))){ |
|
411 | + $name = $namespace.self::NS_SEPARATOR.$name; |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | $this->declarations[\token_name($tokenType)][$name] = [ |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | /** |
431 | 431 | * Check if token ID represents anonymous class creation, e.g. `new class ('foo', 'bar')`. |
432 | 432 | */ |
433 | - private function isAnonymousClass(int|string $tokenID): bool |
|
433 | + private function isAnonymousClass(int | string $tokenID): bool |
|
434 | 434 | { |
435 | 435 | return $this->tokens[$tokenID][self::TOKEN_TYPE] === T_CLASS |
436 | 436 | && isset($this->tokens[$tokenID - 2]) |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | /** |
441 | 441 | * Check if token ID represents named parameter with name `class`, e.g. `foo(class: SomeClass::name)`. |
442 | 442 | */ |
443 | - private function isCorrectDeclaration(int|string $tokenID): bool |
|
443 | + private function isCorrectDeclaration(int | string $tokenID): bool |
|
444 | 444 | { |
445 | 445 | return \in_array($this->tokens[$tokenID][self::TOKEN_TYPE], [T_CLASS, T_TRAIT, T_INTERFACE, T_ENUM], true) |
446 | 446 | && isset($this->tokens[$tokenID + 2]) |
@@ -473,24 +473,24 @@ discard block |
||
473 | 473 | |
474 | 474 | //Tokens used to re-enable token detection |
475 | 475 | $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR]; |
476 | - foreach ($tokens as $tokenID => $token) { |
|
476 | + foreach ($tokens as $tokenID => $token){ |
|
477 | 477 | $tokenType = $token[self::TOKEN_TYPE]; |
478 | 478 | |
479 | 479 | //We are not indexing function declarations or functions called from $objects. |
480 | - if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) { |
|
480 | + if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])){ |
|
481 | 481 | if ( |
482 | 482 | empty($argumentsTID) |
483 | 483 | && ( |
484 | 484 | empty($invocationTID) |
485 | 485 | || $this->getSource($invocationTID, $tokenID - 1) !== '$this' |
486 | 486 | ) |
487 | - ) { |
|
487 | + ){ |
|
488 | 488 | //Not a call, function declaration, or object method |
489 | 489 | $ignore = true; |
490 | 490 | continue; |
491 | 491 | } |
492 | - } elseif ($ignore) { |
|
493 | - if (!\in_array($tokenType, $stopTokens)) { |
|
492 | + } elseif ($ignore){ |
|
493 | + if (!\in_array($tokenType, $stopTokens)){ |
|
494 | 494 | //Returning to search |
495 | 495 | $ignore = false; |
496 | 496 | } |
@@ -498,13 +498,13 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | //We are inside function, and there is "(", indexing arguments. |
501 | - if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) { |
|
502 | - if (empty($argumentsTID)) { |
|
501 | + if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')){ |
|
502 | + if (empty($argumentsTID)){ |
|
503 | 503 | $argumentsTID = $tokenID; |
504 | 504 | } |
505 | 505 | |
506 | 506 | ++$level; |
507 | - if ($level != 1) { |
|
507 | + if ($level != 1){ |
|
508 | 508 | //Not arguments beginning, but arguments part |
509 | 509 | $arguments[$tokenID] = $token; |
510 | 510 | } |
@@ -513,16 +513,16 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | //We are inside function arguments and ")" met. |
516 | - if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) { |
|
516 | + if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')){ |
|
517 | 517 | --$level; |
518 | - if ($level == -1) { |
|
518 | + if ($level == -1){ |
|
519 | 519 | $invocationTID = false; |
520 | 520 | $level = 0; |
521 | 521 | continue; |
522 | 522 | } |
523 | 523 | |
524 | 524 | //Function fully indexed, we can process it now. |
525 | - if ($level == 0) { |
|
525 | + if ($level == 0){ |
|
526 | 526 | $this->registerInvocation( |
527 | 527 | $invocationTID, |
528 | 528 | $argumentsTID, |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | //Closing search |
535 | 535 | $arguments = []; |
536 | 536 | $argumentsTID = $invocationTID = false; |
537 | - } else { |
|
537 | + }else{ |
|
538 | 538 | //Not arguments beginning, but arguments part |
539 | 539 | $arguments[$tokenID] = $token; |
540 | 540 | } |
@@ -543,13 +543,13 @@ discard block |
||
543 | 543 | } |
544 | 544 | |
545 | 545 | //Still inside arguments. |
546 | - if (!empty($invocationTID) && !empty($level)) { |
|
546 | + if (!empty($invocationTID) && !empty($level)){ |
|
547 | 547 | $arguments[$tokenID] = $token; |
548 | 548 | continue; |
549 | 549 | } |
550 | 550 | |
551 | 551 | //Nothing valuable to remember, will be parsed later. |
552 | - if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) { |
|
552 | + if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)){ |
|
553 | 553 | continue; |
554 | 554 | } |
555 | 555 | |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | || $tokenType == T_STATIC |
560 | 560 | || $tokenType == T_NS_SEPARATOR |
561 | 561 | || ($tokenType == T_VARIABLE && $token[self::TOKEN_CODE] === '$this') |
562 | - ) { |
|
562 | + ){ |
|
563 | 563 | $invocationTID = $tokenID; |
564 | 564 | $level = 0; |
565 | 565 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | |
589 | 589 | [$class, $operator, $name] = $this->fetchContext($invocationID, $argumentsID); |
590 | 590 | |
591 | - if (!empty($operator) && empty($class)) { |
|
591 | + if (!empty($operator) && empty($class)){ |
|
592 | 592 | //Non detectable |
593 | 593 | return; |
594 | 594 | } |
@@ -614,17 +614,17 @@ discard block |
||
614 | 614 | $name = \trim($this->getSource($invocationTID, $argumentsTID), '( '); |
615 | 615 | |
616 | 616 | //Let's try to fetch all information we need |
617 | - if (\str_contains($name, '->')) { |
|
617 | + if (\str_contains($name, '->')){ |
|
618 | 618 | $operator = '->'; |
619 | - } elseif (\str_contains($name, '::')) { |
|
619 | + } elseif (\str_contains($name, '::')){ |
|
620 | 620 | $operator = '::'; |
621 | 621 | } |
622 | 622 | |
623 | - if (!empty($operator)) { |
|
623 | + if (!empty($operator)){ |
|
624 | 624 | [$class, $name] = \explode($operator, $name); |
625 | 625 | |
626 | 626 | //We now have to clarify class name |
627 | - if (\in_array($class, ['self', 'static', '$this'])) { |
|
627 | + if (\in_array($class, ['self', 'static', '$this'])){ |
|
628 | 628 | $class = $this->activeDeclaration($invocationTID); |
629 | 629 | } |
630 | 630 | } |
@@ -637,9 +637,9 @@ discard block |
||
637 | 637 | */ |
638 | 638 | private function activeDeclaration(int $tokenID): string |
639 | 639 | { |
640 | - foreach ($this->declarations as $declarations) { |
|
641 | - foreach ($declarations as $name => $position) { |
|
642 | - if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { |
|
640 | + foreach ($this->declarations as $declarations){ |
|
641 | + foreach ($declarations as $name => $position){ |
|
642 | + if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]){ |
|
643 | 643 | return $name; |
644 | 644 | } |
645 | 645 | } |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | */ |
655 | 655 | private function activeNamespace(int $tokenID): string |
656 | 656 | { |
657 | - foreach ($this->namespaces as $namespace => $position) { |
|
658 | - if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { |
|
657 | + foreach ($this->namespaces as $namespace => $position){ |
|
658 | + if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]){ |
|
659 | 659 | return $namespace; |
660 | 660 | } |
661 | 661 | } |
@@ -676,18 +676,18 @@ discard block |
||
676 | 676 | private function endingToken(int $tokenID): int |
677 | 677 | { |
678 | 678 | $level = null; |
679 | - for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) { |
|
679 | + for ($localID = $tokenID; $localID < $this->countTokens; ++$localID){ |
|
680 | 680 | $token = $this->tokens[$localID]; |
681 | - if ($token[self::TOKEN_CODE] === '{') { |
|
681 | + if ($token[self::TOKEN_CODE] === '{'){ |
|
682 | 682 | ++$level; |
683 | 683 | continue; |
684 | 684 | } |
685 | 685 | |
686 | - if ($token[self::TOKEN_CODE] === '}') { |
|
686 | + if ($token[self::TOKEN_CODE] === '}'){ |
|
687 | 687 | --$level; |
688 | 688 | } |
689 | 689 | |
690 | - if ($level === 0) { |
|
690 | + if ($level === 0){ |
|
691 | 691 | break; |
692 | 692 | } |
693 | 693 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | private function lineNumber(int $tokenID): int |
702 | 702 | { |
703 | - while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) { |
|
703 | + while (empty($this->tokens[$tokenID][self::TOKEN_LINE])){ |
|
704 | 704 | --$tokenID; |
705 | 705 | } |
706 | 706 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | private function getSource(int $startID, int $endID): string |
714 | 714 | { |
715 | 715 | $result = ''; |
716 | - for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) { |
|
716 | + for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID){ |
|
717 | 717 | //Collecting function usage src |
718 | 718 | $result .= $this->tokens[$tokenID][self::TOKEN_CODE]; |
719 | 719 | } |
@@ -142,7 +142,8 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function getClasses(): array |
144 | 144 | { |
145 | - if (!isset($this->declarations['T_CLASS'])) { |
|
145 | + if (!isset($this->declarations['T_CLASS'])) |
|
146 | + { |
|
146 | 147 | return []; |
147 | 148 | } |
148 | 149 | |
@@ -154,7 +155,8 @@ discard block |
||
154 | 155 | */ |
155 | 156 | public function getEnums(): array |
156 | 157 | { |
157 | - if (!isset($this->declarations['T_ENUM'])) { |
|
158 | + if (!isset($this->declarations['T_ENUM'])) |
|
159 | + { |
|
158 | 160 | return []; |
159 | 161 | } |
160 | 162 | |
@@ -166,7 +168,8 @@ discard block |
||
166 | 168 | */ |
167 | 169 | public function getTraits(): array |
168 | 170 | { |
169 | - if (!isset($this->declarations['T_TRAIT'])) { |
|
171 | + if (!isset($this->declarations['T_TRAIT'])) |
|
172 | + { |
|
170 | 173 | return []; |
171 | 174 | } |
172 | 175 | |
@@ -178,7 +181,8 @@ discard block |
||
178 | 181 | */ |
179 | 182 | public function getInterfaces(): array |
180 | 183 | { |
181 | - if (!isset($this->declarations['T_INTERFACE'])) { |
|
184 | + if (!isset($this->declarations['T_INTERFACE'])) |
|
185 | + { |
|
182 | 186 | return []; |
183 | 187 | } |
184 | 188 | |
@@ -209,7 +213,8 @@ discard block |
||
209 | 213 | */ |
210 | 214 | public function getInvocations(): array |
211 | 215 | { |
212 | - if (empty($this->invocations)) { |
|
216 | + if (empty($this->invocations)) |
|
217 | + { |
|
213 | 218 | $this->locateInvocations($this->getTokens()); |
214 | 219 | } |
215 | 220 | |
@@ -237,12 +242,15 @@ discard block |
||
237 | 242 | */ |
238 | 243 | protected function locateDeclarations() |
239 | 244 | { |
240 | - foreach ($this->getTokens() as $tokenID => $token) { |
|
241 | - if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) { |
|
245 | + foreach ($this->getTokens() as $tokenID => $token) |
|
246 | + { |
|
247 | + if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) |
|
248 | + { |
|
242 | 249 | continue; |
243 | 250 | } |
244 | 251 | |
245 | - switch ($token[self::TOKEN_TYPE]) { |
|
252 | + switch ($token[self::TOKEN_TYPE]) |
|
253 | + { |
|
246 | 254 | case T_NAMESPACE: |
247 | 255 | $this->registerNamespace($tokenID); |
248 | 256 | break; |
@@ -259,17 +267,20 @@ discard block |
||
259 | 267 | case T_TRAIT: |
260 | 268 | case T_INTERFACE: |
261 | 269 | case T_ENUM: |
262 | - if ($this->isClassNameConst($tokenID)) { |
|
270 | + if ($this->isClassNameConst($tokenID)) |
|
271 | + { |
|
263 | 272 | // PHP5.5 ClassName::class constant |
264 | 273 | continue 2; |
265 | 274 | } |
266 | 275 | |
267 | - if ($this->isAnonymousClass($tokenID)) { |
|
276 | + if ($this->isAnonymousClass($tokenID)) |
|
277 | + { |
|
268 | 278 | // PHP7.0 Anonymous classes new class ('foo', 'bar') |
269 | 279 | continue 2; |
270 | 280 | } |
271 | 281 | |
272 | - if (!$this->isCorrectDeclaration($tokenID)) { |
|
282 | + if (!$this->isCorrectDeclaration($tokenID)) |
|
283 | + { |
|
273 | 284 | // PHP8.0 Named parameters ->foo(class: 'bar') |
274 | 285 | continue 2; |
275 | 286 | } |
@@ -286,7 +297,8 @@ discard block |
||
286 | 297 | } |
287 | 298 | |
288 | 299 | //Dropping empty namespace |
289 | - if (isset($this->namespaces[''])) { |
|
300 | + if (isset($this->namespaces[''])) |
|
301 | + { |
|
290 | 302 | $this->namespaces['\\'] = $this->namespaces['']; |
291 | 303 | unset($this->namespaces['']); |
292 | 304 | } |
@@ -300,9 +312,11 @@ discard block |
||
300 | 312 | $namespace = ''; |
301 | 313 | $localID = $tokenID + 1; |
302 | 314 | |
303 | - do { |
|
315 | + do |
|
316 | + { |
|
304 | 317 | $token = $this->tokens[$localID++]; |
305 | - if ($token[self::TOKEN_CODE] === '{') { |
|
318 | + if ($token[self::TOKEN_CODE] === '{') |
|
319 | + { |
|
306 | 320 | break; |
307 | 321 | } |
308 | 322 | |
@@ -317,13 +331,17 @@ discard block |
||
317 | 331 | $namespace = \trim($namespace); |
318 | 332 | |
319 | 333 | $uses = []; |
320 | - if (isset($this->namespaces[$namespace])) { |
|
334 | + if (isset($this->namespaces[$namespace])) |
|
335 | + { |
|
321 | 336 | $uses = $this->namespaces[$namespace]; |
322 | 337 | } |
323 | 338 | |
324 | - if ($this->tokens[$localID][self::TOKEN_CODE] === ';') { |
|
339 | + if ($this->tokens[$localID][self::TOKEN_CODE] === ';') |
|
340 | + { |
|
325 | 341 | $endingID = \count($this->tokens) - 1; |
326 | - } else { |
|
342 | + } |
|
343 | + else |
|
344 | + { |
|
327 | 345 | $endingID = $this->endingToken($tokenID); |
328 | 346 | } |
329 | 347 | |
@@ -343,20 +361,26 @@ discard block |
||
343 | 361 | |
344 | 362 | $class = ''; |
345 | 363 | $localAlias = null; |
346 | - for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) { |
|
347 | - if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) { |
|
364 | + for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) |
|
365 | + { |
|
366 | + if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) |
|
367 | + { |
|
348 | 368 | $localAlias = ''; |
349 | 369 | continue; |
350 | 370 | } |
351 | 371 | |
352 | - if ($localAlias === null) { |
|
372 | + if ($localAlias === null) |
|
373 | + { |
|
353 | 374 | $class .= $this->tokens[$localID][self::TOKEN_CODE]; |
354 | - } else { |
|
375 | + } |
|
376 | + else |
|
377 | + { |
|
355 | 378 | $localAlias .= $this->tokens[$localID][self::TOKEN_CODE]; |
356 | 379 | } |
357 | 380 | } |
358 | 381 | |
359 | - if (empty($localAlias)) { |
|
382 | + if (empty($localAlias)) |
|
383 | + { |
|
360 | 384 | $names = explode('\\', $class); |
361 | 385 | $localAlias = end($names); |
362 | 386 | } |
@@ -369,9 +393,12 @@ discard block |
||
369 | 393 | */ |
370 | 394 | private function registerFunction(int $tokenID): void |
371 | 395 | { |
372 | - foreach ($this->declarations as $declarations) { |
|
373 | - foreach ($declarations as $location) { |
|
374 | - if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) { |
|
396 | + foreach ($this->declarations as $declarations) |
|
397 | + { |
|
398 | + foreach ($declarations as $location) |
|
399 | + { |
|
400 | + if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) |
|
401 | + { |
|
375 | 402 | //We are inside class, function is method |
376 | 403 | return; |
377 | 404 | } |
@@ -379,13 +406,15 @@ discard block |
||
379 | 406 | } |
380 | 407 | |
381 | 408 | $localID = $tokenID + 1; |
382 | - while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) { |
|
409 | + while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) |
|
410 | + { |
|
383 | 411 | //Fetching function name |
384 | 412 | ++$localID; |
385 | 413 | } |
386 | 414 | |
387 | 415 | $name = $this->tokens[$localID][self::TOKEN_CODE]; |
388 | - if (!empty($namespace = $this->activeNamespace($tokenID))) { |
|
416 | + if (!empty($namespace = $this->activeNamespace($tokenID))) |
|
417 | + { |
|
389 | 418 | $name = $namespace . self::NS_SEPARATOR . $name; |
390 | 419 | } |
391 | 420 | |
@@ -402,12 +431,14 @@ discard block |
||
402 | 431 | private function registerDeclaration(int $tokenID, int $tokenType): void |
403 | 432 | { |
404 | 433 | $localID = $tokenID + 1; |
405 | - while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) { |
|
434 | + while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) |
|
435 | + { |
|
406 | 436 | ++$localID; |
407 | 437 | } |
408 | 438 | |
409 | 439 | $name = $this->tokens[$localID][self::TOKEN_CODE]; |
410 | - if (!empty($namespace = $this->activeNamespace($tokenID))) { |
|
440 | + if (!empty($namespace = $this->activeNamespace($tokenID))) |
|
441 | + { |
|
411 | 442 | $name = $namespace . self::NS_SEPARATOR . $name; |
412 | 443 | } |
413 | 444 | |
@@ -473,11 +504,13 @@ discard block |
||
473 | 504 | |
474 | 505 | //Tokens used to re-enable token detection |
475 | 506 | $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR]; |
476 | - foreach ($tokens as $tokenID => $token) { |
|
507 | + foreach ($tokens as $tokenID => $token) |
|
508 | + { |
|
477 | 509 | $tokenType = $token[self::TOKEN_TYPE]; |
478 | 510 | |
479 | 511 | //We are not indexing function declarations or functions called from $objects. |
480 | - if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) { |
|
512 | + if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) |
|
513 | + { |
|
481 | 514 | if ( |
482 | 515 | empty($argumentsTID) |
483 | 516 | && ( |
@@ -489,8 +522,11 @@ discard block |
||
489 | 522 | $ignore = true; |
490 | 523 | continue; |
491 | 524 | } |
492 | - } elseif ($ignore) { |
|
493 | - if (!\in_array($tokenType, $stopTokens)) { |
|
525 | + } |
|
526 | + elseif ($ignore) |
|
527 | + { |
|
528 | + if (!\in_array($tokenType, $stopTokens)) |
|
529 | + { |
|
494 | 530 | //Returning to search |
495 | 531 | $ignore = false; |
496 | 532 | } |
@@ -498,13 +534,16 @@ discard block |
||
498 | 534 | } |
499 | 535 | |
500 | 536 | //We are inside function, and there is "(", indexing arguments. |
501 | - if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) { |
|
502 | - if (empty($argumentsTID)) { |
|
537 | + if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) |
|
538 | + { |
|
539 | + if (empty($argumentsTID)) |
|
540 | + { |
|
503 | 541 | $argumentsTID = $tokenID; |
504 | 542 | } |
505 | 543 | |
506 | 544 | ++$level; |
507 | - if ($level != 1) { |
|
545 | + if ($level != 1) |
|
546 | + { |
|
508 | 547 | //Not arguments beginning, but arguments part |
509 | 548 | $arguments[$tokenID] = $token; |
510 | 549 | } |
@@ -513,16 +552,19 @@ discard block |
||
513 | 552 | } |
514 | 553 | |
515 | 554 | //We are inside function arguments and ")" met. |
516 | - if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) { |
|
555 | + if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) |
|
556 | + { |
|
517 | 557 | --$level; |
518 | - if ($level == -1) { |
|
558 | + if ($level == -1) |
|
559 | + { |
|
519 | 560 | $invocationTID = false; |
520 | 561 | $level = 0; |
521 | 562 | continue; |
522 | 563 | } |
523 | 564 | |
524 | 565 | //Function fully indexed, we can process it now. |
525 | - if ($level == 0) { |
|
566 | + if ($level == 0) |
|
567 | + { |
|
526 | 568 | $this->registerInvocation( |
527 | 569 | $invocationTID, |
528 | 570 | $argumentsTID, |
@@ -534,7 +576,9 @@ discard block |
||
534 | 576 | //Closing search |
535 | 577 | $arguments = []; |
536 | 578 | $argumentsTID = $invocationTID = false; |
537 | - } else { |
|
579 | + } |
|
580 | + else |
|
581 | + { |
|
538 | 582 | //Not arguments beginning, but arguments part |
539 | 583 | $arguments[$tokenID] = $token; |
540 | 584 | } |
@@ -543,13 +587,15 @@ discard block |
||
543 | 587 | } |
544 | 588 | |
545 | 589 | //Still inside arguments. |
546 | - if (!empty($invocationTID) && !empty($level)) { |
|
590 | + if (!empty($invocationTID) && !empty($level)) |
|
591 | + { |
|
547 | 592 | $arguments[$tokenID] = $token; |
548 | 593 | continue; |
549 | 594 | } |
550 | 595 | |
551 | 596 | //Nothing valuable to remember, will be parsed later. |
552 | - if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) { |
|
597 | + if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) |
|
598 | + { |
|
553 | 599 | continue; |
554 | 600 | } |
555 | 601 | |
@@ -588,7 +634,8 @@ discard block |
||
588 | 634 | |
589 | 635 | [$class, $operator, $name] = $this->fetchContext($invocationID, $argumentsID); |
590 | 636 | |
591 | - if (!empty($operator) && empty($class)) { |
|
637 | + if (!empty($operator) && empty($class)) |
|
638 | + { |
|
592 | 639 | //Non detectable |
593 | 640 | return; |
594 | 641 | } |
@@ -614,17 +661,22 @@ discard block |
||
614 | 661 | $name = \trim($this->getSource($invocationTID, $argumentsTID), '( '); |
615 | 662 | |
616 | 663 | //Let's try to fetch all information we need |
617 | - if (\str_contains($name, '->')) { |
|
664 | + if (\str_contains($name, '->')) |
|
665 | + { |
|
618 | 666 | $operator = '->'; |
619 | - } elseif (\str_contains($name, '::')) { |
|
667 | + } |
|
668 | + elseif (\str_contains($name, '::')) |
|
669 | + { |
|
620 | 670 | $operator = '::'; |
621 | 671 | } |
622 | 672 | |
623 | - if (!empty($operator)) { |
|
673 | + if (!empty($operator)) |
|
674 | + { |
|
624 | 675 | [$class, $name] = \explode($operator, $name); |
625 | 676 | |
626 | 677 | //We now have to clarify class name |
627 | - if (\in_array($class, ['self', 'static', '$this'])) { |
|
678 | + if (\in_array($class, ['self', 'static', '$this'])) |
|
679 | + { |
|
628 | 680 | $class = $this->activeDeclaration($invocationTID); |
629 | 681 | } |
630 | 682 | } |
@@ -637,9 +689,12 @@ discard block |
||
637 | 689 | */ |
638 | 690 | private function activeDeclaration(int $tokenID): string |
639 | 691 | { |
640 | - foreach ($this->declarations as $declarations) { |
|
641 | - foreach ($declarations as $name => $position) { |
|
642 | - if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { |
|
692 | + foreach ($this->declarations as $declarations) |
|
693 | + { |
|
694 | + foreach ($declarations as $name => $position) |
|
695 | + { |
|
696 | + if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) |
|
697 | + { |
|
643 | 698 | return $name; |
644 | 699 | } |
645 | 700 | } |
@@ -654,8 +709,10 @@ discard block |
||
654 | 709 | */ |
655 | 710 | private function activeNamespace(int $tokenID): string |
656 | 711 | { |
657 | - foreach ($this->namespaces as $namespace => $position) { |
|
658 | - if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { |
|
712 | + foreach ($this->namespaces as $namespace => $position) |
|
713 | + { |
|
714 | + if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) |
|
715 | + { |
|
659 | 716 | return $namespace; |
660 | 717 | } |
661 | 718 | } |
@@ -676,18 +733,22 @@ discard block |
||
676 | 733 | private function endingToken(int $tokenID): int |
677 | 734 | { |
678 | 735 | $level = null; |
679 | - for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) { |
|
736 | + for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) |
|
737 | + { |
|
680 | 738 | $token = $this->tokens[$localID]; |
681 | - if ($token[self::TOKEN_CODE] === '{') { |
|
739 | + if ($token[self::TOKEN_CODE] === '{') |
|
740 | + { |
|
682 | 741 | ++$level; |
683 | 742 | continue; |
684 | 743 | } |
685 | 744 | |
686 | - if ($token[self::TOKEN_CODE] === '}') { |
|
745 | + if ($token[self::TOKEN_CODE] === '}') |
|
746 | + { |
|
687 | 747 | --$level; |
688 | 748 | } |
689 | 749 | |
690 | - if ($level === 0) { |
|
750 | + if ($level === 0) |
|
751 | + { |
|
691 | 752 | break; |
692 | 753 | } |
693 | 754 | } |
@@ -700,7 +761,8 @@ discard block |
||
700 | 761 | */ |
701 | 762 | private function lineNumber(int $tokenID): int |
702 | 763 | { |
703 | - while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) { |
|
764 | + while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) |
|
765 | + { |
|
704 | 766 | --$tokenID; |
705 | 767 | } |
706 | 768 | |
@@ -713,7 +775,8 @@ discard block |
||
713 | 775 | private function getSource(int $startID, int $endID): string |
714 | 776 | { |
715 | 777 | $result = ''; |
716 | - for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) { |
|
778 | + for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) |
|
779 | + { |
|
717 | 780 | //Collecting function usage src |
718 | 781 | $result .= $this->tokens[$tokenID][self::TOKEN_CODE]; |
719 | 782 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | 'alias' => $alias, |
25 | 25 | '--description' => 'My sample command description', |
26 | 26 | ]; |
27 | - if ($alias === null) { |
|
27 | + if ($alias === null){ |
|
28 | 28 | unset($input['alias']); |
29 | 29 | } |
30 | 30 |
@@ -24,7 +24,8 @@ |
||
24 | 24 | 'alias' => $alias, |
25 | 25 | '--description' => 'My sample command description', |
26 | 26 | ]; |
27 | - if ($alias === null) { |
|
27 | + if ($alias === null) |
|
28 | + { |
|
28 | 29 | unset($input['alias']); |
29 | 30 | } |
30 | 31 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | ?string $namespace = null, |
23 | 23 | private readonly ?string $alias = null, |
24 | 24 | private readonly ?string $description = null, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | parent::__construct($config, $name, $comment, $namespace); |
27 | 27 | } |
28 | 28 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'name' => $this->alias, |
70 | 70 | ]; |
71 | 71 | |
72 | - if ($this->description) { |
|
72 | + if ($this->description){ |
|
73 | 73 | $commandDefinition['description'] = $this->description; |
74 | 74 | } |
75 | 75 |
@@ -69,7 +69,8 @@ |
||
69 | 69 | 'name' => $this->alias, |
70 | 70 | ]; |
71 | 71 | |
72 | - if ($this->description) { |
|
72 | + if ($this->description) |
|
73 | + { |
|
73 | 74 | $commandDefinition['description'] = $this->description; |
74 | 75 | } |
75 | 76 |
@@ -39,9 +39,12 @@ |
||
39 | 39 | $console->addCommand(Command\MiddlewareCommand::class); |
40 | 40 | $console->addCommand(Command\FilterCommand::class); |
41 | 41 | |
42 | - try { |
|
42 | + try |
|
43 | + { |
|
43 | 44 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
44 | - } catch (ReflectionException) { |
|
45 | + } |
|
46 | + catch (ReflectionException) |
|
47 | + { |
|
45 | 48 | $defaultNamespace = ''; |
46 | 49 | } |
47 | 50 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function __construct( |
28 | 28 | private readonly ConfiguratorInterface $config, |
29 | 29 | private readonly KernelInterface $kernel, |
30 | - ) { |
|
30 | + ){ |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function init(ConsoleBootloader $console, DirectoriesInterface $dir): void |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $console->addCommand(Command\MiddlewareCommand::class); |
42 | 42 | $console->addCommand(Command\FilterCommand::class); |
43 | 43 | |
44 | - try { |
|
44 | + try{ |
|
45 | 45 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
46 | - } catch (ReflectionException) { |
|
46 | + }catch (ReflectionException){ |
|
47 | 47 | $defaultNamespace = ''; |
48 | 48 | } |
49 | 49 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Base directory for generated classes, class will be automatically localed into sub directory |
59 | 59 | * using given namespace. |
60 | 60 | */ |
61 | - 'directory' => $dir->get('app') . 'src/', |
|
61 | + 'directory' => $dir->get('app').'src/', |
|
62 | 62 | |
63 | 63 | /* |
64 | 64 | * Default namespace to be applied for every generated class. By default uses Kernel namespace |