@@ -51,16 +51,16 @@ |
||
51 | 51 | */ |
52 | 52 | public function validate($value) : bool |
53 | 53 | { |
54 | - if (! is_array($value)) { |
|
54 | + if (!is_array($value)) { |
|
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | 58 | foreach ($value as $key => $innerValue) { |
59 | - if (! $this->keyType->validate($key)) { |
|
59 | + if (!$this->keyType->validate($key)) { |
|
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | |
63 | - if (! $this->valueType->validate($innerValue)) { |
|
63 | + if (!$this->valueType->validate($innerValue)) { |
|
64 | 64 | return false; |
65 | 65 | } |
66 | 66 | } |
@@ -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 |
@@ -40,7 +40,7 @@ |
||
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 | } |
@@ -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 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | } |
554 | 554 | |
555 | 555 | // Checks if the property has type[] |
556 | - if (false !== $pos = strrpos($type, '[')) { |
|
556 | + if (false !== $pos = strrpos($type, '[')) { |
|
557 | 557 | $arrayType = substr($type, 0, $pos); |
558 | 558 | |
559 | 559 | $metadata->withType(new ArrayType(new MixedType(), $this->createTypeFromName($arrayType))); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | if (($metadata->getTarget()->unwrap() & $target) === 0 && $target) { |
724 | 724 | throw AnnotationException::semanticalError( |
725 | 725 | sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.', |
726 | - $originalName, $this->context, $metadata->getTarget()->describe()) |
|
726 | + $originalName, $this->context, $metadata->getTarget()->describe()) |
|
727 | 727 | ); |
728 | 728 | } |
729 | 729 | |
@@ -915,9 +915,9 @@ discard block |
||
915 | 915 | case !empty ($this->namespaces): |
916 | 916 | foreach ($this->namespaces as $ns) { |
917 | 917 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
918 | - $className = $ns.'\\'.$className; |
|
919 | - $found = true; |
|
920 | - break; |
|
918 | + $className = $ns.'\\'.$className; |
|
919 | + $found = true; |
|
920 | + break; |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | break; |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | } |
943 | 943 | |
944 | 944 | if ($found) { |
945 | - $identifier = $className . '::' . $const; |
|
945 | + $identifier = $className . '::' . $const; |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 |
@@ -308,7 +308,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
498 | 498 | */ |
499 | 499 | private function createEnumType($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 | } |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | |
652 | 652 | if ('\\' !== $name[0]) { |
653 | 653 | $pos = strpos($name, '\\'); |
654 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
654 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
655 | 655 | $found = false; |
656 | 656 | $loweredAlias = strtolower($alias); |
657 | 657 | |
@@ -666,19 +666,19 @@ discard block |
||
666 | 666 | } elseif (isset($this->imports[$loweredAlias])) { |
667 | 667 | $found = true; |
668 | 668 | $name = (false !== $pos) |
669 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
669 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
670 | 670 | : $this->imports[$loweredAlias]; |
671 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
671 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
672 | 672 | && isset($this->imports['__NAMESPACE__']) |
673 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
673 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
674 | 674 | ) { |
675 | 675 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
676 | 676 | $found = true; |
677 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
677 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
678 | 678 | $found = true; |
679 | 679 | } |
680 | 680 | |
681 | - if ( ! $found) { |
|
681 | + if (!$found) { |
|
682 | 682 | if ($this->isIgnoredAnnotation($name)) { |
683 | 683 | return false; |
684 | 684 | } |
@@ -687,9 +687,9 @@ discard block |
||
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | - $name = ltrim($name,'\\'); |
|
690 | + $name = ltrim($name, '\\'); |
|
691 | 691 | |
692 | - if ( ! $this->classExists($name)) { |
|
692 | + if (!$this->classExists($name)) { |
|
693 | 693 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
694 | 694 | } |
695 | 695 | |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | |
701 | 701 | // collects the metadata annotation only if there is not yet |
702 | - if (! $this->metadata->has($name) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
702 | + if (!$this->metadata->has($name) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
703 | 703 | $this->collectAnnotationMetadata($name); |
704 | 704 | } |
705 | 705 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $enum = $property->getEnum(); |
736 | 736 | |
737 | 737 | // checks if the attribute is a valid enumerator |
738 | - if ($enum !== null && isset($values[$propertyName]) && ! $enum->validate($values[$propertyName])) { |
|
738 | + if ($enum !== null && isset($values[$propertyName]) && !$enum->validate($values[$propertyName])) { |
|
739 | 739 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum->describe(), $values[$propertyName]); |
740 | 740 | } |
741 | 741 | } |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | } |
752 | 752 | |
753 | 753 | // handle a not given attribute or null value |
754 | - if (! isset($values[$valueName])) { |
|
754 | + if (!isset($values[$valueName])) { |
|
755 | 755 | if ($property->isRequired()) { |
756 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type->describe()); |
|
756 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe()); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | continue; |
@@ -761,14 +761,14 @@ discard block |
||
761 | 761 | |
762 | 762 | if ($type instanceof ArrayType) { |
763 | 763 | // handle the case of a single value |
764 | - if ( ! is_array($values[$valueName])) { |
|
764 | + if (!is_array($values[$valueName])) { |
|
765 | 765 | $values[$valueName] = [$values[$valueName]]; |
766 | 766 | } |
767 | 767 | |
768 | 768 | $valueType = $type->getValueType(); |
769 | 769 | |
770 | - if (! $type->validate($values[$valueName])) { |
|
771 | - $firstInvalidValue = (static function (array $values) use ($valueType) { |
|
770 | + if (!$type->validate($values[$valueName])) { |
|
771 | + $firstInvalidValue = (static function(array $values) use ($valueType) { |
|
772 | 772 | foreach ($values as $value) { |
773 | 773 | if ($valueType->validate($value)) { |
774 | 774 | continue; |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | } |
779 | 779 | })($values[$valueName]); |
780 | 780 | |
781 | - throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) ' . $type->getValueType()->describe() . ', or an array of ' . $type->getValueType()->describe() . 's', $firstInvalidValue); |
|
781 | + throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) '.$type->getValueType()->describe().', or an array of '.$type->getValueType()->describe().'s', $firstInvalidValue); |
|
782 | 782 | } |
783 | - } elseif (! $type->validate($values[$valueName])) { |
|
783 | + } elseif (!$type->validate($values[$valueName])) { |
|
784 | 784 | throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe(), $values[$valueName]); |
785 | 785 | } |
786 | 786 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | $instance = new $name(); |
795 | 795 | |
796 | 796 | foreach ($values as $property => $value) { |
797 | - if (! isset($metadata->getProperties()[$property])) { |
|
797 | + if (!isset($metadata->getProperties()[$property])) { |
|
798 | 798 | if ('value' !== $property) { |
799 | 799 | throw AnnotationException::creationError( |
800 | 800 | sprintf( |
@@ -832,13 +832,13 @@ discard block |
||
832 | 832 | { |
833 | 833 | $values = []; |
834 | 834 | |
835 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
835 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
836 | 836 | return $values; |
837 | 837 | } |
838 | 838 | |
839 | 839 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
840 | 840 | |
841 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
841 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
842 | 842 | $values = $this->Values(); |
843 | 843 | } |
844 | 844 | |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $token = $this->lexer->lookahead; |
867 | 867 | $value = $this->Value(); |
868 | 868 | |
869 | - if ( ! is_object($value) && ! is_array($value)) { |
|
869 | + if (!is_object($value) && !is_array($value)) { |
|
870 | 870 | $this->syntaxError('Value', $token); |
871 | 871 | } |
872 | 872 | |
@@ -876,10 +876,10 @@ discard block |
||
876 | 876 | foreach ($values as $k => $value) { |
877 | 877 | if (is_object($value) && $value instanceof \stdClass) { |
878 | 878 | $values[$value->name] = $value->value; |
879 | - } else if ( ! isset($values['value'])){ |
|
879 | + } else if (!isset($values['value'])) { |
|
880 | 880 | $values['value'] = $value; |
881 | 881 | } else { |
882 | - if ( ! is_array($values['value'])) { |
|
882 | + if (!is_array($values['value'])) { |
|
883 | 883 | $values['value'] = [$values['value']]; |
884 | 884 | } |
885 | 885 | |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | { |
904 | 904 | $identifier = $this->Identifier(); |
905 | 905 | |
906 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
906 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
907 | 907 | list($className, $const) = explode('::', $identifier); |
908 | 908 | |
909 | 909 | $pos = strpos($className, '\\'); |
@@ -925,12 +925,12 @@ discard block |
||
925 | 925 | case isset($this->imports[$loweredAlias]): |
926 | 926 | $found = true; |
927 | 927 | $className = (false !== $pos) |
928 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
928 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
929 | 929 | : $this->imports[$loweredAlias]; |
930 | 930 | break; |
931 | 931 | |
932 | 932 | default: |
933 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
933 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
934 | 934 | $ns = $this->imports['__NAMESPACE__']; |
935 | 935 | |
936 | 936 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | } |
943 | 943 | |
944 | 944 | if ($found) { |
945 | - $identifier = $className . '::' . $const; |
|
945 | + $identifier = $className.'::'.$const; |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | private function Identifier() |
968 | 968 | { |
969 | 969 | // check if we have an annotation |
970 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
970 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
971 | 971 | $this->syntaxError('namespace separator or identifier'); |
972 | 972 | } |
973 | 973 | |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
982 | 982 | $this->matchAny(self::$classIdentifiers); |
983 | 983 | |
984 | - $className .= '\\' . $this->lexer->token['value']; |
|
984 | + $className .= '\\'.$this->lexer->token['value']; |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | return $className; |
@@ -1029,11 +1029,11 @@ discard block |
||
1029 | 1029 | |
1030 | 1030 | case DocLexer::T_INTEGER: |
1031 | 1031 | $this->match(DocLexer::T_INTEGER); |
1032 | - return (int)$this->lexer->token['value']; |
|
1032 | + return (int) $this->lexer->token['value']; |
|
1033 | 1033 | |
1034 | 1034 | case DocLexer::T_FLOAT: |
1035 | 1035 | $this->match(DocLexer::T_FLOAT); |
1036 | - return (float)$this->lexer->token['value']; |
|
1036 | + return (float) $this->lexer->token['value']; |
|
1037 | 1037 | |
1038 | 1038 | case DocLexer::T_TRUE: |
1039 | 1039 | $this->match(DocLexer::T_TRUE); |
@@ -1161,9 +1161,9 @@ discard block |
||
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
1164 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
1164 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
1165 | 1165 | |
1166 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
1166 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
1167 | 1167 | return true; |
1168 | 1168 | } |
1169 | 1169 | } |