@@ -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 |
@@ -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 |
@@ -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 | ); |
@@ -23,7 +23,7 @@ |
||
23 | 23 | implode( |
24 | 24 | '", "', |
25 | 25 | array_map( |
26 | - static function (PropertyMetadata $property) : string { |
|
26 | + static function(PropertyMetadata $property) : string { |
|
27 | 27 | return $property->getName(); |
28 | 28 | }, |
29 | 29 | $properties |
@@ -21,6 +21,6 @@ |
||
21 | 21 | */ |
22 | 22 | public function validate($value) : bool |
23 | 23 | { |
24 | - return ! is_resource($value); |
|
24 | + return !is_resource($value); |
|
25 | 25 | } |
26 | 26 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | return implode( |
41 | 41 | '|', |
42 | 42 | array_map( |
43 | - static function (Type $subType) : string { |
|
43 | + static function(Type $subType) : string { |
|
44 | 44 | if ($subType instanceof CompositeType) { |
45 | 45 | return sprintf('(%s)', $subType->describe()); |
46 | 46 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function validate($value) : bool |
59 | 59 | { |
60 | 60 | foreach ($this->subTypes as $subType) { |
61 | - if (! $subType->validate($value)) { |
|
61 | + if (!$subType->validate($value)) { |
|
62 | 62 | continue; |
63 | 63 | } |
64 | 64 |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | } |
520 | 520 | |
521 | 521 | // Checks if the property has type[] |
522 | - if (false !== $pos = strrpos($type, '[')) { |
|
522 | + if (false !== $pos = strrpos($type, '[')) { |
|
523 | 523 | $arrayType = substr($type, 0, $pos); |
524 | 524 | |
525 | 525 | $metadata->withType(new ArrayType(new MixedType(), $this->createTypeFromName($arrayType))); |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | if (($metadata->getTarget()->unwrap() & $target) === 0 && $target) { |
690 | 690 | throw AnnotationException::semanticalError( |
691 | 691 | sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.', |
692 | - $originalName, $this->context, $metadata->getTarget()->describe()) |
|
692 | + $originalName, $this->context, $metadata->getTarget()->describe()) |
|
693 | 693 | ); |
694 | 694 | } |
695 | 695 | |
@@ -869,9 +869,9 @@ discard block |
||
869 | 869 | case !empty ($this->namespaces): |
870 | 870 | foreach ($this->namespaces as $ns) { |
871 | 871 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
872 | - $className = $ns.'\\'.$className; |
|
873 | - $found = true; |
|
874 | - break; |
|
872 | + $className = $ns.'\\'.$className; |
|
873 | + $found = true; |
|
874 | + break; |
|
875 | 875 | } |
876 | 876 | } |
877 | 877 | break; |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | } |
897 | 897 | |
898 | 898 | if ($found) { |
899 | - $identifier = $className . '::' . $const; |
|
899 | + $identifier = $className . '::' . $const; |
|
900 | 900 | } |
901 | 901 | } |
902 | 902 |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | private function match($token) |
298 | 298 | { |
299 | - if ( ! $this->lexer->isNextToken($token) ) { |
|
299 | + if (!$this->lexer->isNextToken($token)) { |
|
300 | 300 | $this->syntaxError($this->lexer->getLiteral($token)); |
301 | 301 | } |
302 | 302 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | private function matchAny(array $tokens) |
317 | 317 | { |
318 | - if ( ! $this->lexer->isNextTokenAny($tokens)) { |
|
318 | + if (!$this->lexer->isNextTokenAny($tokens)) { |
|
319 | 319 | $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens))); |
320 | 320 | } |
321 | 321 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | : sprintf("'%s' at position %s", $token['value'], $token['position']); |
345 | 345 | |
346 | 346 | if (strlen($this->context)) { |
347 | - $message .= ' in ' . $this->context; |
|
347 | + $message .= ' in '.$this->context; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | $message .= '.'; |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | |
411 | 411 | self::$metadataParser->setTarget(Target::TARGET_CLASS); |
412 | 412 | |
413 | - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { |
|
413 | + foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) { |
|
414 | 414 | if ($annotation instanceof Target) { |
415 | 415 | $annotationBuilder->withTarget(AnnotationTarget::fromAnnotation($annotation)); |
416 | 416 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $attribute = new Attribute(); |
455 | 455 | $attribute->required = (false !== strpos($propertyComment, '@Required')); |
456 | 456 | $attribute->name = $property->name; |
457 | - $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) |
|
457 | + $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/', $propertyComment, $matches)) |
|
458 | 458 | ? $matches[1] |
459 | 459 | : 'mixed'; |
460 | 460 | |
@@ -462,18 +462,18 @@ discard block |
||
462 | 462 | |
463 | 463 | // checks if the property has @Enum |
464 | 464 | if (false !== strpos($propertyComment, '@Enum')) { |
465 | - $context = 'property ' . $class->name . "::\$" . $property->name; |
|
465 | + $context = 'property '.$class->name."::\$".$property->name; |
|
466 | 466 | |
467 | 467 | self::$metadataParser->setTarget(Target::TARGET_PROPERTY); |
468 | 468 | |
469 | 469 | foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { |
470 | - if ( ! $annotation instanceof Enum) { |
|
470 | + if (!$annotation instanceof Enum) { |
|
471 | 471 | continue; |
472 | 472 | } |
473 | 473 | |
474 | 474 | $propertyBuilder = $propertyBuilder->withEnum([ |
475 | 475 | 'value' => $annotation->value, |
476 | - 'literal' => ( ! empty($annotation->literal)) |
|
476 | + 'literal' => (!empty($annotation->literal)) |
|
477 | 477 | ? $annotation->literal |
478 | 478 | : $annotation->value, |
479 | 479 | ]); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | |
618 | 618 | if ('\\' !== $name[0]) { |
619 | 619 | $pos = strpos($name, '\\'); |
620 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
620 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
621 | 621 | $found = false; |
622 | 622 | $loweredAlias = strtolower($alias); |
623 | 623 | |
@@ -632,19 +632,19 @@ discard block |
||
632 | 632 | } elseif (isset($this->imports[$loweredAlias])) { |
633 | 633 | $found = true; |
634 | 634 | $name = (false !== $pos) |
635 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
635 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
636 | 636 | : $this->imports[$loweredAlias]; |
637 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
637 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
638 | 638 | && isset($this->imports['__NAMESPACE__']) |
639 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
639 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
640 | 640 | ) { |
641 | 641 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
642 | 642 | $found = true; |
643 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
643 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
644 | 644 | $found = true; |
645 | 645 | } |
646 | 646 | |
647 | - if ( ! $found) { |
|
647 | + if (!$found) { |
|
648 | 648 | if ($this->isIgnoredAnnotation($name)) { |
649 | 649 | return false; |
650 | 650 | } |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
656 | - $name = ltrim($name,'\\'); |
|
656 | + $name = ltrim($name, '\\'); |
|
657 | 657 | |
658 | - if ( ! $this->classExists($name)) { |
|
658 | + if (!$this->classExists($name)) { |
|
659 | 659 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
660 | 660 | } |
661 | 661 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | |
666 | 666 | |
667 | 667 | // collects the metadata annotation only if there is not yet |
668 | - if (! $this->metadata->has($name) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
668 | + if (!$this->metadata->has($name) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
669 | 669 | $this->collectAnnotationMetadata($name); |
670 | 670 | } |
671 | 671 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | $enum = $property->getEnum(); |
702 | 702 | |
703 | 703 | // checks if the attribute is a valid enumerator |
704 | - if ($enum !== null && isset($values[$propertyName]) && ! in_array($values[$propertyName], $enum['value'])) { |
|
704 | + if ($enum !== null && isset($values[$propertyName]) && !in_array($values[$propertyName], $enum['value'])) { |
|
705 | 705 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum['literal'], $values[$propertyName]); |
706 | 706 | } |
707 | 707 | } |
@@ -717,9 +717,9 @@ discard block |
||
717 | 717 | } |
718 | 718 | |
719 | 719 | // handle a not given attribute or null value |
720 | - if (! isset($values[$valueName])) { |
|
720 | + if (!isset($values[$valueName])) { |
|
721 | 721 | if ($property->isRequired()) { |
722 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type->describe()); |
|
722 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe()); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | continue; |
@@ -727,14 +727,14 @@ discard block |
||
727 | 727 | |
728 | 728 | if ($type instanceof ArrayType) { |
729 | 729 | // handle the case of a single value |
730 | - if ( ! is_array($values[$valueName])) { |
|
730 | + if (!is_array($values[$valueName])) { |
|
731 | 731 | $values[$valueName] = [$values[$valueName]]; |
732 | 732 | } |
733 | 733 | |
734 | - if (! $type->validate($values[$valueName])) { |
|
735 | - throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) ' . $type->getValueType()->describe() . ', or an array of ' . $type->getValueType()->describe() . 's'); |
|
734 | + if (!$type->validate($values[$valueName])) { |
|
735 | + throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) '.$type->getValueType()->describe().', or an array of '.$type->getValueType()->describe().'s'); |
|
736 | 736 | } |
737 | - } elseif (! $type->validate($values[$valueName])) { |
|
737 | + } elseif (!$type->validate($values[$valueName])) { |
|
738 | 738 | throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe()); |
739 | 739 | } |
740 | 740 | } |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $instance = new $name(); |
749 | 749 | |
750 | 750 | foreach ($values as $property => $value) { |
751 | - if (! isset($metadata->getProperties()[$property])) { |
|
751 | + if (!isset($metadata->getProperties()[$property])) { |
|
752 | 752 | if ('value' !== $property) { |
753 | 753 | throw AnnotationException::creationError( |
754 | 754 | sprintf( |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | { |
787 | 787 | $values = []; |
788 | 788 | |
789 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
789 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
790 | 790 | return $values; |
791 | 791 | } |
792 | 792 | |
793 | 793 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
794 | 794 | |
795 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
795 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
796 | 796 | $values = $this->Values(); |
797 | 797 | } |
798 | 798 | |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $token = $this->lexer->lookahead; |
821 | 821 | $value = $this->Value(); |
822 | 822 | |
823 | - if ( ! is_object($value) && ! is_array($value)) { |
|
823 | + if (!is_object($value) && !is_array($value)) { |
|
824 | 824 | $this->syntaxError('Value', $token); |
825 | 825 | } |
826 | 826 | |
@@ -830,10 +830,10 @@ discard block |
||
830 | 830 | foreach ($values as $k => $value) { |
831 | 831 | if (is_object($value) && $value instanceof \stdClass) { |
832 | 832 | $values[$value->name] = $value->value; |
833 | - } else if ( ! isset($values['value'])){ |
|
833 | + } else if (!isset($values['value'])) { |
|
834 | 834 | $values['value'] = $value; |
835 | 835 | } else { |
836 | - if ( ! is_array($values['value'])) { |
|
836 | + if (!is_array($values['value'])) { |
|
837 | 837 | $values['value'] = [$values['value']]; |
838 | 838 | } |
839 | 839 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | { |
858 | 858 | $identifier = $this->Identifier(); |
859 | 859 | |
860 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
860 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
861 | 861 | list($className, $const) = explode('::', $identifier); |
862 | 862 | |
863 | 863 | $pos = strpos($className, '\\'); |
@@ -879,12 +879,12 @@ discard block |
||
879 | 879 | case isset($this->imports[$loweredAlias]): |
880 | 880 | $found = true; |
881 | 881 | $className = (false !== $pos) |
882 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
882 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
883 | 883 | : $this->imports[$loweredAlias]; |
884 | 884 | break; |
885 | 885 | |
886 | 886 | default: |
887 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
887 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
888 | 888 | $ns = $this->imports['__NAMESPACE__']; |
889 | 889 | |
890 | 890 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | } |
897 | 897 | |
898 | 898 | if ($found) { |
899 | - $identifier = $className . '::' . $const; |
|
899 | + $identifier = $className.'::'.$const; |
|
900 | 900 | } |
901 | 901 | } |
902 | 902 | |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | private function Identifier() |
922 | 922 | { |
923 | 923 | // check if we have an annotation |
924 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
924 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
925 | 925 | $this->syntaxError('namespace separator or identifier'); |
926 | 926 | } |
927 | 927 | |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
936 | 936 | $this->matchAny(self::$classIdentifiers); |
937 | 937 | |
938 | - $className .= '\\' . $this->lexer->token['value']; |
|
938 | + $className .= '\\'.$this->lexer->token['value']; |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | return $className; |
@@ -983,11 +983,11 @@ discard block |
||
983 | 983 | |
984 | 984 | case DocLexer::T_INTEGER: |
985 | 985 | $this->match(DocLexer::T_INTEGER); |
986 | - return (int)$this->lexer->token['value']; |
|
986 | + return (int) $this->lexer->token['value']; |
|
987 | 987 | |
988 | 988 | case DocLexer::T_FLOAT: |
989 | 989 | $this->match(DocLexer::T_FLOAT); |
990 | - return (float)$this->lexer->token['value']; |
|
990 | + return (float) $this->lexer->token['value']; |
|
991 | 991 | |
992 | 992 | case DocLexer::T_TRUE: |
993 | 993 | $this->match(DocLexer::T_TRUE); |
@@ -1115,9 +1115,9 @@ discard block |
||
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
1118 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
1118 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
1119 | 1119 | |
1120 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
1120 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
1121 | 1121 | return true; |
1122 | 1122 | } |
1123 | 1123 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function syntaxError($message) |
24 | 24 | { |
25 | - return new self('[Syntax Error] ' . $message); |
|
25 | + return new self('[Syntax Error] '.$message); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public static function semanticalError($message) |
36 | 36 | { |
37 | - return new self('[Semantical Error] ' . $message); |
|
37 | + return new self('[Semantical Error] '.$message); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public static function creationError($message) |
51 | 51 | { |
52 | - return new self('[Creation Error] ' . $message); |
|
52 | + return new self('[Creation Error] '.$message); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public static function typeError($message) |
65 | 65 | { |
66 | - return new self('[Type Error] ' . $message); |
|
66 | + return new self('[Type Error] '.$message); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | return self::semanticalError(sprintf( |
82 | 82 | "Couldn't find constant %s%s.", |
83 | 83 | $identifier, |
84 | - $context ? ', ' . $context : '' |
|
84 | + $context ? ', '.$context : '' |
|
85 | 85 | )); |
86 | 86 | } |
87 | 87 |
@@ -50,16 +50,16 @@ |
||
50 | 50 | */ |
51 | 51 | public function validate($value) : bool |
52 | 52 | { |
53 | - if (! is_array($value)) { |
|
53 | + if (!is_array($value)) { |
|
54 | 54 | return false; |
55 | 55 | } |
56 | 56 | |
57 | 57 | foreach ($value as $key => $innerValue) { |
58 | - if (! $this->keyType->validate($key)) { |
|
58 | + if (!$this->keyType->validate($key)) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - if (! $this->valueType->validate($innerValue)) { |
|
62 | + if (!$this->valueType->validate($innerValue)) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | } |