@@ -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(array $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 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | if ('\\' !== $name[0]) { |
| 658 | 658 | $pos = strpos($name, '\\'); |
| 659 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
| 659 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
| 660 | 660 | $found = false; |
| 661 | 661 | $loweredAlias = strtolower($alias); |
| 662 | 662 | |
@@ -671,19 +671,19 @@ discard block |
||
| 671 | 671 | } elseif (isset($this->imports[$loweredAlias])) { |
| 672 | 672 | $found = true; |
| 673 | 673 | $name = (false !== $pos) |
| 674 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
| 674 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
| 675 | 675 | : $this->imports[$loweredAlias]; |
| 676 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
| 676 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
| 677 | 677 | && isset($this->imports['__NAMESPACE__']) |
| 678 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
| 678 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
| 679 | 679 | ) { |
| 680 | 680 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
| 681 | 681 | $found = true; |
| 682 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
| 682 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
| 683 | 683 | $found = true; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if ( ! $found) { |
|
| 686 | + if (!$found) { |
|
| 687 | 687 | if ($this->isIgnoredAnnotation($name)) { |
| 688 | 688 | return false; |
| 689 | 689 | } |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - $name = ltrim($name,'\\'); |
|
| 695 | + $name = ltrim($name, '\\'); |
|
| 696 | 696 | |
| 697 | - if ( ! $this->classExists($name)) { |
|
| 697 | + if (!$this->classExists($name)) { |
|
| 698 | 698 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
| 699 | 699 | } |
| 700 | 700 | |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | |
| 706 | 706 | // collects the metadata annotation only if there is not yet |
| 707 | - if (! $this->metadata->has($name) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
| 707 | + if (!$this->metadata->has($name) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
| 708 | 708 | $this->collectAnnotationMetadata($name); |
| 709 | 709 | } |
| 710 | 710 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $enum = $property->getEnum(); |
| 741 | 741 | |
| 742 | 742 | // checks if the attribute is a valid enumerator |
| 743 | - if ($enum !== null && isset($values[$propertyName]) && ! $enum->validate($values[$propertyName])) { |
|
| 743 | + if ($enum !== null && isset($values[$propertyName]) && !$enum->validate($values[$propertyName])) { |
|
| 744 | 744 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum->describe(), $values[$propertyName]); |
| 745 | 745 | } |
| 746 | 746 | } |
@@ -756,9 +756,9 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // handle a not given attribute or null value |
| 759 | - if (! isset($values[$valueName])) { |
|
| 759 | + if (!isset($values[$valueName])) { |
|
| 760 | 760 | if ($property->isRequired()) { |
| 761 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type->describe()); |
|
| 761 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe()); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | continue; |
@@ -766,14 +766,14 @@ discard block |
||
| 766 | 766 | |
| 767 | 767 | if ($type instanceof ArrayType) { |
| 768 | 768 | // handle the case of a single value |
| 769 | - if ( ! is_array($values[$valueName])) { |
|
| 769 | + if (!is_array($values[$valueName])) { |
|
| 770 | 770 | $values[$valueName] = [$values[$valueName]]; |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | $valueType = $type->getValueType(); |
| 774 | 774 | |
| 775 | - if (! $type->validate($values[$valueName])) { |
|
| 776 | - $firstInvalidValue = (static function (array $values) use ($valueType) { |
|
| 775 | + if (!$type->validate($values[$valueName])) { |
|
| 776 | + $firstInvalidValue = (static function(array $values) use ($valueType) { |
|
| 777 | 777 | foreach ($values as $value) { |
| 778 | 778 | if ($valueType->validate($value)) { |
| 779 | 779 | continue; |
@@ -783,9 +783,9 @@ discard block |
||
| 783 | 783 | } |
| 784 | 784 | })($values[$valueName]); |
| 785 | 785 | |
| 786 | - throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) ' . $type->getValueType()->describe() . ', or an array of ' . $type->getValueType()->describe() . 's', $firstInvalidValue); |
|
| 786 | + throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'either a(n) '.$type->getValueType()->describe().', or an array of '.$type->getValueType()->describe().'s', $firstInvalidValue); |
|
| 787 | 787 | } |
| 788 | - } elseif (! $type->validate($values[$valueName])) { |
|
| 788 | + } elseif (!$type->validate($values[$valueName])) { |
|
| 789 | 789 | throw AnnotationException::attributeTypeError($propertyName, $originalName, $this->context, 'a(n) '.$type->describe(), $values[$valueName]); |
| 790 | 790 | } |
| 791 | 791 | } |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | $instance = new $name(); |
| 800 | 800 | |
| 801 | 801 | foreach ($values as $property => $value) { |
| 802 | - if (! isset($metadata->getProperties()[$property])) { |
|
| 802 | + if (!isset($metadata->getProperties()[$property])) { |
|
| 803 | 803 | if ('value' !== $property) { |
| 804 | 804 | throw AnnotationException::creationError( |
| 805 | 805 | sprintf( |
@@ -837,13 +837,13 @@ discard block |
||
| 837 | 837 | { |
| 838 | 838 | $values = []; |
| 839 | 839 | |
| 840 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
| 840 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
| 841 | 841 | return $values; |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
| 845 | 845 | |
| 846 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
| 846 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
| 847 | 847 | $values = $this->Values(); |
| 848 | 848 | } |
| 849 | 849 | |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | $token = $this->lexer->lookahead; |
| 872 | 872 | $value = $this->Value(); |
| 873 | 873 | |
| 874 | - if ( ! is_object($value) && ! is_array($value)) { |
|
| 874 | + if (!is_object($value) && !is_array($value)) { |
|
| 875 | 875 | $this->syntaxError('Value', $token); |
| 876 | 876 | } |
| 877 | 877 | |
@@ -881,10 +881,10 @@ discard block |
||
| 881 | 881 | foreach ($values as $k => $value) { |
| 882 | 882 | if (is_object($value) && $value instanceof \stdClass) { |
| 883 | 883 | $values[$value->name] = $value->value; |
| 884 | - } else if ( ! isset($values['value'])){ |
|
| 884 | + } else if (!isset($values['value'])) { |
|
| 885 | 885 | $values['value'] = $value; |
| 886 | 886 | } else { |
| 887 | - if ( ! is_array($values['value'])) { |
|
| 887 | + if (!is_array($values['value'])) { |
|
| 888 | 888 | $values['value'] = [$values['value']]; |
| 889 | 889 | } |
| 890 | 890 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | { |
| 909 | 909 | $identifier = $this->Identifier(); |
| 910 | 910 | |
| 911 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
| 911 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
| 912 | 912 | list($className, $const) = explode('::', $identifier); |
| 913 | 913 | |
| 914 | 914 | $pos = strpos($className, '\\'); |
@@ -930,12 +930,12 @@ discard block |
||
| 930 | 930 | case isset($this->imports[$loweredAlias]): |
| 931 | 931 | $found = true; |
| 932 | 932 | $className = (false !== $pos) |
| 933 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
| 933 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
| 934 | 934 | : $this->imports[$loweredAlias]; |
| 935 | 935 | break; |
| 936 | 936 | |
| 937 | 937 | default: |
| 938 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
| 938 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
| 939 | 939 | $ns = $this->imports['__NAMESPACE__']; |
| 940 | 940 | |
| 941 | 941 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | if ($found) { |
| 950 | - $identifier = $className . '::' . $const; |
|
| 950 | + $identifier = $className.'::'.$const; |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | private function Identifier() |
| 973 | 973 | { |
| 974 | 974 | // check if we have an annotation |
| 975 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
| 975 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
| 976 | 976 | $this->syntaxError('namespace separator or identifier'); |
| 977 | 977 | } |
| 978 | 978 | |
@@ -980,13 +980,13 @@ discard block |
||
| 980 | 980 | |
| 981 | 981 | $className = $this->lexer->token['value']; |
| 982 | 982 | |
| 983 | - while ($this->lexer->lookahead!==null && $this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value'])) |
|
| 983 | + while ($this->lexer->lookahead !== null && $this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value'])) |
|
| 984 | 984 | && $this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) { |
| 985 | 985 | |
| 986 | 986 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
| 987 | 987 | $this->matchAny(self::$classIdentifiers); |
| 988 | 988 | |
| 989 | - $className .= '\\' . $this->lexer->token['value']; |
|
| 989 | + $className .= '\\'.$this->lexer->token['value']; |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | return $className; |
@@ -1034,11 +1034,11 @@ discard block |
||
| 1034 | 1034 | |
| 1035 | 1035 | case DocLexer::T_INTEGER: |
| 1036 | 1036 | $this->match(DocLexer::T_INTEGER); |
| 1037 | - return (int)$this->lexer->token['value']; |
|
| 1037 | + return (int) $this->lexer->token['value']; |
|
| 1038 | 1038 | |
| 1039 | 1039 | case DocLexer::T_FLOAT: |
| 1040 | 1040 | $this->match(DocLexer::T_FLOAT); |
| 1041 | - return (float)$this->lexer->token['value']; |
|
| 1041 | + return (float) $this->lexer->token['value']; |
|
| 1042 | 1042 | |
| 1043 | 1043 | case DocLexer::T_TRUE: |
| 1044 | 1044 | $this->match(DocLexer::T_TRUE); |
@@ -1166,9 +1166,9 @@ discard block |
||
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
| 1169 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
| 1169 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
| 1170 | 1170 | |
| 1171 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
| 1171 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
| 1172 | 1172 | return true; |
| 1173 | 1173 | } |
| 1174 | 1174 | } |