@@ -946,9 +946,9 @@ discard block |
||
946 | 946 | case ! empty($this->namespaces): |
947 | 947 | foreach ($this->namespaces as $ns) { |
948 | 948 | if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) { |
949 | - $className = $ns . '\\' . $className; |
|
950 | - $found = true; |
|
951 | - break; |
|
949 | + $className = $ns . '\\' . $className; |
|
950 | + $found = true; |
|
951 | + break; |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | } |
976 | 976 | |
977 | 977 | if ($found) { |
978 | - $identifier = $className . '::' . $const; |
|
978 | + $identifier = $className . '::' . $const; |
|
979 | 979 | } |
980 | 980 | } |
981 | 981 |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | 'type' => 'array', |
199 | 199 | 'required' => true, |
200 | 200 | 'array_type' => Annotation\Attribute::class, |
201 | - 'value' => 'array<' . Annotation\Attribute::class . '>', |
|
201 | + 'value' => 'array<'.Annotation\Attribute::class.'>', |
|
202 | 202 | ], |
203 | 203 | ], |
204 | 204 | ], |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | */ |
393 | 393 | private function match(int $token): bool |
394 | 394 | { |
395 | - if (! $this->lexer->isNextToken($token)) { |
|
395 | + if (!$this->lexer->isNextToken($token)) { |
|
396 | 396 | throw $this->syntaxError($this->lexer->getLiteral($token)); |
397 | 397 | } |
398 | 398 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | */ |
410 | 410 | private function matchAny(array $tokens): bool |
411 | 411 | { |
412 | - if (! $this->lexer->isNextTokenAny($tokens)) { |
|
412 | + if (!$this->lexer->isNextTokenAny($tokens)) { |
|
413 | 413 | throw $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens))); |
414 | 414 | } |
415 | 415 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | : sprintf("'%s' at position %s", $token['value'], $token['position']); |
435 | 435 | |
436 | 436 | if (strlen($this->context)) { |
437 | - $message .= ' in ' . $this->context; |
|
437 | + $message .= ' in '.$this->context; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $message .= '.'; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | if ($metadata['is_annotation']) { |
510 | 510 | self::$metadataParser->setTarget(Target::TARGET_CLASS); |
511 | 511 | |
512 | - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { |
|
512 | + foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) { |
|
513 | 513 | if ($annotation instanceof Target) { |
514 | 514 | $metadata['targets'] = $annotation->targets; |
515 | 515 | $metadata['targets_literal'] = $annotation->literal; |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | continue; |
518 | 518 | } |
519 | 519 | |
520 | - if (! ($annotation instanceof Attributes)) { |
|
520 | + if (!($annotation instanceof Attributes)) { |
|
521 | 521 | continue; |
522 | 522 | } |
523 | 523 | |
@@ -551,17 +551,17 @@ discard block |
||
551 | 551 | continue; |
552 | 552 | } |
553 | 553 | |
554 | - $context = 'property ' . $class->name . '::$' . $property->name; |
|
554 | + $context = 'property '.$class->name.'::$'.$property->name; |
|
555 | 555 | |
556 | 556 | self::$metadataParser->setTarget(Target::TARGET_PROPERTY); |
557 | 557 | |
558 | 558 | foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { |
559 | - if (! $annotation instanceof Enum) { |
|
559 | + if (!$annotation instanceof Enum) { |
|
560 | 560 | continue; |
561 | 561 | } |
562 | 562 | |
563 | 563 | $metadata['enum'][$property->name]['value'] = $annotation->value; |
564 | - $metadata['enum'][$property->name]['literal'] = ( ! empty($annotation->literal)) |
|
564 | + $metadata['enum'][$property->name]['literal'] = (!empty($annotation->literal)) |
|
565 | 565 | ? $annotation->literal |
566 | 566 | : $annotation->value; |
567 | 567 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | // an identifier token |
647 | 647 | if ( |
648 | 648 | (null === $peek = $this->lexer->glimpse()) |
649 | - || ($peek['type'] !== DocLexer::T_NAMESPACE_SEPARATOR && ! in_array($peek['type'], self::$classIdentifiers, true)) |
|
649 | + || ($peek['type'] !== DocLexer::T_NAMESPACE_SEPARATOR && !in_array($peek['type'], self::$classIdentifiers, true)) |
|
650 | 650 | || $peek['position'] !== $this->lexer->lookahead['position'] + 1 |
651 | 651 | ) { |
652 | 652 | $this->lexer->moveNext(); |
@@ -703,8 +703,8 @@ discard block |
||
703 | 703 | |
704 | 704 | if ($this->namespaces) { |
705 | 705 | foreach ($this->namespaces as $namespace) { |
706 | - if ($this->classExists($namespace . '\\' . $name)) { |
|
707 | - $name = $namespace . '\\' . $name; |
|
706 | + if ($this->classExists($namespace.'\\'.$name)) { |
|
707 | + $name = $namespace.'\\'.$name; |
|
708 | 708 | $found = true; |
709 | 709 | break; |
710 | 710 | } |
@@ -712,21 +712,21 @@ discard block |
||
712 | 712 | } elseif (isset($this->imports[$loweredAlias])) { |
713 | 713 | $namespace = ltrim($this->imports[$loweredAlias], '\\'); |
714 | 714 | $name = ($pos !== false) |
715 | - ? $namespace . substr($name, $pos) |
|
715 | + ? $namespace.substr($name, $pos) |
|
716 | 716 | : $namespace; |
717 | 717 | $found = $this->classExists($name); |
718 | 718 | } elseif ( |
719 | - ! isset($this->ignoredAnnotationNames[$name]) |
|
719 | + !isset($this->ignoredAnnotationNames[$name]) |
|
720 | 720 | && isset($this->imports['__NAMESPACE__']) |
721 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
721 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
722 | 722 | ) { |
723 | - $name = $this->imports['__NAMESPACE__'] . '\\' . $name; |
|
723 | + $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
|
724 | 724 | $found = true; |
725 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
725 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
726 | 726 | $found = true; |
727 | 727 | } |
728 | 728 | |
729 | - if (! $found) { |
|
729 | + if (!$found) { |
|
730 | 730 | if ($this->isIgnoredAnnotation($name)) { |
731 | 731 | return false; |
732 | 732 | } |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | |
738 | 738 | $name = ltrim($name, '\\'); |
739 | 739 | |
740 | - if (! $this->classExists($name)) { |
|
740 | + if (!$this->classExists($name)) { |
|
741 | 741 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
742 | 742 | } |
743 | 743 | |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | // that it is loaded |
747 | 747 | |
748 | 748 | // collects the metadata annotation only if there is not yet |
749 | - if (! isset(self::$annotationMetadata[$name])) { |
|
749 | + if (!isset(self::$annotationMetadata[$name])) { |
|
750 | 750 | $this->collectAnnotationMetadata($name); |
751 | 751 | } |
752 | 752 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | // checks all declared attributes |
784 | 784 | foreach (self::$annotationMetadata[$name]['enum'] as $property => $enum) { |
785 | 785 | // checks if the attribute is a valid enumerator |
786 | - if (isset($values[$property]) && ! in_array($values[$property], $enum['value'])) { |
|
786 | + if (isset($values[$property]) && !in_array($values[$property], $enum['value'])) { |
|
787 | 787 | throw AnnotationException::enumeratorError($property, $name, $this->context, $enum['literal'], $values[$property]); |
788 | 788 | } |
789 | 789 | } |
@@ -793,15 +793,15 @@ discard block |
||
793 | 793 | foreach (self::$annotationMetadata[$name]['attribute_types'] as $property => $type) { |
794 | 794 | if ( |
795 | 795 | $property === self::$annotationMetadata[$name]['default_property'] |
796 | - && ! isset($values[$property]) && isset($values['value']) |
|
796 | + && !isset($values[$property]) && isset($values['value']) |
|
797 | 797 | ) { |
798 | 798 | $property = 'value'; |
799 | 799 | } |
800 | 800 | |
801 | 801 | // handle a not given attribute or null value |
802 | - if (! isset($values[$property])) { |
|
802 | + if (!isset($values[$property])) { |
|
803 | 803 | if ($type['required']) { |
804 | - throw AnnotationException::requiredError($property, $originalName, $this->context, 'a(n) ' . $type['value']); |
|
804 | + throw AnnotationException::requiredError($property, $originalName, $this->context, 'a(n) '.$type['value']); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | continue; |
@@ -809,20 +809,20 @@ discard block |
||
809 | 809 | |
810 | 810 | if ($type['type'] === 'array') { |
811 | 811 | // handle the case of a single value |
812 | - if (! is_array($values[$property])) { |
|
812 | + if (!is_array($values[$property])) { |
|
813 | 813 | $values[$property] = [$values[$property]]; |
814 | 814 | } |
815 | 815 | |
816 | 816 | // checks if the attribute has array type declaration, such as "array<string>" |
817 | 817 | if (isset($type['array_type'])) { |
818 | 818 | foreach ($values[$property] as $item) { |
819 | - if (gettype($item) !== $type['array_type'] && ! $item instanceof $type['array_type']) { |
|
820 | - throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'either a(n) ' . $type['array_type'] . ', or an array of ' . $type['array_type'] . 's', $item); |
|
819 | + if (gettype($item) !== $type['array_type'] && !$item instanceof $type['array_type']) { |
|
820 | + throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'either a(n) '.$type['array_type'].', or an array of '.$type['array_type'].'s', $item); |
|
821 | 821 | } |
822 | 822 | } |
823 | 823 | } |
824 | - } elseif (gettype($values[$property]) !== $type['type'] && ! $values[$property] instanceof $type['type']) { |
|
825 | - throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'a(n) ' . $type['value'], $values[$property]); |
|
824 | + } elseif (gettype($values[$property]) !== $type['type'] && !$values[$property] instanceof $type['type']) { |
|
825 | + throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'a(n) '.$type['value'], $values[$property]); |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | $instance = new $name(); |
836 | 836 | |
837 | 837 | foreach ($values as $property => $value) { |
838 | - if (! isset(self::$annotationMetadata[$name]['properties'][$property])) { |
|
838 | + if (!isset(self::$annotationMetadata[$name]['properties'][$property])) { |
|
839 | 839 | if ($property !== 'value') { |
840 | 840 | throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not have a property named "%s". Available properties: %s', $originalName, $this->context, $property, implode(', ', self::$annotationMetadata[$name]['properties']))); |
841 | 841 | } |
842 | 842 | |
843 | 843 | // handle the case if the property has no annotations |
844 | - if (! $property = self::$annotationMetadata[$name]['default_property']) { |
|
844 | + if (!$property = self::$annotationMetadata[$name]['default_property']) { |
|
845 | 845 | throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not accept any values, but got %s.', $originalName, $this->context, json_encode($values))); |
846 | 846 | } |
847 | 847 | } |
@@ -862,13 +862,13 @@ discard block |
||
862 | 862 | { |
863 | 863 | $values = []; |
864 | 864 | |
865 | - if (! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
865 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
866 | 866 | return $values; |
867 | 867 | } |
868 | 868 | |
869 | 869 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
870 | 870 | |
871 | - if (! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
871 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
872 | 872 | $values = $this->Values(); |
873 | 873 | } |
874 | 874 | |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | $token = $this->lexer->lookahead; |
898 | 898 | $value = $this->Value(); |
899 | 899 | |
900 | - if (! is_object($value) && ! is_array($value)) { |
|
900 | + if (!is_object($value) && !is_array($value)) { |
|
901 | 901 | throw $this->syntaxError('Value', $token); |
902 | 902 | } |
903 | 903 | |
@@ -907,10 +907,10 @@ discard block |
||
907 | 907 | foreach ($values as $k => $value) { |
908 | 908 | if (is_object($value) && $value instanceof stdClass) { |
909 | 909 | $values[$value->name] = $value->value; |
910 | - } elseif (! isset($values['value'])) { |
|
910 | + } elseif (!isset($values['value'])) { |
|
911 | 911 | $values['value'] = $value; |
912 | 912 | } else { |
913 | - if (! is_array($values['value'])) { |
|
913 | + if (!is_array($values['value'])) { |
|
914 | 914 | $values['value'] = [$values['value']]; |
915 | 915 | } |
916 | 916 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | { |
935 | 935 | $identifier = $this->Identifier(); |
936 | 936 | |
937 | - if (! defined($identifier) && strpos($identifier, '::') !== false && $identifier[0] !== '\\') { |
|
937 | + if (!defined($identifier) && strpos($identifier, '::') !== false && $identifier[0] !== '\\') { |
|
938 | 938 | [$className, $const] = explode('::', $identifier); |
939 | 939 | |
940 | 940 | $pos = strpos($className, '\\'); |
@@ -943,10 +943,10 @@ discard block |
||
943 | 943 | $loweredAlias = strtolower($alias); |
944 | 944 | |
945 | 945 | switch (true) { |
946 | - case ! empty($this->namespaces): |
|
946 | + case !empty($this->namespaces): |
|
947 | 947 | foreach ($this->namespaces as $ns) { |
948 | - if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) { |
|
949 | - $className = $ns . '\\' . $className; |
|
948 | + if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
|
949 | + $className = $ns.'\\'.$className; |
|
950 | 950 | $found = true; |
951 | 951 | break; |
952 | 952 | } |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | case isset($this->imports[$loweredAlias]): |
958 | 958 | $found = true; |
959 | 959 | $className = ($pos !== false) |
960 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
960 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
961 | 961 | : $this->imports[$loweredAlias]; |
962 | 962 | break; |
963 | 963 | |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | if (isset($this->imports['__NAMESPACE__'])) { |
966 | 966 | $ns = $this->imports['__NAMESPACE__']; |
967 | 967 | |
968 | - if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) { |
|
969 | - $className = $ns . '\\' . $className; |
|
968 | + if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
|
969 | + $className = $ns.'\\'.$className; |
|
970 | 970 | $found = true; |
971 | 971 | } |
972 | 972 | } |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | } |
976 | 976 | |
977 | 977 | if ($found) { |
978 | - $identifier = $className . '::' . $const; |
|
978 | + $identifier = $className.'::'.$const; |
|
979 | 979 | } |
980 | 980 | } |
981 | 981 | |
982 | 982 | /** |
983 | 983 | * Checks if identifier ends with ::class and remove the leading backslash if it exists. |
984 | 984 | */ |
985 | - if ($this->identifierEndsWithClassConstant($identifier) && ! $this->identifierStartsWithBackslash($identifier)) { |
|
985 | + if ($this->identifierEndsWithClassConstant($identifier) && !$this->identifierStartsWithBackslash($identifier)) { |
|
986 | 986 | return substr($identifier, 0, $this->getClassConstantPositionInIdentifier($identifier)); |
987 | 987 | } |
988 | 988 | |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | return substr($identifier, 1, $this->getClassConstantPositionInIdentifier($identifier) - 1); |
991 | 991 | } |
992 | 992 | |
993 | - if (! defined($identifier)) { |
|
993 | + if (!defined($identifier)) { |
|
994 | 994 | throw AnnotationException::semanticalErrorConstants($identifier, $this->context); |
995 | 995 | } |
996 | 996 | |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | private function Identifier(): string |
1024 | 1024 | { |
1025 | 1025 | // check if we have an annotation |
1026 | - if (! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
1026 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
1027 | 1027 | throw $this->syntaxError('namespace separator or identifier'); |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
1040 | 1040 | $this->matchAny(self::$classIdentifiers); |
1041 | 1041 | |
1042 | - $className .= '\\' . $this->lexer->token['value']; |
|
1042 | + $className .= '\\'.$this->lexer->token['value']; |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | return $className; |
@@ -1231,9 +1231,9 @@ discard block |
||
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
1234 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
1234 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
1235 | 1235 | |
1236 | - if (stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace) === 0) { |
|
1236 | + if (stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace) === 0) { |
|
1237 | 1237 | return true; |
1238 | 1238 | } |
1239 | 1239 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | $namespace = preg_quote($class->getNamespaceName()); |
42 | - $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content); |
|
43 | - $tokenizer = new TokenParser('<?php ' . $content); |
|
42 | + $content = preg_replace('/^.*?(\bnamespace\s+'.$namespace.'\s*[;{].*)$/s', '\\1', $content); |
|
43 | + $tokenizer = new TokenParser('<?php '.$content); |
|
44 | 44 | |
45 | 45 | return $tokenizer->parseUseStatements($class->getNamespaceName()); |
46 | 46 | } |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private function getFileContent($filename, $lineNumber) |
57 | 57 | { |
58 | - if (! is_file($filename)) { |
|
58 | + if (!is_file($filename)) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $content = ''; |
63 | 63 | $lineCnt = 0; |
64 | 64 | $file = new SplFileObject($filename); |
65 | - while (! $file->eof()) { |
|
65 | + while (!$file->eof()) { |
|
66 | 66 | if ($lineCnt++ === $lineNumber) { |
67 | 67 | break; |
68 | 68 | } |