@@ -30,7 +30,7 @@ |
||
30 | 30 | public function add(AnnotationMetadata ...$metadatas) : void |
31 | 31 | { |
32 | 32 | foreach ($metadatas as $metadata) { |
33 | - assert(! isset($this[$metadata->getName()]), sprintf('Metadata with name %s already exists.', $metadata->getName())); |
|
33 | + assert(!isset($this[$metadata->getName()]), sprintf('Metadata with name %s already exists.', $metadata->getName())); |
|
34 | 34 | |
35 | 35 | $this->metadata[$metadata->getName()] = $metadata; |
36 | 36 | } |
@@ -106,7 +106,7 @@ |
||
106 | 106 | ', ', |
107 | 107 | array_filter( |
108 | 108 | self::LABELS, |
109 | - function (int $target) : bool { |
|
109 | + function(int $target) : bool { |
|
110 | 110 | return ($this->target & $target) === $target; |
111 | 111 | }, |
112 | 112 | ARRAY_FILTER_USE_KEY |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $this->usesConstructor = $hasConstructor; |
46 | 46 | $this->properties = array_combine( |
47 | 47 | array_map( |
48 | - static function (PropertyMetadata $property) : string { |
|
48 | + static function(PropertyMetadata $property) : string { |
|
49 | 49 | return $property->getName(); |
50 | 50 | }, |
51 | 51 | $properties |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $defaultProperties = array_values( |
57 | 57 | array_filter( |
58 | 58 | $properties, |
59 | - static function (PropertyMetadata $property) : bool { |
|
59 | + static function(PropertyMetadata $property) : bool { |
|
60 | 60 | return $property->isDefault(); |
61 | 61 | } |
62 | 62 | ) |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | // Checks if the property has type[] |
523 | - if (false !== $pos = strrpos($type, '[')) { |
|
523 | + if (false !== $pos = strrpos($type, '[')) { |
|
524 | 524 | $arrayType = substr($type, 0, $pos); |
525 | 525 | |
526 | 526 | return $metadata->withType([ |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | if (($this->annotationMetadata[$name]->getTarget()->unwrap() & $target) === 0 && $target) { |
670 | 670 | throw AnnotationException::semanticalError( |
671 | 671 | sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.', |
672 | - $originalName, $this->context, $this->annotationMetadata[$name]->getTarget()->describe()) |
|
672 | + $originalName, $this->context, $this->annotationMetadata[$name]->getTarget()->describe()) |
|
673 | 673 | ); |
674 | 674 | } |
675 | 675 | |
@@ -854,9 +854,9 @@ discard block |
||
854 | 854 | case !empty ($this->namespaces): |
855 | 855 | foreach ($this->namespaces as $ns) { |
856 | 856 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
857 | - $className = $ns.'\\'.$className; |
|
858 | - $found = true; |
|
859 | - break; |
|
857 | + $className = $ns.'\\'.$className; |
|
858 | + $found = true; |
|
859 | + break; |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | break; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | } |
882 | 882 | |
883 | 883 | if ($found) { |
884 | - $identifier = $className . '::' . $const; |
|
884 | + $identifier = $className . '::' . $const; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | private function match($token) |
319 | 319 | { |
320 | - if ( ! $this->lexer->isNextToken($token) ) { |
|
320 | + if (!$this->lexer->isNextToken($token)) { |
|
321 | 321 | $this->syntaxError($this->lexer->getLiteral($token)); |
322 | 322 | } |
323 | 323 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | */ |
337 | 337 | private function matchAny(array $tokens) |
338 | 338 | { |
339 | - if ( ! $this->lexer->isNextTokenAny($tokens)) { |
|
339 | + if (!$this->lexer->isNextTokenAny($tokens)) { |
|
340 | 340 | $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens))); |
341 | 341 | } |
342 | 342 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | : sprintf("'%s' at position %s", $token['value'], $token['position']); |
366 | 366 | |
367 | 367 | if (strlen($this->context)) { |
368 | - $message .= ' in ' . $this->context; |
|
368 | + $message .= ' in '.$this->context; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $message .= '.'; |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes' |
418 | 418 | ]); |
419 | 419 | |
420 | - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Enum.php'); |
|
421 | - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php'); |
|
422 | - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php'); |
|
423 | - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attributes.php'); |
|
420 | + AnnotationRegistry::registerFile(__DIR__.'/Annotation/Enum.php'); |
|
421 | + AnnotationRegistry::registerFile(__DIR__.'/Annotation/Target.php'); |
|
422 | + AnnotationRegistry::registerFile(__DIR__.'/Annotation/Attribute.php'); |
|
423 | + AnnotationRegistry::registerFile(__DIR__.'/Annotation/Attributes.php'); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $class = new \ReflectionClass($name); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | self::$metadataParser->setTarget(Target::TARGET_CLASS); |
444 | 444 | |
445 | - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { |
|
445 | + foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) { |
|
446 | 446 | if ($annotation instanceof Target) { |
447 | 447 | $annotationBuilder = $annotationBuilder->withTarget(AnnotationTarget::fromAnnotation($annotation)); |
448 | 448 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | } |
460 | 460 | |
461 | 461 | // if there is no constructor we will inject values into public properties |
462 | - if (! $useConstructor) { |
|
462 | + if (!$useConstructor) { |
|
463 | 463 | // collect all public properties |
464 | 464 | foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $i => $property) { |
465 | 465 | $propertyBuilder = new PropertyMetadataBuilder($property->getName()); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | $attribute = new Attribute(); |
480 | 480 | $attribute->required = (false !== strpos($propertyComment, '@Required')); |
481 | 481 | $attribute->name = $property->name; |
482 | - $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) |
|
482 | + $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/', $propertyComment, $matches)) |
|
483 | 483 | ? $matches[1] |
484 | 484 | : 'mixed'; |
485 | 485 | |
@@ -487,18 +487,18 @@ discard block |
||
487 | 487 | |
488 | 488 | // checks if the property has @Enum |
489 | 489 | if (false !== strpos($propertyComment, '@Enum')) { |
490 | - $context = 'property ' . $class->name . "::\$" . $property->name; |
|
490 | + $context = 'property '.$class->name."::\$".$property->name; |
|
491 | 491 | |
492 | 492 | self::$metadataParser->setTarget(Target::TARGET_PROPERTY); |
493 | 493 | |
494 | 494 | foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { |
495 | - if ( ! $annotation instanceof Enum) { |
|
495 | + if (!$annotation instanceof Enum) { |
|
496 | 496 | continue; |
497 | 497 | } |
498 | 498 | |
499 | 499 | $propertyBuilder = $propertyBuilder->withEnum([ |
500 | 500 | 'value' => $annotation->value, |
501 | - 'literal' => ( ! empty($annotation->literal)) |
|
501 | + 'literal' => (!empty($annotation->literal)) |
|
502 | 502 | ? $annotation->literal |
503 | 503 | : $annotation->value, |
504 | 504 | ]); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | |
627 | 627 | if ('\\' !== $name[0]) { |
628 | 628 | $pos = strpos($name, '\\'); |
629 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
629 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
630 | 630 | $found = false; |
631 | 631 | $loweredAlias = strtolower($alias); |
632 | 632 | |
@@ -641,19 +641,19 @@ discard block |
||
641 | 641 | } elseif (isset($this->imports[$loweredAlias])) { |
642 | 642 | $found = true; |
643 | 643 | $name = (false !== $pos) |
644 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
644 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
645 | 645 | : $this->imports[$loweredAlias]; |
646 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
646 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
647 | 647 | && isset($this->imports['__NAMESPACE__']) |
648 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
648 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
649 | 649 | ) { |
650 | 650 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
651 | 651 | $found = true; |
652 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
652 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
653 | 653 | $found = true; |
654 | 654 | } |
655 | 655 | |
656 | - if ( ! $found) { |
|
656 | + if (!$found) { |
|
657 | 657 | if ($this->isIgnoredAnnotation($name)) { |
658 | 658 | return false; |
659 | 659 | } |
@@ -662,9 +662,9 @@ discard block |
||
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
665 | - $name = ltrim($name,'\\'); |
|
665 | + $name = ltrim($name, '\\'); |
|
666 | 666 | |
667 | - if ( ! $this->classExists($name)) { |
|
667 | + if (!$this->classExists($name)) { |
|
668 | 668 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
669 | 669 | } |
670 | 670 | |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | |
676 | 676 | // collects the metadata annotation only if there is not yet |
677 | - if (! isset($this->annotationMetadata[$name]) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
677 | + if (!isset($this->annotationMetadata[$name]) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
678 | 678 | $this->collectAnnotationMetadata($name); |
679 | 679 | } |
680 | 680 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | $enum = $property->getEnum(); |
710 | 710 | |
711 | 711 | // checks if the attribute is a valid enumerator |
712 | - if ($enum !== null && isset($values[$propertyName]) && ! in_array($values[$propertyName], $enum['value'])) { |
|
712 | + if ($enum !== null && isset($values[$propertyName]) && !in_array($values[$propertyName], $enum['value'])) { |
|
713 | 713 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum['literal'], $values[$propertyName]); |
714 | 714 | } |
715 | 715 | } |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | // handle a not given attribute or null value |
728 | - if (! isset($values[$valueName])) { |
|
728 | + if (!isset($values[$valueName])) { |
|
729 | 729 | if ($property->isRequired()) { |
730 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type['value']); |
|
730 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type['value']); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | continue; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | |
736 | 736 | if ($type !== null && $type['type'] === 'array') { |
737 | 737 | // handle the case of a single value |
738 | - if ( ! is_array($values[$valueName])) { |
|
738 | + if (!is_array($values[$valueName])) { |
|
739 | 739 | $values[$valueName] = [$values[$valueName]]; |
740 | 740 | } |
741 | 741 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $instance = new $name(); |
762 | 762 | |
763 | 763 | foreach ($values as $property => $value) { |
764 | - if (! isset($this->annotationMetadata[$name]->getProperties()[$property])) { |
|
764 | + if (!isset($this->annotationMetadata[$name]->getProperties()[$property])) { |
|
765 | 765 | if ('value' !== $property) { |
766 | 766 | throw AnnotationException::creationError( |
767 | 767 | sprintf( |
@@ -799,13 +799,13 @@ discard block |
||
799 | 799 | { |
800 | 800 | $values = []; |
801 | 801 | |
802 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
802 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
803 | 803 | return $values; |
804 | 804 | } |
805 | 805 | |
806 | 806 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
807 | 807 | |
808 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
808 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
809 | 809 | $values = $this->Values(); |
810 | 810 | } |
811 | 811 | |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | $token = $this->lexer->lookahead; |
834 | 834 | $value = $this->Value(); |
835 | 835 | |
836 | - if ( ! is_object($value) && ! is_array($value)) { |
|
836 | + if (!is_object($value) && !is_array($value)) { |
|
837 | 837 | $this->syntaxError('Value', $token); |
838 | 838 | } |
839 | 839 | |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | foreach ($values as $k => $value) { |
844 | 844 | if (is_object($value) && $value instanceof \stdClass) { |
845 | 845 | $values[$value->name] = $value->value; |
846 | - } else if ( ! isset($values['value'])){ |
|
846 | + } else if (!isset($values['value'])) { |
|
847 | 847 | $values['value'] = $value; |
848 | 848 | } else { |
849 | - if ( ! is_array($values['value'])) { |
|
849 | + if (!is_array($values['value'])) { |
|
850 | 850 | $values['value'] = [$values['value']]; |
851 | 851 | } |
852 | 852 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | { |
871 | 871 | $identifier = $this->Identifier(); |
872 | 872 | |
873 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
873 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
874 | 874 | list($className, $const) = explode('::', $identifier); |
875 | 875 | |
876 | 876 | $pos = strpos($className, '\\'); |
@@ -892,12 +892,12 @@ discard block |
||
892 | 892 | case isset($this->imports[$loweredAlias]): |
893 | 893 | $found = true; |
894 | 894 | $className = (false !== $pos) |
895 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
895 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
896 | 896 | : $this->imports[$loweredAlias]; |
897 | 897 | break; |
898 | 898 | |
899 | 899 | default: |
900 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
900 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
901 | 901 | $ns = $this->imports['__NAMESPACE__']; |
902 | 902 | |
903 | 903 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | } |
910 | 910 | |
911 | 911 | if ($found) { |
912 | - $identifier = $className . '::' . $const; |
|
912 | + $identifier = $className.'::'.$const; |
|
913 | 913 | } |
914 | 914 | } |
915 | 915 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | private function Identifier() |
935 | 935 | { |
936 | 936 | // check if we have an annotation |
937 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
937 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
938 | 938 | $this->syntaxError('namespace separator or identifier'); |
939 | 939 | } |
940 | 940 | |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
949 | 949 | $this->matchAny(self::$classIdentifiers); |
950 | 950 | |
951 | - $className .= '\\' . $this->lexer->token['value']; |
|
951 | + $className .= '\\'.$this->lexer->token['value']; |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | return $className; |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | |
997 | 997 | case DocLexer::T_INTEGER: |
998 | 998 | $this->match(DocLexer::T_INTEGER); |
999 | - return (int)$this->lexer->token['value']; |
|
999 | + return (int) $this->lexer->token['value']; |
|
1000 | 1000 | |
1001 | 1001 | case DocLexer::T_FLOAT: |
1002 | 1002 | $this->match(DocLexer::T_FLOAT); |
1003 | - return (float)$this->lexer->token['value']; |
|
1003 | + return (float) $this->lexer->token['value']; |
|
1004 | 1004 | |
1005 | 1005 | case DocLexer::T_TRUE: |
1006 | 1006 | $this->match(DocLexer::T_TRUE); |
@@ -1128,9 +1128,9 @@ discard block |
||
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
1131 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
1131 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
1132 | 1132 | |
1133 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
1133 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
1134 | 1134 | return true; |
1135 | 1135 | } |
1136 | 1136 | } |