@@ -102,7 +102,7 @@ |
||
102 | 102 | ', ', |
103 | 103 | array_filter( |
104 | 104 | self::LABELS, |
105 | - function (int $target) : bool { |
|
105 | + function(int $target) : bool { |
|
106 | 106 | return ($this->target & $target) === $target; |
107 | 107 | }, |
108 | 108 | ARRAY_FILTER_USE_KEY |
@@ -48,7 +48,7 @@ |
||
48 | 48 | */ |
49 | 49 | public function get(string $name) : AnnotationMetadata |
50 | 50 | { |
51 | - if (! isset($this->metadata[$name])) { |
|
51 | + if (!isset($this->metadata[$name])) { |
|
52 | 52 | throw MetadataDoesNotExist::new($name); |
53 | 53 | } |
54 | 54 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | [ |
60 | 60 | 'type' => 'array', |
61 | 61 | 'array_type' =>Attribute::class, |
62 | - 'value' =>'array<' . Attribute::class . '>', |
|
62 | + 'value' =>'array<'.Attribute::class.'>', |
|
63 | 63 | ], |
64 | 64 | true, |
65 | 65 | true |
@@ -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 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $defaultProperties = array_filter( |
57 | 57 | $properties, |
58 | - static function (PropertyMetadata $property) : bool { |
|
58 | + static function(PropertyMetadata $property) : bool { |
|
59 | 59 | return $property->isDefault(); |
60 | 60 | } |
61 | 61 | ); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | } |
524 | 524 | |
525 | 525 | // Checks if the property has type[] |
526 | - if (false !== $pos = strrpos($type, '[')) { |
|
526 | + if (false !== $pos = strrpos($type, '[')) { |
|
527 | 527 | $arrayType = substr($type, 0, $pos); |
528 | 528 | |
529 | 529 | $metadata->withType([ |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | if (($metadata->getTarget()->unwrap() & $target) === 0 && $target) { |
676 | 676 | throw AnnotationException::semanticalError( |
677 | 677 | sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.', |
678 | - $originalName, $this->context, $metadata->getTarget()->describe()) |
|
678 | + $originalName, $this->context, $metadata->getTarget()->describe()) |
|
679 | 679 | ); |
680 | 680 | } |
681 | 681 | |
@@ -860,9 +860,9 @@ discard block |
||
860 | 860 | case !empty ($this->namespaces): |
861 | 861 | foreach ($this->namespaces as $ns) { |
862 | 862 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
863 | - $className = $ns.'\\'.$className; |
|
864 | - $found = true; |
|
865 | - break; |
|
863 | + $className = $ns.'\\'.$className; |
|
864 | + $found = true; |
|
865 | + break; |
|
866 | 866 | } |
867 | 867 | } |
868 | 868 | break; |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | if ($found) { |
890 | - $identifier = $className . '::' . $const; |
|
890 | + $identifier = $className . '::' . $const; |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | private function match($token) |
303 | 303 | { |
304 | - if ( ! $this->lexer->isNextToken($token) ) { |
|
304 | + if (!$this->lexer->isNextToken($token)) { |
|
305 | 305 | $this->syntaxError($this->lexer->getLiteral($token)); |
306 | 306 | } |
307 | 307 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | private function matchAny(array $tokens) |
322 | 322 | { |
323 | - if ( ! $this->lexer->isNextTokenAny($tokens)) { |
|
323 | + if (!$this->lexer->isNextTokenAny($tokens)) { |
|
324 | 324 | $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens))); |
325 | 325 | } |
326 | 326 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | : sprintf("'%s' at position %s", $token['value'], $token['position']); |
350 | 350 | |
351 | 351 | if (strlen($this->context)) { |
352 | - $message .= ' in ' . $this->context; |
|
352 | + $message .= ' in '.$this->context; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | $message .= '.'; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | self::$metadataParser->setTarget(Target::TARGET_CLASS); |
417 | 417 | |
418 | - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { |
|
418 | + foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) { |
|
419 | 419 | if ($annotation instanceof Target) { |
420 | 420 | $annotationBuilder->withTarget(AnnotationTarget::fromAnnotation($annotation)); |
421 | 421 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | // if there is no constructor we will inject values into public properties |
436 | - if (! $useConstructor) { |
|
436 | + if (!$useConstructor) { |
|
437 | 437 | // collect all public properties |
438 | 438 | foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $i => $property) { |
439 | 439 | $propertyBuilder = new PropertyMetadataBuilder($property->getName()); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $attribute = new Attribute(); |
454 | 454 | $attribute->required = (false !== strpos($propertyComment, '@Required')); |
455 | 455 | $attribute->name = $property->name; |
456 | - $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) |
|
456 | + $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/', $propertyComment, $matches)) |
|
457 | 457 | ? $matches[1] |
458 | 458 | : 'mixed'; |
459 | 459 | |
@@ -461,18 +461,18 @@ discard block |
||
461 | 461 | |
462 | 462 | // checks if the property has @Enum |
463 | 463 | if (false !== strpos($propertyComment, '@Enum')) { |
464 | - $context = 'property ' . $class->name . "::\$" . $property->name; |
|
464 | + $context = 'property '.$class->name."::\$".$property->name; |
|
465 | 465 | |
466 | 466 | self::$metadataParser->setTarget(Target::TARGET_PROPERTY); |
467 | 467 | |
468 | 468 | foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { |
469 | - if ( ! $annotation instanceof Enum) { |
|
469 | + if (!$annotation instanceof Enum) { |
|
470 | 470 | continue; |
471 | 471 | } |
472 | 472 | |
473 | 473 | $propertyBuilder = $propertyBuilder->withEnum([ |
474 | 474 | 'value' => $annotation->value, |
475 | - 'literal' => ( ! empty($annotation->literal)) |
|
475 | + 'literal' => (!empty($annotation->literal)) |
|
476 | 476 | ? $annotation->literal |
477 | 477 | : $annotation->value, |
478 | 478 | ]); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | |
604 | 604 | if ('\\' !== $name[0]) { |
605 | 605 | $pos = strpos($name, '\\'); |
606 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
606 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
607 | 607 | $found = false; |
608 | 608 | $loweredAlias = strtolower($alias); |
609 | 609 | |
@@ -618,19 +618,19 @@ discard block |
||
618 | 618 | } elseif (isset($this->imports[$loweredAlias])) { |
619 | 619 | $found = true; |
620 | 620 | $name = (false !== $pos) |
621 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
621 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
622 | 622 | : $this->imports[$loweredAlias]; |
623 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
623 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
624 | 624 | && isset($this->imports['__NAMESPACE__']) |
625 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
625 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
626 | 626 | ) { |
627 | 627 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
628 | 628 | $found = true; |
629 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
629 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
630 | 630 | $found = true; |
631 | 631 | } |
632 | 632 | |
633 | - if ( ! $found) { |
|
633 | + if (!$found) { |
|
634 | 634 | if ($this->isIgnoredAnnotation($name)) { |
635 | 635 | return false; |
636 | 636 | } |
@@ -639,9 +639,9 @@ discard block |
||
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
642 | - $name = ltrim($name,'\\'); |
|
642 | + $name = ltrim($name, '\\'); |
|
643 | 643 | |
644 | - if ( ! $this->classExists($name)) { |
|
644 | + if (!$this->classExists($name)) { |
|
645 | 645 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
646 | 646 | } |
647 | 647 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | |
652 | 652 | |
653 | 653 | // collects the metadata annotation only if there is not yet |
654 | - if (! $this->metadata->has($name) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
654 | + if (!$this->metadata->has($name) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
655 | 655 | $this->collectAnnotationMetadata($name); |
656 | 656 | } |
657 | 657 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | $enum = $property->getEnum(); |
688 | 688 | |
689 | 689 | // checks if the attribute is a valid enumerator |
690 | - if ($enum !== null && isset($values[$propertyName]) && ! in_array($values[$propertyName], $enum['value'])) { |
|
690 | + if ($enum !== null && isset($values[$propertyName]) && !in_array($values[$propertyName], $enum['value'])) { |
|
691 | 691 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum['literal'], $values[$propertyName]); |
692 | 692 | } |
693 | 693 | } |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | } |
704 | 704 | |
705 | 705 | // handle a not given attribute or null value |
706 | - if (! isset($values[$valueName])) { |
|
706 | + if (!isset($values[$valueName])) { |
|
707 | 707 | if ($property->isRequired()) { |
708 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type['value']); |
|
708 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type['value']); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | continue; |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | |
714 | 714 | if ($type !== null && $type['type'] === 'array') { |
715 | 715 | // handle the case of a single value |
716 | - if ( ! is_array($values[$valueName])) { |
|
716 | + if (!is_array($values[$valueName])) { |
|
717 | 717 | $values[$valueName] = [$values[$valueName]]; |
718 | 718 | } |
719 | 719 | |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | $instance = new $name(); |
740 | 740 | |
741 | 741 | foreach ($values as $property => $value) { |
742 | - if (! isset($metadata->getProperties()[$property])) { |
|
742 | + if (!isset($metadata->getProperties()[$property])) { |
|
743 | 743 | if ('value' !== $property) { |
744 | 744 | throw AnnotationException::creationError( |
745 | 745 | sprintf( |
@@ -777,13 +777,13 @@ discard block |
||
777 | 777 | { |
778 | 778 | $values = []; |
779 | 779 | |
780 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
780 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
781 | 781 | return $values; |
782 | 782 | } |
783 | 783 | |
784 | 784 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
785 | 785 | |
786 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
786 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
787 | 787 | $values = $this->Values(); |
788 | 788 | } |
789 | 789 | |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | $token = $this->lexer->lookahead; |
812 | 812 | $value = $this->Value(); |
813 | 813 | |
814 | - if ( ! is_object($value) && ! is_array($value)) { |
|
814 | + if (!is_object($value) && !is_array($value)) { |
|
815 | 815 | $this->syntaxError('Value', $token); |
816 | 816 | } |
817 | 817 | |
@@ -821,10 +821,10 @@ discard block |
||
821 | 821 | foreach ($values as $k => $value) { |
822 | 822 | if (is_object($value) && $value instanceof \stdClass) { |
823 | 823 | $values[$value->name] = $value->value; |
824 | - } else if ( ! isset($values['value'])){ |
|
824 | + } else if (!isset($values['value'])) { |
|
825 | 825 | $values['value'] = $value; |
826 | 826 | } else { |
827 | - if ( ! is_array($values['value'])) { |
|
827 | + if (!is_array($values['value'])) { |
|
828 | 828 | $values['value'] = [$values['value']]; |
829 | 829 | } |
830 | 830 | |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | { |
849 | 849 | $identifier = $this->Identifier(); |
850 | 850 | |
851 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
851 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
852 | 852 | list($className, $const) = explode('::', $identifier); |
853 | 853 | |
854 | 854 | $pos = strpos($className, '\\'); |
@@ -870,12 +870,12 @@ discard block |
||
870 | 870 | case isset($this->imports[$loweredAlias]): |
871 | 871 | $found = true; |
872 | 872 | $className = (false !== $pos) |
873 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
873 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
874 | 874 | : $this->imports[$loweredAlias]; |
875 | 875 | break; |
876 | 876 | |
877 | 877 | default: |
878 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
878 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
879 | 879 | $ns = $this->imports['__NAMESPACE__']; |
880 | 880 | |
881 | 881 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | if ($found) { |
890 | - $identifier = $className . '::' . $const; |
|
890 | + $identifier = $className.'::'.$const; |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | private function Identifier() |
913 | 913 | { |
914 | 914 | // check if we have an annotation |
915 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
915 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
916 | 916 | $this->syntaxError('namespace separator or identifier'); |
917 | 917 | } |
918 | 918 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
927 | 927 | $this->matchAny(self::$classIdentifiers); |
928 | 928 | |
929 | - $className .= '\\' . $this->lexer->token['value']; |
|
929 | + $className .= '\\'.$this->lexer->token['value']; |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | return $className; |
@@ -974,11 +974,11 @@ discard block |
||
974 | 974 | |
975 | 975 | case DocLexer::T_INTEGER: |
976 | 976 | $this->match(DocLexer::T_INTEGER); |
977 | - return (int)$this->lexer->token['value']; |
|
977 | + return (int) $this->lexer->token['value']; |
|
978 | 978 | |
979 | 979 | case DocLexer::T_FLOAT: |
980 | 980 | $this->match(DocLexer::T_FLOAT); |
981 | - return (float)$this->lexer->token['value']; |
|
981 | + return (float) $this->lexer->token['value']; |
|
982 | 982 | |
983 | 983 | case DocLexer::T_TRUE: |
984 | 984 | $this->match(DocLexer::T_TRUE); |
@@ -1106,9 +1106,9 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
1109 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
1109 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
1110 | 1110 | |
1111 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
1111 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
1112 | 1112 | return true; |
1113 | 1113 | } |
1114 | 1114 | } |