@@ -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 |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | private function match($token) |
302 | 302 | { |
303 | - if ( ! $this->lexer->isNextToken($token) ) { |
|
303 | + if (!$this->lexer->isNextToken($token)) { |
|
304 | 304 | $this->syntaxError($this->lexer->getLiteral($token)); |
305 | 305 | } |
306 | 306 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | private function matchAny(array $tokens) |
321 | 321 | { |
322 | - if ( ! $this->lexer->isNextTokenAny($tokens)) { |
|
322 | + if (!$this->lexer->isNextTokenAny($tokens)) { |
|
323 | 323 | $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens))); |
324 | 324 | } |
325 | 325 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | : sprintf("'%s' at position %s", $token['value'], $token['position']); |
349 | 349 | |
350 | 350 | if (strlen($this->context)) { |
351 | - $message .= ' in ' . $this->context; |
|
351 | + $message .= ' in '.$this->context; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | $message .= '.'; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | self::$metadataParser->setTarget(Target::TARGET_CLASS); |
416 | 416 | |
417 | - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { |
|
417 | + foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) { |
|
418 | 418 | if ($annotation instanceof Target) { |
419 | 419 | $annotationBuilder = $annotationBuilder->withTarget(AnnotationTarget::fromAnnotation($annotation)); |
420 | 420 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | // if there is no constructor we will inject values into public properties |
434 | - if (! $useConstructor) { |
|
434 | + if (!$useConstructor) { |
|
435 | 435 | // collect all public properties |
436 | 436 | foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $i => $property) { |
437 | 437 | $propertyBuilder = new PropertyMetadataBuilder($property->getName()); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $attribute = new Attribute(); |
452 | 452 | $attribute->required = (false !== strpos($propertyComment, '@Required')); |
453 | 453 | $attribute->name = $property->name; |
454 | - $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) |
|
454 | + $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/', $propertyComment, $matches)) |
|
455 | 455 | ? $matches[1] |
456 | 456 | : 'mixed'; |
457 | 457 | |
@@ -459,18 +459,18 @@ discard block |
||
459 | 459 | |
460 | 460 | // checks if the property has @Enum |
461 | 461 | if (false !== strpos($propertyComment, '@Enum')) { |
462 | - $context = 'property ' . $class->name . "::\$" . $property->name; |
|
462 | + $context = 'property '.$class->name."::\$".$property->name; |
|
463 | 463 | |
464 | 464 | self::$metadataParser->setTarget(Target::TARGET_PROPERTY); |
465 | 465 | |
466 | 466 | foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { |
467 | - if ( ! $annotation instanceof Enum) { |
|
467 | + if (!$annotation instanceof Enum) { |
|
468 | 468 | continue; |
469 | 469 | } |
470 | 470 | |
471 | 471 | $propertyBuilder = $propertyBuilder->withEnum([ |
472 | 472 | 'value' => $annotation->value, |
473 | - 'literal' => ( ! empty($annotation->literal)) |
|
473 | + 'literal' => (!empty($annotation->literal)) |
|
474 | 474 | ? $annotation->literal |
475 | 475 | : $annotation->value, |
476 | 476 | ]); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | |
599 | 599 | if ('\\' !== $name[0]) { |
600 | 600 | $pos = strpos($name, '\\'); |
601 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
601 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
602 | 602 | $found = false; |
603 | 603 | $loweredAlias = strtolower($alias); |
604 | 604 | |
@@ -613,19 +613,19 @@ discard block |
||
613 | 613 | } elseif (isset($this->imports[$loweredAlias])) { |
614 | 614 | $found = true; |
615 | 615 | $name = (false !== $pos) |
616 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
616 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
617 | 617 | : $this->imports[$loweredAlias]; |
618 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
618 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
619 | 619 | && isset($this->imports['__NAMESPACE__']) |
620 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
620 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
621 | 621 | ) { |
622 | 622 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
623 | 623 | $found = true; |
624 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
624 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
625 | 625 | $found = true; |
626 | 626 | } |
627 | 627 | |
628 | - if ( ! $found) { |
|
628 | + if (!$found) { |
|
629 | 629 | if ($this->isIgnoredAnnotation($name)) { |
630 | 630 | return false; |
631 | 631 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
637 | - $name = ltrim($name,'\\'); |
|
637 | + $name = ltrim($name, '\\'); |
|
638 | 638 | |
639 | - if ( ! $this->classExists($name)) { |
|
639 | + if (!$this->classExists($name)) { |
|
640 | 640 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
641 | 641 | } |
642 | 642 | |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | |
647 | 647 | |
648 | 648 | // collects the metadata annotation only if there is not yet |
649 | - if (! isset($this->annotationMetadata[$name]) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
649 | + if (!isset($this->annotationMetadata[$name]) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
650 | 650 | $this->collectAnnotationMetadata($name); |
651 | 651 | } |
652 | 652 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $enum = $property->getEnum(); |
682 | 682 | |
683 | 683 | // checks if the attribute is a valid enumerator |
684 | - if ($enum !== null && isset($values[$propertyName]) && ! in_array($values[$propertyName], $enum['value'])) { |
|
684 | + if ($enum !== null && isset($values[$propertyName]) && !in_array($values[$propertyName], $enum['value'])) { |
|
685 | 685 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum['literal'], $values[$propertyName]); |
686 | 686 | } |
687 | 687 | } |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | // handle a not given attribute or null value |
700 | - if (! isset($values[$valueName])) { |
|
700 | + if (!isset($values[$valueName])) { |
|
701 | 701 | if ($property->isRequired()) { |
702 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type['value']); |
|
702 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type['value']); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | continue; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | |
708 | 708 | if ($type !== null && $type['type'] === 'array') { |
709 | 709 | // handle the case of a single value |
710 | - if ( ! is_array($values[$valueName])) { |
|
710 | + if (!is_array($values[$valueName])) { |
|
711 | 711 | $values[$valueName] = [$values[$valueName]]; |
712 | 712 | } |
713 | 713 | |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | $instance = new $name(); |
734 | 734 | |
735 | 735 | foreach ($values as $property => $value) { |
736 | - if (! isset($this->annotationMetadata[$name]->getProperties()[$property])) { |
|
736 | + if (!isset($this->annotationMetadata[$name]->getProperties()[$property])) { |
|
737 | 737 | if ('value' !== $property) { |
738 | 738 | throw AnnotationException::creationError( |
739 | 739 | sprintf( |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | { |
772 | 772 | $values = []; |
773 | 773 | |
774 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
774 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
775 | 775 | return $values; |
776 | 776 | } |
777 | 777 | |
778 | 778 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
779 | 779 | |
780 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
780 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
781 | 781 | $values = $this->Values(); |
782 | 782 | } |
783 | 783 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $token = $this->lexer->lookahead; |
806 | 806 | $value = $this->Value(); |
807 | 807 | |
808 | - if ( ! is_object($value) && ! is_array($value)) { |
|
808 | + if (!is_object($value) && !is_array($value)) { |
|
809 | 809 | $this->syntaxError('Value', $token); |
810 | 810 | } |
811 | 811 | |
@@ -815,10 +815,10 @@ discard block |
||
815 | 815 | foreach ($values as $k => $value) { |
816 | 816 | if (is_object($value) && $value instanceof \stdClass) { |
817 | 817 | $values[$value->name] = $value->value; |
818 | - } else if ( ! isset($values['value'])){ |
|
818 | + } else if (!isset($values['value'])) { |
|
819 | 819 | $values['value'] = $value; |
820 | 820 | } else { |
821 | - if ( ! is_array($values['value'])) { |
|
821 | + if (!is_array($values['value'])) { |
|
822 | 822 | $values['value'] = [$values['value']]; |
823 | 823 | } |
824 | 824 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | { |
843 | 843 | $identifier = $this->Identifier(); |
844 | 844 | |
845 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
845 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
846 | 846 | list($className, $const) = explode('::', $identifier); |
847 | 847 | |
848 | 848 | $pos = strpos($className, '\\'); |
@@ -864,12 +864,12 @@ discard block |
||
864 | 864 | case isset($this->imports[$loweredAlias]): |
865 | 865 | $found = true; |
866 | 866 | $className = (false !== $pos) |
867 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
867 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
868 | 868 | : $this->imports[$loweredAlias]; |
869 | 869 | break; |
870 | 870 | |
871 | 871 | default: |
872 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
872 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
873 | 873 | $ns = $this->imports['__NAMESPACE__']; |
874 | 874 | |
875 | 875 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -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 | |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | private function Identifier() |
907 | 907 | { |
908 | 908 | // check if we have an annotation |
909 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
909 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
910 | 910 | $this->syntaxError('namespace separator or identifier'); |
911 | 911 | } |
912 | 912 | |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
921 | 921 | $this->matchAny(self::$classIdentifiers); |
922 | 922 | |
923 | - $className .= '\\' . $this->lexer->token['value']; |
|
923 | + $className .= '\\'.$this->lexer->token['value']; |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | return $className; |
@@ -968,11 +968,11 @@ discard block |
||
968 | 968 | |
969 | 969 | case DocLexer::T_INTEGER: |
970 | 970 | $this->match(DocLexer::T_INTEGER); |
971 | - return (int)$this->lexer->token['value']; |
|
971 | + return (int) $this->lexer->token['value']; |
|
972 | 972 | |
973 | 973 | case DocLexer::T_FLOAT: |
974 | 974 | $this->match(DocLexer::T_FLOAT); |
975 | - return (float)$this->lexer->token['value']; |
|
975 | + return (float) $this->lexer->token['value']; |
|
976 | 976 | |
977 | 977 | case DocLexer::T_TRUE: |
978 | 978 | $this->match(DocLexer::T_TRUE); |
@@ -1100,9 +1100,9 @@ discard block |
||
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
1103 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
1103 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
1104 | 1104 | |
1105 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
1105 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
1106 | 1106 | return true; |
1107 | 1107 | } |
1108 | 1108 | } |
@@ -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 |
@@ -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 | ) |
@@ -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 | } |