Passed
Pull Request — master (#370)
by Valentin
04:51
created
src/Tokenizer/src/Tokenizer.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function createInjection(\ReflectionClass $class, string $context = null)
79 79
     {
80
-        if ($class->isSubclassOf(ClassesInterface::class)) {
80
+        if ($class->isSubclassOf(ClassesInterface::class)){
81 81
             return $this->classLocator();
82
-        } elseif ($class->isSubclassOf(InvocationsInterface::class)) {
82
+        } elseif ($class->isSubclassOf(InvocationsInterface::class)){
83 83
             return $this->invocationLocator();
84 84
         }
85 85
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
         $tokens = token_get_all(file_get_contents($filename));
98 98
 
99 99
         $line = 0;
100
-        foreach ($tokens as &$token) {
101
-            if (isset($token[self::LINE])) {
100
+        foreach ($tokens as &$token){
101
+            if (isset($token[self::LINE])){
102 102
                 $line = $token[self::LINE];
103 103
             }
104 104
 
105
-            if (!is_array($token)) {
105
+            if (!is_array($token)){
106 106
                 $token = [$token, $token, $line];
107 107
             }
108 108
 
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $finder = new Finder();
124 124
 
125
-        if (empty($directories)) {
125
+        if (empty($directories)){
126 126
             $directories = $this->config->getDirectories();
127 127
         }
128 128
 
129
-        if (empty($exclude)) {
129
+        if (empty($exclude)){
130 130
             $exclude = $this->config->getExcludes();
131 131
         }
132 132
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,9 +77,12 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function createInjection(\ReflectionClass $class, string $context = null)
79 79
     {
80
-        if ($class->isSubclassOf(ClassesInterface::class)) {
80
+        if ($class->isSubclassOf(ClassesInterface::class))
81
+        {
81 82
             return $this->classLocator();
82
-        } elseif ($class->isSubclassOf(InvocationsInterface::class)) {
83
+        }
84
+        elseif ($class->isSubclassOf(InvocationsInterface::class))
85
+        {
83 86
             return $this->invocationLocator();
84 87
         }
85 88
 
@@ -97,12 +100,15 @@  discard block
 block discarded – undo
97 100
         $tokens = token_get_all(file_get_contents($filename));
98 101
 
99 102
         $line = 0;
100
-        foreach ($tokens as &$token) {
101
-            if (isset($token[self::LINE])) {
103
+        foreach ($tokens as &$token)
104
+        {
105
+            if (isset($token[self::LINE]))
106
+            {
102 107
                 $line = $token[self::LINE];
103 108
             }
104 109
 
105
-            if (!is_array($token)) {
110
+            if (!is_array($token))
111
+            {
106 112
                 $token = [$token, $token, $line];
107 113
             }
108 114
 
@@ -122,11 +128,13 @@  discard block
 block discarded – undo
122 128
     {
123 129
         $finder = new Finder();
124 130
 
125
-        if (empty($directories)) {
131
+        if (empty($directories))
132
+        {
126 133
             $directories = $this->config->getDirectories();
127 134
         }
128 135
 
129
-        if (empty($exclude)) {
136
+        if (empty($exclude))
137
+        {
130 138
             $exclude = $this->config->getExcludes();
131 139
         }
132 140
 
Please login to merge, or discard this patch.
src/Tokenizer/src/InvocationLocator.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     public function getInvocations(\ReflectionFunctionAbstract $function): array
29 29
     {
30 30
         $result = [];
31
-        foreach ($this->availableInvocations($function->getName()) as $invocation) {
32
-            if ($this->isTargeted($invocation, $function)) {
31
+        foreach ($this->availableInvocations($function->getName()) as $invocation){
32
+            if ($this->isTargeted($invocation, $function)){
33 33
                 $result[] = $invocation;
34 34
             }
35 35
         }
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
     protected function availableInvocations(string $signature = ''): \Generator
47 47
     {
48 48
         $signature = strtolower(trim($signature, '\\'));
49
-        foreach ($this->availableReflections() as $reflection) {
50
-            foreach ($reflection->getInvocations() as $invocation) {
49
+        foreach ($this->availableReflections() as $reflection){
50
+            foreach ($reflection->getInvocations() as $invocation){
51 51
                 if (
52 52
                     !empty($signature)
53 53
                     && strtolower(trim($invocation->getName(), '\\')) != $signature
54
-                ) {
54
+                ){
55 55
                     continue;
56 56
                 }
57 57
 
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
      */
69 69
     protected function isTargeted(ReflectionInvocation $invocation, \ReflectionFunctionAbstract $function): bool
70 70
     {
71
-        if ($function instanceof \ReflectionFunction) {
71
+        if ($function instanceof \ReflectionFunction){
72 72
             return !$invocation->isMethod();
73 73
         }
74 74
 
75
-        try {
75
+        try{
76 76
             $reflection = $this->classReflection($invocation->getClass());
77
-        } catch (LocatorException $e) {
77
+        }catch (LocatorException $e){
78 78
             return false;
79 79
         }
80 80
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
          */
84 84
         $target = $function->getDeclaringClass();
85 85
 
86
-        if ($target->isTrait()) {
86
+        if ($target->isTrait()){
87 87
             //Let's compare traits
88 88
             return in_array($target->getName(), $this->fetchTraits($invocation->getClass()));
89 89
         }
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,8 +28,10 @@  discard block
 block discarded – undo
28 28
     public function getInvocations(\ReflectionFunctionAbstract $function): array
29 29
     {
30 30
         $result = [];
31
-        foreach ($this->availableInvocations($function->getName()) as $invocation) {
32
-            if ($this->isTargeted($invocation, $function)) {
31
+        foreach ($this->availableInvocations($function->getName()) as $invocation)
32
+        {
33
+            if ($this->isTargeted($invocation, $function))
34
+            {
33 35
                 $result[] = $invocation;
34 36
             }
35 37
         }
@@ -46,8 +48,10 @@  discard block
 block discarded – undo
46 48
     protected function availableInvocations(string $signature = ''): \Generator
47 49
     {
48 50
         $signature = strtolower(trim($signature, '\\'));
49
-        foreach ($this->availableReflections() as $reflection) {
50
-            foreach ($reflection->getInvocations() as $invocation) {
51
+        foreach ($this->availableReflections() as $reflection)
52
+        {
53
+            foreach ($reflection->getInvocations() as $invocation)
54
+            {
51 55
                 if (
52 56
                     !empty($signature)
53 57
                     && strtolower(trim($invocation->getName(), '\\')) != $signature
@@ -68,13 +72,17 @@  discard block
 block discarded – undo
68 72
      */
69 73
     protected function isTargeted(ReflectionInvocation $invocation, \ReflectionFunctionAbstract $function): bool
70 74
     {
71
-        if ($function instanceof \ReflectionFunction) {
75
+        if ($function instanceof \ReflectionFunction)
76
+        {
72 77
             return !$invocation->isMethod();
73 78
         }
74 79
 
75
-        try {
80
+        try
81
+        {
76 82
             $reflection = $this->classReflection($invocation->getClass());
77
-        } catch (LocatorException $e) {
83
+        }
84
+        catch (LocatorException $e)
85
+        {
78 86
             return false;
79 87
         }
80 88
 
@@ -83,7 +91,8 @@  discard block
 block discarded – undo
83 91
          */
84 92
         $target = $function->getDeclaringClass();
85 93
 
86
-        if ($target->isTrait()) {
94
+        if ($target->isTrait())
95
+        {
87 96
             //Let's compare traits
88 97
             return in_array($target->getName(), $this->fetchTraits($invocation->getClass()));
89 98
         }
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionFile.php 2 patches
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function getClasses(): array
170 170
     {
171
-        if (!isset($this->declarations['T_CLASS'])) {
171
+        if (!isset($this->declarations['T_CLASS'])){
172 172
             return [];
173 173
         }
174 174
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function getTraits(): array
184 184
     {
185
-        if (!isset($this->declarations['T_TRAIT'])) {
185
+        if (!isset($this->declarations['T_TRAIT'])){
186 186
             return [];
187 187
         }
188 188
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public function getInterfaces(): array
198 198
     {
199
-        if (!isset($this->declarations['T_INTERFACE'])) {
199
+        if (!isset($this->declarations['T_INTERFACE'])){
200 200
             return [];
201 201
         }
202 202
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function getInvocations(): array
233 233
     {
234
-        if (empty($this->invocations)) {
234
+        if (empty($this->invocations)){
235 235
             $this->locateInvocations($this->getTokens());
236 236
         }
237 237
 
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
      */
264 264
     protected function locateDeclarations()
265 265
     {
266
-        foreach ($this->getTokens() as $tokenID => $token) {
267
-            if (!in_array($token[self::TOKEN_TYPE], self::$processTokens)) {
266
+        foreach ($this->getTokens() as $tokenID => $token){
267
+            if (!in_array($token[self::TOKEN_TYPE], self::$processTokens)){
268 268
                 continue;
269 269
             }
270 270
 
271
-            switch ($token[self::TOKEN_TYPE]) {
271
+            switch ($token[self::TOKEN_TYPE]){
272 272
                 case T_NAMESPACE:
273 273
                     $this->registerNamespace($tokenID);
274 274
                     break;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                 case T_CLASS:
285 285
                 case T_TRAIT:
286 286
                 case T_INTERFACE:
287
-                    if ($this->isClassNameConst($tokenID)) {
287
+                    if ($this->isClassNameConst($tokenID)){
288 288
                         //PHP5.5 ClassName::class constant
289 289
                         continue 2;
290 290
                     }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         }
302 302
 
303 303
         //Dropping empty namespace
304
-        if (isset($this->namespaces[''])) {
304
+        if (isset($this->namespaces[''])){
305 305
             $this->namespaces['\\'] = $this->namespaces[''];
306 306
             unset($this->namespaces['']);
307 307
         }
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         $namespace = '';
318 318
         $localID = $tokenID + 1;
319 319
 
320
-        do {
320
+        do{
321 321
             $token = $this->tokens[$localID++];
322
-            if ($token[self::TOKEN_CODE] == '{') {
322
+            if ($token[self::TOKEN_CODE] == '{'){
323 323
                 break;
324 324
             }
325 325
 
326 326
             $namespace .= $token[self::TOKEN_CODE];
327
-        } while (
327
+        }while (
328 328
             isset($this->tokens[$localID])
329 329
             && $this->tokens[$localID][self::TOKEN_CODE] != '{'
330 330
             && $this->tokens[$localID][self::TOKEN_CODE] != ';'
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
         $namespace = trim($namespace);
335 335
 
336 336
         $uses = [];
337
-        if (isset($this->namespaces[$namespace])) {
337
+        if (isset($this->namespaces[$namespace])){
338 338
             $uses = $this->namespaces[$namespace];
339 339
         }
340 340
 
341
-        if ($this->tokens[$localID][self::TOKEN_CODE] == ';') {
341
+        if ($this->tokens[$localID][self::TOKEN_CODE] == ';'){
342 342
             $endingID = count($this->tokens) - 1;
343
-        } else {
343
+        }else{
344 344
             $endingID = $this->endingToken($tokenID);
345 345
         }
346 346
 
@@ -362,20 +362,20 @@  discard block
 block discarded – undo
362 362
 
363 363
         $class = '';
364 364
         $localAlias = null;
365
-        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] != ';'; ++$localID) {
366
-            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) {
365
+        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] != ';'; ++$localID){
366
+            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS){
367 367
                 $localAlias = '';
368 368
                 continue;
369 369
             }
370 370
 
371
-            if ($localAlias === null) {
371
+            if ($localAlias === null){
372 372
                 $class .= $this->tokens[$localID][self::TOKEN_CODE];
373
-            } else {
373
+            }else{
374 374
                 $localAlias .= $this->tokens[$localID][self::TOKEN_CODE];
375 375
             }
376 376
         }
377 377
 
378
-        if (empty($localAlias)) {
378
+        if (empty($localAlias)){
379 379
             $names = explode('\\', $class);
380 380
             $localAlias = end($names);
381 381
         }
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
      */
391 391
     private function registerFunction(int $tokenID)
392 392
     {
393
-        foreach ($this->declarations as $declarations) {
394
-            foreach ($declarations as $location) {
395
-                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) {
393
+        foreach ($this->declarations as $declarations){
394
+            foreach ($declarations as $location){
395
+                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]){
396 396
                     //We are inside class, function is method
397 397
                     return;
398 398
                 }
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         $localID = $tokenID + 1;
403
-        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING) {
403
+        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING){
404 404
             //Fetching function name
405 405
             ++$localID;
406 406
         }
407 407
 
408 408
         $name = $this->tokens[$localID][self::TOKEN_CODE];
409
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
410
-            $name = $namespace . self::NS_SEPARATOR . $name;
409
+        if (!empty($namespace = $this->activeNamespace($tokenID))){
410
+            $name = $namespace.self::NS_SEPARATOR.$name;
411 411
         }
412 412
 
413 413
         $this->functions[$name] = [
@@ -426,13 +426,13 @@  discard block
 block discarded – undo
426 426
     private function registerDeclaration(int $tokenID, int $tokenType)
427 427
     {
428 428
         $localID = $tokenID + 1;
429
-        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING) {
429
+        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING){
430 430
             ++$localID;
431 431
         }
432 432
 
433 433
         $name = $this->tokens[$localID][self::TOKEN_CODE];
434
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
435
-            $name = $namespace . self::NS_SEPARATOR . $name;
434
+        if (!empty($namespace = $this->activeNamespace($tokenID))){
435
+            $name = $namespace.self::NS_SEPARATOR.$name;
436 436
         }
437 437
 
438 438
         $this->declarations[token_name($tokenType)][$name] = [
@@ -480,24 +480,24 @@  discard block
 block discarded – undo
480 480
 
481 481
         //Tokens used to re-enable token detection
482 482
         $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR];
483
-        foreach ($tokens as $tokenID => $token) {
483
+        foreach ($tokens as $tokenID => $token){
484 484
             $tokenType = $token[self::TOKEN_TYPE];
485 485
 
486 486
             //We are not indexing function declarations or functions called from $objects.
487
-            if (in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) {
487
+            if (in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])){
488 488
                 if (
489 489
                     empty($argumentsTID)
490 490
                     && (
491 491
                         empty($invocationTID)
492 492
                         || $this->getSource($invocationTID, $tokenID - 1) != '$this'
493 493
                     )
494
-                ) {
494
+                ){
495 495
                     //Not a call, function declaration, or object method
496 496
                     $ignore = true;
497 497
                     continue;
498 498
                 }
499
-            } elseif ($ignore) {
500
-                if (!in_array($tokenType, $stopTokens)) {
499
+            } elseif ($ignore){
500
+                if (!in_array($tokenType, $stopTokens)){
501 501
                     //Returning to search
502 502
                     $ignore = false;
503 503
                 }
@@ -505,13 +505,13 @@  discard block
 block discarded – undo
505 505
             }
506 506
 
507 507
             //We are inside function, and there is "(", indexing arguments.
508
-            if (!empty($invocationTID) && ($tokenType == '(' || $tokenType == '[')) {
509
-                if (empty($argumentsTID)) {
508
+            if (!empty($invocationTID) && ($tokenType == '(' || $tokenType == '[')){
509
+                if (empty($argumentsTID)){
510 510
                     $argumentsTID = $tokenID;
511 511
                 }
512 512
 
513 513
                 ++$level;
514
-                if ($level != 1) {
514
+                if ($level != 1){
515 515
                     //Not arguments beginning, but arguments part
516 516
                     $arguments[$tokenID] = $token;
517 517
                 }
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
             }
521 521
 
522 522
             //We are inside function arguments and ")" met.
523
-            if (!empty($invocationTID) && ($tokenType == ')' || $tokenType == ']')) {
523
+            if (!empty($invocationTID) && ($tokenType == ')' || $tokenType == ']')){
524 524
                 --$level;
525
-                if ($level == -1) {
525
+                if ($level == -1){
526 526
                     $invocationTID = false;
527 527
                     $level = 0;
528 528
                     continue;
529 529
                 }
530 530
 
531 531
                 //Function fully indexed, we can process it now.
532
-                if ($level == 0) {
532
+                if ($level == 0){
533 533
                     $this->registerInvocation(
534 534
                         $invocationTID,
535 535
                         $argumentsTID,
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
                     //Closing search
542 542
                     $arguments = [];
543 543
                     $argumentsTID = $invocationTID = false;
544
-                } else {
544
+                }else{
545 545
                     //Not arguments beginning, but arguments part
546 546
                     $arguments[$tokenID] = $token;
547 547
                 }
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
             }
551 551
 
552 552
             //Still inside arguments.
553
-            if (!empty($invocationTID) && !empty($level)) {
553
+            if (!empty($invocationTID) && !empty($level)){
554 554
                 $arguments[$tokenID] = $token;
555 555
                 continue;
556 556
             }
557 557
 
558 558
             //Nothing valuable to remember, will be parsed later.
559
-            if (!empty($invocationTID) && in_array($tokenType, $stopTokens)) {
559
+            if (!empty($invocationTID) && in_array($tokenType, $stopTokens)){
560 560
                 continue;
561 561
             }
562 562
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                 || $tokenType == T_STATIC
567 567
                 || $tokenType == T_NS_SEPARATOR
568 568
                 || ($tokenType == T_VARIABLE && $token[self::TOKEN_CODE] == '$this')
569
-            ) {
569
+            ){
570 570
                 $invocationTID = $tokenID;
571 571
                 $level = 0;
572 572
 
@@ -595,13 +595,13 @@  discard block
 block discarded – undo
595 595
         int $endID,
596 596
         array $arguments,
597 597
         int $invocationLevel
598
-    ) {
598
+    ){
599 599
         //Nested invocations
600 600
         $this->locateInvocations($arguments, $invocationLevel + 1);
601 601
 
602 602
         list($class, $operator, $name) = $this->fetchContext($invocationID, $argumentsID);
603 603
 
604
-        if (!empty($operator) && empty($class)) {
604
+        if (!empty($operator) && empty($class)){
605 605
             //Non detectable
606 606
             return;
607 607
         }
@@ -632,17 +632,17 @@  discard block
 block discarded – undo
632 632
         $name = trim($this->getSource($invocationTID, $argumentsTID), '( ');
633 633
 
634 634
         //Let's try to fetch all information we need
635
-        if (strpos($name, '->') !== false) {
635
+        if (strpos($name, '->') !== false){
636 636
             $operator = '->';
637
-        } elseif (strpos($name, '::') !== false) {
637
+        } elseif (strpos($name, '::') !== false){
638 638
             $operator = '::';
639 639
         }
640 640
 
641
-        if (!empty($operator)) {
641
+        if (!empty($operator)){
642 642
             list($class, $name) = explode($operator, $name);
643 643
 
644 644
             //We now have to clarify class name
645
-            if (in_array($class, ['self', 'static', '$this'])) {
645
+            if (in_array($class, ['self', 'static', '$this'])){
646 646
                 $class = $this->activeDeclaration($invocationTID);
647 647
             }
648 648
         }
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
      */
660 660
     private function activeDeclaration(int $tokenID): string
661 661
     {
662
-        foreach ($this->declarations as $declarations) {
663
-            foreach ($declarations as $name => $position) {
664
-                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
662
+        foreach ($this->declarations as $declarations){
663
+            foreach ($declarations as $name => $position){
664
+                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]){
665 665
                     return $name;
666 666
                 }
667 667
             }
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
      */
681 681
     private function activeNamespace(int $tokenID): string
682 682
     {
683
-        foreach ($this->namespaces as $namespace => $position) {
684
-            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
683
+        foreach ($this->namespaces as $namespace => $position){
684
+            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]){
685 685
                 return $namespace;
686 686
             }
687 687
         }
@@ -706,18 +706,18 @@  discard block
 block discarded – undo
706 706
     private function endingToken(int $tokenID): int
707 707
     {
708 708
         $level = null;
709
-        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) {
709
+        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID){
710 710
             $token = $this->tokens[$localID];
711
-            if ($token[self::TOKEN_CODE] == '{') {
711
+            if ($token[self::TOKEN_CODE] == '{'){
712 712
                 ++$level;
713 713
                 continue;
714 714
             }
715 715
 
716
-            if ($token[self::TOKEN_CODE] == '}') {
716
+            if ($token[self::TOKEN_CODE] == '}'){
717 717
                 --$level;
718 718
             }
719 719
 
720
-            if ($level === 0) {
720
+            if ($level === 0){
721 721
                 break;
722 722
             }
723 723
         }
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
      */
735 735
     private function lineNumber(int $tokenID): int
736 736
     {
737
-        while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) {
737
+        while (empty($this->tokens[$tokenID][self::TOKEN_LINE])){
738 738
             --$tokenID;
739 739
         }
740 740
 
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
     private function getSource(int $startID, int $endID): string
753 753
     {
754 754
         $result = '';
755
-        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) {
755
+        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID){
756 756
             //Collecting function usage src
757 757
             $result .= $this->tokens[$tokenID][self::TOKEN_CODE];
758 758
         }
Please login to merge, or discard this patch.
Braces   +115 added lines, -55 removed lines patch added patch discarded remove patch
@@ -168,7 +168,8 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function getClasses(): array
170 170
     {
171
-        if (!isset($this->declarations['T_CLASS'])) {
171
+        if (!isset($this->declarations['T_CLASS']))
172
+        {
172 173
             return [];
173 174
         }
174 175
 
@@ -182,7 +183,8 @@  discard block
 block discarded – undo
182 183
      */
183 184
     public function getTraits(): array
184 185
     {
185
-        if (!isset($this->declarations['T_TRAIT'])) {
186
+        if (!isset($this->declarations['T_TRAIT']))
187
+        {
186 188
             return [];
187 189
         }
188 190
 
@@ -196,7 +198,8 @@  discard block
 block discarded – undo
196 198
      */
197 199
     public function getInterfaces(): array
198 200
     {
199
-        if (!isset($this->declarations['T_INTERFACE'])) {
201
+        if (!isset($this->declarations['T_INTERFACE']))
202
+        {
200 203
             return [];
201 204
         }
202 205
 
@@ -231,7 +234,8 @@  discard block
 block discarded – undo
231 234
      */
232 235
     public function getInvocations(): array
233 236
     {
234
-        if (empty($this->invocations)) {
237
+        if (empty($this->invocations))
238
+        {
235 239
             $this->locateInvocations($this->getTokens());
236 240
         }
237 241
 
@@ -263,12 +267,15 @@  discard block
 block discarded – undo
263 267
      */
264 268
     protected function locateDeclarations()
265 269
     {
266
-        foreach ($this->getTokens() as $tokenID => $token) {
267
-            if (!in_array($token[self::TOKEN_TYPE], self::$processTokens)) {
270
+        foreach ($this->getTokens() as $tokenID => $token)
271
+        {
272
+            if (!in_array($token[self::TOKEN_TYPE], self::$processTokens))
273
+            {
268 274
                 continue;
269 275
             }
270 276
 
271
-            switch ($token[self::TOKEN_TYPE]) {
277
+            switch ($token[self::TOKEN_TYPE])
278
+            {
272 279
                 case T_NAMESPACE:
273 280
                     $this->registerNamespace($tokenID);
274 281
                     break;
@@ -284,7 +291,8 @@  discard block
 block discarded – undo
284 291
                 case T_CLASS:
285 292
                 case T_TRAIT:
286 293
                 case T_INTERFACE:
287
-                    if ($this->isClassNameConst($tokenID)) {
294
+                    if ($this->isClassNameConst($tokenID))
295
+                    {
288 296
                         //PHP5.5 ClassName::class constant
289 297
                         continue 2;
290 298
                     }
@@ -301,7 +309,8 @@  discard block
 block discarded – undo
301 309
         }
302 310
 
303 311
         //Dropping empty namespace
304
-        if (isset($this->namespaces[''])) {
312
+        if (isset($this->namespaces['']))
313
+        {
305 314
             $this->namespaces['\\'] = $this->namespaces[''];
306 315
             unset($this->namespaces['']);
307 316
         }
@@ -317,9 +326,11 @@  discard block
 block discarded – undo
317 326
         $namespace = '';
318 327
         $localID = $tokenID + 1;
319 328
 
320
-        do {
329
+        do
330
+        {
321 331
             $token = $this->tokens[$localID++];
322
-            if ($token[self::TOKEN_CODE] == '{') {
332
+            if ($token[self::TOKEN_CODE] == '{')
333
+            {
323 334
                 break;
324 335
             }
325 336
 
@@ -334,13 +345,17 @@  discard block
 block discarded – undo
334 345
         $namespace = trim($namespace);
335 346
 
336 347
         $uses = [];
337
-        if (isset($this->namespaces[$namespace])) {
348
+        if (isset($this->namespaces[$namespace]))
349
+        {
338 350
             $uses = $this->namespaces[$namespace];
339 351
         }
340 352
 
341
-        if ($this->tokens[$localID][self::TOKEN_CODE] == ';') {
353
+        if ($this->tokens[$localID][self::TOKEN_CODE] == ';')
354
+        {
342 355
             $endingID = count($this->tokens) - 1;
343
-        } else {
356
+        }
357
+        else
358
+        {
344 359
             $endingID = $this->endingToken($tokenID);
345 360
         }
346 361
 
@@ -362,20 +377,26 @@  discard block
 block discarded – undo
362 377
 
363 378
         $class = '';
364 379
         $localAlias = null;
365
-        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] != ';'; ++$localID) {
366
-            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) {
380
+        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] != ';'; ++$localID)
381
+        {
382
+            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS)
383
+            {
367 384
                 $localAlias = '';
368 385
                 continue;
369 386
             }
370 387
 
371
-            if ($localAlias === null) {
388
+            if ($localAlias === null)
389
+            {
372 390
                 $class .= $this->tokens[$localID][self::TOKEN_CODE];
373
-            } else {
391
+            }
392
+            else
393
+            {
374 394
                 $localAlias .= $this->tokens[$localID][self::TOKEN_CODE];
375 395
             }
376 396
         }
377 397
 
378
-        if (empty($localAlias)) {
398
+        if (empty($localAlias))
399
+        {
379 400
             $names = explode('\\', $class);
380 401
             $localAlias = end($names);
381 402
         }
@@ -390,9 +411,12 @@  discard block
 block discarded – undo
390 411
      */
391 412
     private function registerFunction(int $tokenID)
392 413
     {
393
-        foreach ($this->declarations as $declarations) {
394
-            foreach ($declarations as $location) {
395
-                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) {
414
+        foreach ($this->declarations as $declarations)
415
+        {
416
+            foreach ($declarations as $location)
417
+            {
418
+                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN])
419
+                {
396 420
                     //We are inside class, function is method
397 421
                     return;
398 422
                 }
@@ -400,13 +424,15 @@  discard block
 block discarded – undo
400 424
         }
401 425
 
402 426
         $localID = $tokenID + 1;
403
-        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING) {
427
+        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING)
428
+        {
404 429
             //Fetching function name
405 430
             ++$localID;
406 431
         }
407 432
 
408 433
         $name = $this->tokens[$localID][self::TOKEN_CODE];
409
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
434
+        if (!empty($namespace = $this->activeNamespace($tokenID)))
435
+        {
410 436
             $name = $namespace . self::NS_SEPARATOR . $name;
411 437
         }
412 438
 
@@ -426,12 +452,14 @@  discard block
 block discarded – undo
426 452
     private function registerDeclaration(int $tokenID, int $tokenType)
427 453
     {
428 454
         $localID = $tokenID + 1;
429
-        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING) {
455
+        while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING)
456
+        {
430 457
             ++$localID;
431 458
         }
432 459
 
433 460
         $name = $this->tokens[$localID][self::TOKEN_CODE];
434
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
461
+        if (!empty($namespace = $this->activeNamespace($tokenID)))
462
+        {
435 463
             $name = $namespace . self::NS_SEPARATOR . $name;
436 464
         }
437 465
 
@@ -480,11 +508,13 @@  discard block
 block discarded – undo
480 508
 
481 509
         //Tokens used to re-enable token detection
482 510
         $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR];
483
-        foreach ($tokens as $tokenID => $token) {
511
+        foreach ($tokens as $tokenID => $token)
512
+        {
484 513
             $tokenType = $token[self::TOKEN_TYPE];
485 514
 
486 515
             //We are not indexing function declarations or functions called from $objects.
487
-            if (in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) {
516
+            if (in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW]))
517
+            {
488 518
                 if (
489 519
                     empty($argumentsTID)
490 520
                     && (
@@ -496,8 +526,11 @@  discard block
 block discarded – undo
496 526
                     $ignore = true;
497 527
                     continue;
498 528
                 }
499
-            } elseif ($ignore) {
500
-                if (!in_array($tokenType, $stopTokens)) {
529
+            }
530
+            elseif ($ignore)
531
+            {
532
+                if (!in_array($tokenType, $stopTokens))
533
+                {
501 534
                     //Returning to search
502 535
                     $ignore = false;
503 536
                 }
@@ -505,13 +538,16 @@  discard block
 block discarded – undo
505 538
             }
506 539
 
507 540
             //We are inside function, and there is "(", indexing arguments.
508
-            if (!empty($invocationTID) && ($tokenType == '(' || $tokenType == '[')) {
509
-                if (empty($argumentsTID)) {
541
+            if (!empty($invocationTID) && ($tokenType == '(' || $tokenType == '['))
542
+            {
543
+                if (empty($argumentsTID))
544
+                {
510 545
                     $argumentsTID = $tokenID;
511 546
                 }
512 547
 
513 548
                 ++$level;
514
-                if ($level != 1) {
549
+                if ($level != 1)
550
+                {
515 551
                     //Not arguments beginning, but arguments part
516 552
                     $arguments[$tokenID] = $token;
517 553
                 }
@@ -520,16 +556,19 @@  discard block
 block discarded – undo
520 556
             }
521 557
 
522 558
             //We are inside function arguments and ")" met.
523
-            if (!empty($invocationTID) && ($tokenType == ')' || $tokenType == ']')) {
559
+            if (!empty($invocationTID) && ($tokenType == ')' || $tokenType == ']'))
560
+            {
524 561
                 --$level;
525
-                if ($level == -1) {
562
+                if ($level == -1)
563
+                {
526 564
                     $invocationTID = false;
527 565
                     $level = 0;
528 566
                     continue;
529 567
                 }
530 568
 
531 569
                 //Function fully indexed, we can process it now.
532
-                if ($level == 0) {
570
+                if ($level == 0)
571
+                {
533 572
                     $this->registerInvocation(
534 573
                         $invocationTID,
535 574
                         $argumentsTID,
@@ -541,7 +580,9 @@  discard block
 block discarded – undo
541 580
                     //Closing search
542 581
                     $arguments = [];
543 582
                     $argumentsTID = $invocationTID = false;
544
-                } else {
583
+                }
584
+                else
585
+                {
545 586
                     //Not arguments beginning, but arguments part
546 587
                     $arguments[$tokenID] = $token;
547 588
                 }
@@ -550,13 +591,15 @@  discard block
 block discarded – undo
550 591
             }
551 592
 
552 593
             //Still inside arguments.
553
-            if (!empty($invocationTID) && !empty($level)) {
594
+            if (!empty($invocationTID) && !empty($level))
595
+            {
554 596
                 $arguments[$tokenID] = $token;
555 597
                 continue;
556 598
             }
557 599
 
558 600
             //Nothing valuable to remember, will be parsed later.
559
-            if (!empty($invocationTID) && in_array($tokenType, $stopTokens)) {
601
+            if (!empty($invocationTID) && in_array($tokenType, $stopTokens))
602
+            {
560 603
                 continue;
561 604
             }
562 605
 
@@ -601,7 +644,8 @@  discard block
 block discarded – undo
601 644
 
602 645
         list($class, $operator, $name) = $this->fetchContext($invocationID, $argumentsID);
603 646
 
604
-        if (!empty($operator) && empty($class)) {
647
+        if (!empty($operator) && empty($class))
648
+        {
605 649
             //Non detectable
606 650
             return;
607 651
         }
@@ -632,17 +676,22 @@  discard block
 block discarded – undo
632 676
         $name = trim($this->getSource($invocationTID, $argumentsTID), '( ');
633 677
 
634 678
         //Let's try to fetch all information we need
635
-        if (strpos($name, '->') !== false) {
679
+        if (strpos($name, '->') !== false)
680
+        {
636 681
             $operator = '->';
637
-        } elseif (strpos($name, '::') !== false) {
682
+        }
683
+        elseif (strpos($name, '::') !== false)
684
+        {
638 685
             $operator = '::';
639 686
         }
640 687
 
641
-        if (!empty($operator)) {
688
+        if (!empty($operator))
689
+        {
642 690
             list($class, $name) = explode($operator, $name);
643 691
 
644 692
             //We now have to clarify class name
645
-            if (in_array($class, ['self', 'static', '$this'])) {
693
+            if (in_array($class, ['self', 'static', '$this']))
694
+            {
646 695
                 $class = $this->activeDeclaration($invocationTID);
647 696
             }
648 697
         }
@@ -659,9 +708,12 @@  discard block
 block discarded – undo
659 708
      */
660 709
     private function activeDeclaration(int $tokenID): string
661 710
     {
662
-        foreach ($this->declarations as $declarations) {
663
-            foreach ($declarations as $name => $position) {
664
-                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
711
+        foreach ($this->declarations as $declarations)
712
+        {
713
+            foreach ($declarations as $name => $position)
714
+            {
715
+                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN])
716
+                {
665 717
                     return $name;
666 718
                 }
667 719
             }
@@ -680,8 +732,10 @@  discard block
 block discarded – undo
680 732
      */
681 733
     private function activeNamespace(int $tokenID): string
682 734
     {
683
-        foreach ($this->namespaces as $namespace => $position) {
684
-            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
735
+        foreach ($this->namespaces as $namespace => $position)
736
+        {
737
+            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN])
738
+            {
685 739
                 return $namespace;
686 740
             }
687 741
         }
@@ -706,18 +760,22 @@  discard block
 block discarded – undo
706 760
     private function endingToken(int $tokenID): int
707 761
     {
708 762
         $level = null;
709
-        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) {
763
+        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID)
764
+        {
710 765
             $token = $this->tokens[$localID];
711
-            if ($token[self::TOKEN_CODE] == '{') {
766
+            if ($token[self::TOKEN_CODE] == '{')
767
+            {
712 768
                 ++$level;
713 769
                 continue;
714 770
             }
715 771
 
716
-            if ($token[self::TOKEN_CODE] == '}') {
772
+            if ($token[self::TOKEN_CODE] == '}')
773
+            {
717 774
                 --$level;
718 775
             }
719 776
 
720
-            if ($level === 0) {
777
+            if ($level === 0)
778
+            {
721 779
                 break;
722 780
             }
723 781
         }
@@ -734,7 +792,8 @@  discard block
 block discarded – undo
734 792
      */
735 793
     private function lineNumber(int $tokenID): int
736 794
     {
737
-        while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) {
795
+        while (empty($this->tokens[$tokenID][self::TOKEN_LINE]))
796
+        {
738 797
             --$tokenID;
739 798
         }
740 799
 
@@ -752,7 +811,8 @@  discard block
 block discarded – undo
752 811
     private function getSource(int $startID, int $endID): string
753 812
     {
754 813
         $result = '';
755
-        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) {
814
+        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID)
815
+        {
756 816
             //Collecting function usage src
757 817
             $result .= $this->tokens[$tokenID][self::TOKEN_CODE];
758 818
         }
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionInvocation.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         array $arguments,
70 70
         string $source,
71 71
         int $level
72
-    ) {
72
+    ){
73 73
         $this->filename = $filename;
74 74
         $this->line = $line;
75 75
         $this->class = $class;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function getArgument(int $index): ReflectionArgument
181 181
     {
182
-        if (!isset($this->arguments[$index])) {
182
+        if (!isset($this->arguments[$index])){
183 183
             throw new ReflectionException("No such argument with index '{$index}'");
184 184
         }
185 185
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,8 @@
 block discarded – undo
179 179
      */
180 180
     public function getArgument(int $index): ReflectionArgument
181 181
     {
182
-        if (!isset($this->arguments[$index])) {
182
+        if (!isset($this->arguments[$index]))
183
+        {
183 184
             throw new ReflectionException("No such argument with index '{$index}'");
184 185
         }
185 186
 
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionArgument.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * Argument types.
23 23
      */
24
-    public const CONSTANT   = 'constant';   //Scalar constant and not variable.
25
-    public const VARIABLE   = 'variable';   //PHP variable
24
+    public const CONSTANT   = 'constant'; //Scalar constant and not variable.
25
+    public const VARIABLE   = 'variable'; //PHP variable
26 26
     public const EXPRESSION = 'expression'; //PHP code (expression).
27
-    public const STRING     = 'string';     //Simple scalar string, can be fetched using stringValue().
27
+    public const STRING     = 'string'; //Simple scalar string, can be fetched using stringValue().
28 28
 
29 29
     /** @var string */
30 30
     private $type;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function stringValue(): string
71 71
     {
72
-        if ($this->type != self::STRING) {
72
+        if ($this->type != self::STRING){
73 73
             throw new ReflectionException(
74 74
                 "Unable to represent value as string, value type is '{$this->type}'"
75 75
             );
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
         $level = 0;
92 92
 
93 93
         $result = [];
94
-        foreach ($tokens as $token) {
95
-            if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) {
94
+        foreach ($tokens as $token){
95
+            if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE){
96 96
                 continue;
97 97
             }
98 98
 
99
-            if (empty($definition)) {
99
+            if (empty($definition)){
100 100
                 $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []];
101 101
             }
102 102
 
103 103
             if (
104 104
                 $token[ReflectionFile::TOKEN_TYPE] == '('
105 105
                 || $token[ReflectionFile::TOKEN_TYPE] == '['
106
-            ) {
106
+            ){
107 107
                 ++$level;
108 108
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
109 109
                 continue;
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
             if (
113 113
                 $token[ReflectionFile::TOKEN_TYPE] == ')'
114 114
                 || $token[ReflectionFile::TOKEN_TYPE] == ']'
115
-            ) {
115
+            ){
116 116
                 --$level;
117 117
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
118 118
                 continue;
119 119
             }
120 120
 
121
-            if ($level) {
121
+            if ($level){
122 122
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
123 123
                 continue;
124 124
             }
125 125
 
126
-            if ($token[ReflectionFile::TOKEN_TYPE] == ',') {
126
+            if ($token[ReflectionFile::TOKEN_TYPE] == ','){
127 127
                 $result[] = self::createArgument($definition);
128 128
                 $definition = null;
129 129
                 continue;
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
         }
135 135
 
136 136
         //Last argument
137
-        if (is_array($definition)) {
137
+        if (is_array($definition)){
138 138
             $definition = self::createArgument($definition);
139
-            if (!empty($definition->getType())) {
139
+            if (!empty($definition->getType())){
140 140
                 $result[] = $definition;
141 141
             }
142 142
         }
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
     {
156 156
         $result = new static(self::EXPRESSION, $definition['value']);
157 157
 
158
-        if (count($definition['tokens']) == 1) {
158
+        if (count($definition['tokens']) == 1){
159 159
             //If argument represent by one token we can try to resolve it's type more precisely
160
-            switch ($definition['tokens'][0][0]) {
160
+            switch ($definition['tokens'][0][0]){
161 161
                 case T_VARIABLE:
162 162
                     $result->type = self::VARIABLE;
163 163
                     break;
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,7 +69,8 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function stringValue(): string
71 71
     {
72
-        if ($this->type != self::STRING) {
72
+        if ($this->type != self::STRING)
73
+        {
73 74
             throw new ReflectionException(
74 75
                 "Unable to represent value as string, value type is '{$this->type}'"
75 76
             );
@@ -91,12 +92,15 @@  discard block
 block discarded – undo
91 92
         $level = 0;
92 93
 
93 94
         $result = [];
94
-        foreach ($tokens as $token) {
95
-            if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) {
95
+        foreach ($tokens as $token)
96
+        {
97
+            if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE)
98
+            {
96 99
                 continue;
97 100
             }
98 101
 
99
-            if (empty($definition)) {
102
+            if (empty($definition))
103
+            {
100 104
                 $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []];
101 105
             }
102 106
 
@@ -118,12 +122,14 @@  discard block
 block discarded – undo
118 122
                 continue;
119 123
             }
120 124
 
121
-            if ($level) {
125
+            if ($level)
126
+            {
122 127
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
123 128
                 continue;
124 129
             }
125 130
 
126
-            if ($token[ReflectionFile::TOKEN_TYPE] == ',') {
131
+            if ($token[ReflectionFile::TOKEN_TYPE] == ',')
132
+            {
127 133
                 $result[] = self::createArgument($definition);
128 134
                 $definition = null;
129 135
                 continue;
@@ -134,9 +140,11 @@  discard block
 block discarded – undo
134 140
         }
135 141
 
136 142
         //Last argument
137
-        if (is_array($definition)) {
143
+        if (is_array($definition))
144
+        {
138 145
             $definition = self::createArgument($definition);
139
-            if (!empty($definition->getType())) {
146
+            if (!empty($definition->getType()))
147
+            {
140 148
                 $result[] = $definition;
141 149
             }
142 150
         }
@@ -155,9 +163,11 @@  discard block
 block discarded – undo
155 163
     {
156 164
         $result = new static(self::EXPRESSION, $definition['value']);
157 165
 
158
-        if (count($definition['tokens']) == 1) {
166
+        if (count($definition['tokens']) == 1)
167
+        {
159 168
             //If argument represent by one token we can try to resolve it's type more precisely
160
-            switch ($definition['tokens'][0][0]) {
169
+            switch ($definition['tokens'][0][0])
170
+            {
161 171
                 case T_VARIABLE:
162 172
                     $result->type = self::VARIABLE;
163 173
                     break;
Please login to merge, or discard this patch.
src/Tokenizer/tests/InvocationsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     protected function someFunction()
20 20
     {
21 21
         $result = $this->sampleMethod('hello world');
22
-        print_r(self::sampleMethod($result . 'plus'));
22
+        print_r(self::sampleMethod($result.'plus'));
23 23
     }
24 24
 
25 25
     public function testInstance()
Please login to merge, or discard this patch.
src/Tokenizer/tests/ReflectionFileTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@
 block discarded – undo
22 22
         $this->assertContains(TestTrait::class, $reflection->getTraits());
23 23
         $this->assertContains(TestInterface::class, $reflection->getInterfaces());
24 24
 
25
-        $this->assertSame([__NAMESPACE__ . '\hello'], $reflection->getFunctions());
25
+        $this->assertSame([__NAMESPACE__.'\hello'], $reflection->getFunctions());
26 26
 
27 27
         $functionA = null;
28 28
         $functionB = null;
29 29
 
30
-        foreach ($reflection->getInvocations() as $invocation) {
31
-            if ($invocation->getName() == 'test_function_a') {
30
+        foreach ($reflection->getInvocations() as $invocation){
31
+            if ($invocation->getName() == 'test_function_a'){
32 32
                 $functionA = $invocation;
33 33
             }
34 34
 
35
-            if ($invocation->getName() == 'test_function_b') {
35
+            if ($invocation->getName() == 'test_function_b'){
36 36
                 $functionB = $invocation;
37 37
             }
38 38
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,12 +27,15 @@
 block discarded – undo
27 27
         $functionA = null;
28 28
         $functionB = null;
29 29
 
30
-        foreach ($reflection->getInvocations() as $invocation) {
31
-            if ($invocation->getName() == 'test_function_a') {
30
+        foreach ($reflection->getInvocations() as $invocation)
31
+        {
32
+            if ($invocation->getName() == 'test_function_a')
33
+            {
32 34
                 $functionA = $invocation;
33 35
             }
34 36
 
35
-            if ($invocation->getName() == 'test_function_b') {
37
+            if ($invocation->getName() == 'test_function_b')
38
+            {
36 39
                 $functionB = $invocation;
37 40
             }
38 41
         }
Please login to merge, or discard this patch.
src/Translator/src/Catalogue.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function has(string $domain, string $id): bool
59 59
     {
60
-        if (!isset($this->data[$domain])) {
60
+        if (!isset($this->data[$domain])){
61 61
             return false;
62 62
         }
63 63
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function get(string $domain, string $string): string
71 71
     {
72
-        if (!$this->has($domain, $string)) {
72
+        if (!$this->has($domain, $string)){
73 73
             throw new CatalogueException("Undefined string in domain '{$domain}'");
74 74
         }
75 75
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function mergeFrom(MessageCatalogue $catalogue, bool $follow = true): void
101 101
     {
102
-        foreach ($catalogue->all() as $domain => $messages) {
103
-            if (!isset($this->data[$domain])) {
102
+        foreach ($catalogue->all() as $domain => $messages){
103
+            if (!isset($this->data[$domain])){
104 104
                 $this->data[$domain] = [];
105 105
             }
106 106
 
107
-            if ($follow) {
107
+            if ($follow){
108 108
                 //MessageCatalogue string has higher priority that string stored in memory
109 109
                 $this->data[$domain] = array_merge($messages, $this->data[$domain]);
110
-            } else {
110
+            }else{
111 111
                 $this->data[$domain] = array_merge($this->data[$domain], $messages);
112 112
             }
113 113
         }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function has(string $domain, string $id): bool
59 59
     {
60
-        if (!isset($this->data[$domain])) {
60
+        if (!isset($this->data[$domain]))
61
+        {
61 62
             return false;
62 63
         }
63 64
 
@@ -69,7 +70,8 @@  discard block
 block discarded – undo
69 70
      */
70 71
     public function get(string $domain, string $string): string
71 72
     {
72
-        if (!$this->has($domain, $string)) {
73
+        if (!$this->has($domain, $string))
74
+        {
73 75
             throw new CatalogueException("Undefined string in domain '{$domain}'");
74 76
         }
75 77
 
@@ -99,15 +101,20 @@  discard block
 block discarded – undo
99 101
      */
100 102
     public function mergeFrom(MessageCatalogue $catalogue, bool $follow = true): void
101 103
     {
102
-        foreach ($catalogue->all() as $domain => $messages) {
103
-            if (!isset($this->data[$domain])) {
104
+        foreach ($catalogue->all() as $domain => $messages)
105
+        {
106
+            if (!isset($this->data[$domain]))
107
+            {
104 108
                 $this->data[$domain] = [];
105 109
             }
106 110
 
107
-            if ($follow) {
111
+            if ($follow)
112
+            {
108 113
                 //MessageCatalogue string has higher priority that string stored in memory
109 114
                 $this->data[$domain] = array_merge($messages, $this->data[$domain]);
110
-            } else {
115
+            }
116
+            else
117
+            {
111 118
                 $this->data[$domain] = array_merge($this->data[$domain], $messages);
112 119
             }
113 120
         }
Please login to merge, or discard this patch.
src/Translator/src/Matcher.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@
 block discarded – undo
37 37
      */
38 38
     public function matches(string $string, string $pattern): bool
39 39
     {
40
-        if ($string === $pattern) {
40
+        if ($string === $pattern){
41 41
             return true;
42 42
         }
43
-        if (!$this->isPattern($pattern)) {
43
+        if (!$this->isPattern($pattern)){
44 44
             return false;
45 45
         }
46 46
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,10 +37,12 @@
 block discarded – undo
37 37
      */
38 38
     public function matches(string $string, string $pattern): bool
39 39
     {
40
-        if ($string === $pattern) {
40
+        if ($string === $pattern)
41
+        {
41 42
             return true;
42 43
         }
43
-        if (!$this->isPattern($pattern)) {
44
+        if (!$this->isPattern($pattern))
45
+        {
44 46
             return false;
45 47
         }
46 48
 
Please login to merge, or discard this patch.