Completed
Pull Request — master (#167)
by Grégoire
12:49
created
lib/Doctrine/Annotations/DocParser.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      */
309 309
     private function match($token)
310 310
     {
311
-        if ( ! $this->lexer->isNextToken($token) ) {
311
+        if (!$this->lexer->isNextToken($token)) {
312 312
             $this->syntaxError($this->lexer->getLiteral($token));
313 313
         }
314 314
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      */
328 328
     private function matchAny(array $tokens)
329 329
     {
330
-        if ( ! $this->lexer->isNextTokenAny($tokens)) {
330
+        if (!$this->lexer->isNextTokenAny($tokens)) {
331 331
             $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens)));
332 332
         }
333 333
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             : sprintf("'%s' at position %s", $token['value'], $token['position']);
357 357
 
358 358
         if (strlen($this->context)) {
359
-            $message .= ' in ' . $this->context;
359
+            $message .= ' in '.$this->context;
360 360
         }
361 361
 
362 362
         $message .= '.';
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 
423 423
         self::$metadataParser->setTarget(Target::TARGET_CLASS);
424 424
 
425
-        foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) {
425
+        foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) {
426 426
             if ($annotation instanceof Target) {
427 427
                 $annotationBuilder->withTarget(AnnotationTarget::fromAnnotation($annotation));
428 428
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             $attribute           = new Attribute();
467 467
             $attribute->required = (false !== strpos($propertyComment, '@Required'));
468 468
             $attribute->name     = $property->name;
469
-            $attribute->type     = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches))
469
+            $attribute->type     = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/', $propertyComment, $matches))
470 470
                 ? $matches[1]
471 471
                 : 'mixed';
472 472
 
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
 
475 475
             // checks if the property has @Enum
476 476
             if (false !== strpos($propertyComment, '@Enum')) {
477
-                $context = 'property ' . $class->name . "::\$" . $property->name;
477
+                $context = 'property '.$class->name."::\$".$property->name;
478 478
 
479 479
                 self::$metadataParser->setTarget(Target::TARGET_PROPERTY);
480 480
 
481 481
                 foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) {
482
-                    if ( ! $annotation instanceof Enum) {
482
+                    if (!$annotation instanceof Enum) {
483 483
                         continue;
484 484
                     }
485 485
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
      */
499 499
     private function createEnumType(array $values) : Type
500 500
     {
501
-        $types = array_map(static function ($value) : Type {
501
+        $types = array_map(static function($value) : Type {
502 502
             if (is_string($value)) {
503 503
                 return new ConstantStringType($value);
504 504
             }
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 
657 657
         if ('\\' !== $name[0]) {
658 658
             $pos = strpos($name, '\\');
659
-            $alias = (false === $pos)? $name : substr($name, 0, $pos);
659
+            $alias = (false === $pos) ? $name : substr($name, 0, $pos);
660 660
             $found = false;
661 661
             $loweredAlias = strtolower($alias);
662 662
 
@@ -671,19 +671,19 @@  discard block
 block discarded – undo
671 671
             } elseif (isset($this->imports[$loweredAlias])) {
672 672
                 $found = true;
673 673
                 $name  = (false !== $pos)
674
-                    ? $this->imports[$loweredAlias] . substr($name, $pos)
674
+                    ? $this->imports[$loweredAlias].substr($name, $pos)
675 675
                     : $this->imports[$loweredAlias];
676
-            } elseif ( ! isset($this->ignoredAnnotationNames[$name])
676
+            } elseif (!isset($this->ignoredAnnotationNames[$name])
677 677
                 && isset($this->imports['__NAMESPACE__'])
678
-                && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name)
678
+                && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name)
679 679
             ) {
680 680
                 $name  = $this->imports['__NAMESPACE__'].'\\'.$name;
681 681
                 $found = true;
682
-            } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) {
682
+            } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) {
683 683
                 $found = true;
684 684
             }
685 685
 
686
-            if ( ! $found) {
686
+            if (!$found) {
687 687
                 if ($this->isIgnoredAnnotation($name)) {
688 688
                     return false;
689 689
                 }
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
             }
693 693
         }
694 694
 
695
-        $name = ltrim($name,'\\');
695
+        $name = ltrim($name, '\\');
696 696
 
697
-        if ( ! $this->classExists($name)) {
697
+        if (!$this->classExists($name)) {
698 698
             throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context));
699 699
         }
700 700
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 
705 705
 
706 706
         // collects the metadata annotation only if there is not yet
707
-        if (! $this->metadata->has($name) && ! array_key_exists($name, $this->nonAnnotationClasses)) {
707
+        if (!$this->metadata->has($name) && !array_key_exists($name, $this->nonAnnotationClasses)) {
708 708
             $this->collectAnnotationMetadata($name);
709 709
         }
710 710
 
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
             $enum         = $property->getEnum();
741 741
 
742 742
             // checks if the attribute is a valid enumerator
743
-            if ($enum !== null && isset($values[$propertyName]) && ! $enum->validate($values[$propertyName])) {
743
+            if ($enum !== null && isset($values[$propertyName]) && !$enum->validate($values[$propertyName])) {
744 744
                 throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum->describe(), $values[$propertyName]);
745 745
             }
746 746
         }
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
             }
757 757
 
758 758
             // handle a not given attribute or null value
759
-            if (! isset($values[$valueName])) {
759
+            if (!isset($values[$valueName])) {
760 760
                 if ($property->isRequired()) {
761
-                    throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type->describe());
761
+                    throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe());
762 762
                 }
763 763
 
764 764
                 continue;
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 
767 767
             if ($type instanceof ArrayType) {
768 768
                 // handle the case of a single value
769
-                if ( ! is_array($values[$valueName])) {
769
+                if (!is_array($values[$valueName])) {
770 770
                     $values[$valueName] = [$values[$valueName]];
771 771
                 }
772 772
 
773 773
                 $valueType = $type->getValueType();
774 774
 
775
-                if (! $type->validate($values[$valueName])) {
776
-                    $firstInvalidValue = (static function (array $values) use ($valueType) {
775
+                if (!$type->validate($values[$valueName])) {
776
+                    $firstInvalidValue = (static function(array $values) use ($valueType) {
777 777
                         foreach ($values as $value) {
778 778
                             if ($valueType->validate($value)) {
779 779
                                 continue;
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
                         }
784 784
                     })($values[$valueName]);
785 785
 
786
-                    throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) ' . $type->getValueType()->describe() . ', or an array of ' . $type->getValueType()->describe() . 's', $firstInvalidValue);
786
+                    throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) '.$type->getValueType()->describe().', or an array of '.$type->getValueType()->describe().'s', $firstInvalidValue);
787 787
                 }
788
-            } elseif (! $type->validate($values[$valueName])) {
788
+            } elseif (!$type->validate($values[$valueName])) {
789 789
                 throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe(), $values[$valueName]);
790 790
             }
791 791
         }
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
     {
850 850
         $values = [];
851 851
 
852
-        if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) {
852
+        if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) {
853 853
             return $values;
854 854
         }
855 855
 
856 856
         $this->match(DocLexer::T_OPEN_PARENTHESIS);
857 857
 
858
-        if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
858
+        if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
859 859
             $values = $this->Values();
860 860
         }
861 861
 
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
             $token = $this->lexer->lookahead;
884 884
             $value = $this->Value();
885 885
 
886
-            if ( ! is_object($value) && ! is_array($value)) {
886
+            if (!is_object($value) && !is_array($value)) {
887 887
                 $this->syntaxError('Value', $token);
888 888
             }
889 889
 
@@ -893,10 +893,10 @@  discard block
 block discarded – undo
893 893
         foreach ($values as $k => $value) {
894 894
             if (is_object($value) && $value instanceof \stdClass) {
895 895
                 $values[$value->name] = $value->value;
896
-            } else if ( ! isset($values['value'])){
896
+            } else if (!isset($values['value'])) {
897 897
                 $values['value'] = $value;
898 898
             } else {
899
-                if ( ! is_array($values['value'])) {
899
+                if (!is_array($values['value'])) {
900 900
                     $values['value'] = [$values['value']];
901 901
                 }
902 902
 
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
     {
921 921
         $identifier = $this->Identifier();
922 922
 
923
-        if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
923
+        if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
924 924
             list($className, $const) = explode('::', $identifier);
925 925
 
926 926
             $pos = strpos($className, '\\');
@@ -942,12 +942,12 @@  discard block
 block discarded – undo
942 942
                 case isset($this->imports[$loweredAlias]):
943 943
                     $found     = true;
944 944
                     $className = (false !== $pos)
945
-                        ? $this->imports[$loweredAlias] . substr($className, $pos)
945
+                        ? $this->imports[$loweredAlias].substr($className, $pos)
946 946
                         : $this->imports[$loweredAlias];
947 947
                     break;
948 948
 
949 949
                 default:
950
-                    if(isset($this->imports['__NAMESPACE__'])) {
950
+                    if (isset($this->imports['__NAMESPACE__'])) {
951 951
                         $ns = $this->imports['__NAMESPACE__'];
952 952
 
953 953
                         if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) {
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
             }
960 960
 
961 961
             if ($found) {
962
-                 $identifier = $className . '::' . $const;
962
+                 $identifier = $className.'::'.$const;
963 963
             }
964 964
         }
965 965
 
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
     private function Identifier()
985 985
     {
986 986
         // check if we have an annotation
987
-        if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) {
987
+        if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) {
988 988
             $this->syntaxError('namespace separator or identifier');
989 989
         }
990 990
 
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
             $this->match(DocLexer::T_NAMESPACE_SEPARATOR);
999 999
             $this->matchAny(self::$classIdentifiers);
1000 1000
 
1001
-            $className .= '\\' . $this->lexer->token['value'];
1001
+            $className .= '\\'.$this->lexer->token['value'];
1002 1002
         }
1003 1003
 
1004 1004
         return $className;
@@ -1046,11 +1046,11 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
             case DocLexer::T_INTEGER:
1048 1048
                 $this->match(DocLexer::T_INTEGER);
1049
-                return (int)$this->lexer->token['value'];
1049
+                return (int) $this->lexer->token['value'];
1050 1050
 
1051 1051
             case DocLexer::T_FLOAT:
1052 1052
                 $this->match(DocLexer::T_FLOAT);
1053
-                return (float)$this->lexer->token['value'];
1053
+                return (float) $this->lexer->token['value'];
1054 1054
 
1055 1055
             case DocLexer::T_TRUE:
1056 1056
                 $this->match(DocLexer::T_TRUE);
@@ -1178,9 +1178,9 @@  discard block
 block discarded – undo
1178 1178
         }
1179 1179
 
1180 1180
         foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) {
1181
-            $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\';
1181
+            $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\';
1182 1182
 
1183
-            if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) {
1183
+            if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) {
1184 1184
                 return true;
1185 1185
             }
1186 1186
         }
Please login to merge, or discard this patch.