@@ -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 |
@@ -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 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | [ |
| 60 | 60 | 'type' => 'array', |
| 61 | 61 | 'array_type' =>Attribute::class, |
| 62 | - 'value' =>'array<' . Attribute::class . '>', |
|
| 62 | + 'value' =>'array<'.Attribute::class.'>', |
|
| 63 | 63 | ], |
| 64 | 64 | true, |
| 65 | 65 | true |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | private function match($token) |
| 303 | 303 | { |
| 304 | - if ( ! $this->lexer->isNextToken($token) ) { |
|
| 304 | + if (!$this->lexer->isNextToken($token)) { |
|
| 305 | 305 | $this->syntaxError($this->lexer->getLiteral($token)); |
| 306 | 306 | } |
| 307 | 307 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | private function matchAny(array $tokens) |
| 322 | 322 | { |
| 323 | - if ( ! $this->lexer->isNextTokenAny($tokens)) { |
|
| 323 | + if (!$this->lexer->isNextTokenAny($tokens)) { |
|
| 324 | 324 | $this->syntaxError(implode(' or ', array_map([$this->lexer, 'getLiteral'], $tokens))); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | : sprintf("'%s' at position %s", $token['value'], $token['position']); |
| 350 | 350 | |
| 351 | 351 | if (strlen($this->context)) { |
| 352 | - $message .= ' in ' . $this->context; |
|
| 352 | + $message .= ' in '.$this->context; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $message .= '.'; |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | self::$metadataParser->setTarget(Target::TARGET_CLASS); |
| 417 | 417 | |
| 418 | - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { |
|
| 418 | + foreach (self::$metadataParser->parse($docComment, 'class @'.$name) as $annotation) { |
|
| 419 | 419 | if ($annotation instanceof Target) { |
| 420 | 420 | $annotationBuilder->withTarget(AnnotationTarget::fromAnnotation($annotation)); |
| 421 | 421 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // if there is no constructor we will inject values into public properties |
| 436 | - if (! $useConstructor) { |
|
| 436 | + if (!$useConstructor) { |
|
| 437 | 437 | // collect all public properties |
| 438 | 438 | foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $i => $property) { |
| 439 | 439 | $propertyBuilder = new PropertyMetadataBuilder($property->getName()); |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $attribute = new Attribute(); |
| 454 | 454 | $attribute->required = (false !== strpos($propertyComment, '@Required')); |
| 455 | 455 | $attribute->name = $property->name; |
| 456 | - $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) |
|
| 456 | + $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/', $propertyComment, $matches)) |
|
| 457 | 457 | ? $matches[1] |
| 458 | 458 | : 'mixed'; |
| 459 | 459 | |
@@ -461,18 +461,18 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | // checks if the property has @Enum |
| 463 | 463 | if (false !== strpos($propertyComment, '@Enum')) { |
| 464 | - $context = 'property ' . $class->name . "::\$" . $property->name; |
|
| 464 | + $context = 'property '.$class->name."::\$".$property->name; |
|
| 465 | 465 | |
| 466 | 466 | self::$metadataParser->setTarget(Target::TARGET_PROPERTY); |
| 467 | 467 | |
| 468 | 468 | foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { |
| 469 | - if ( ! $annotation instanceof Enum) { |
|
| 469 | + if (!$annotation instanceof Enum) { |
|
| 470 | 470 | continue; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | $propertyBuilder = $propertyBuilder->withEnum([ |
| 474 | 474 | 'value' => $annotation->value, |
| 475 | - 'literal' => ( ! empty($annotation->literal)) |
|
| 475 | + 'literal' => (!empty($annotation->literal)) |
|
| 476 | 476 | ? $annotation->literal |
| 477 | 477 | : $annotation->value, |
| 478 | 478 | ]); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | if ('\\' !== $name[0]) { |
| 605 | 605 | $pos = strpos($name, '\\'); |
| 606 | - $alias = (false === $pos)? $name : substr($name, 0, $pos); |
|
| 606 | + $alias = (false === $pos) ? $name : substr($name, 0, $pos); |
|
| 607 | 607 | $found = false; |
| 608 | 608 | $loweredAlias = strtolower($alias); |
| 609 | 609 | |
@@ -618,19 +618,19 @@ discard block |
||
| 618 | 618 | } elseif (isset($this->imports[$loweredAlias])) { |
| 619 | 619 | $found = true; |
| 620 | 620 | $name = (false !== $pos) |
| 621 | - ? $this->imports[$loweredAlias] . substr($name, $pos) |
|
| 621 | + ? $this->imports[$loweredAlias].substr($name, $pos) |
|
| 622 | 622 | : $this->imports[$loweredAlias]; |
| 623 | - } elseif ( ! isset($this->ignoredAnnotationNames[$name]) |
|
| 623 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) |
|
| 624 | 624 | && isset($this->imports['__NAMESPACE__']) |
| 625 | - && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) |
|
| 625 | + && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name) |
|
| 626 | 626 | ) { |
| 627 | 627 | $name = $this->imports['__NAMESPACE__'].'\\'.$name; |
| 628 | 628 | $found = true; |
| 629 | - } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
| 629 | + } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { |
|
| 630 | 630 | $found = true; |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - if ( ! $found) { |
|
| 633 | + if (!$found) { |
|
| 634 | 634 | if ($this->isIgnoredAnnotation($name)) { |
| 635 | 635 | return false; |
| 636 | 636 | } |
@@ -639,9 +639,9 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - $name = ltrim($name,'\\'); |
|
| 642 | + $name = ltrim($name, '\\'); |
|
| 643 | 643 | |
| 644 | - if ( ! $this->classExists($name)) { |
|
| 644 | + if (!$this->classExists($name)) { |
|
| 645 | 645 | throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); |
| 646 | 646 | } |
| 647 | 647 | |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | |
| 653 | 653 | // collects the metadata annotation only if there is not yet |
| 654 | - if (! $this->metadata->has($name) && ! array_key_exists($name, $this->nonAnnotationClasses)) { |
|
| 654 | + if (!$this->metadata->has($name) && !array_key_exists($name, $this->nonAnnotationClasses)) { |
|
| 655 | 655 | $this->collectAnnotationMetadata($name); |
| 656 | 656 | } |
| 657 | 657 | |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | $enum = $property->getEnum(); |
| 687 | 687 | |
| 688 | 688 | // checks if the attribute is a valid enumerator |
| 689 | - if ($enum !== null && isset($values[$propertyName]) && ! in_array($values[$propertyName], $enum['value'])) { |
|
| 689 | + if ($enum !== null && isset($values[$propertyName]) && !in_array($values[$propertyName], $enum['value'])) { |
|
| 690 | 690 | throw AnnotationException::enumeratorError($propertyName, $name, $this->context, $enum['literal'], $values[$propertyName]); |
| 691 | 691 | } |
| 692 | 692 | } |
@@ -702,9 +702,9 @@ discard block |
||
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | // handle a not given attribute or null value |
| 705 | - if (! isset($values[$valueName])) { |
|
| 705 | + if (!isset($values[$valueName])) { |
|
| 706 | 706 | if ($property->isRequired()) { |
| 707 | - throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) ' . $type['value']); |
|
| 707 | + throw AnnotationException::requiredError($propertyName, $originalName, $this->context, 'a(n) '.$type['value']); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | continue; |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | if ($type !== null && $type['type'] === 'array') { |
| 714 | 714 | // handle the case of a single value |
| 715 | - if ( ! is_array($values[$valueName])) { |
|
| 715 | + if (!is_array($values[$valueName])) { |
|
| 716 | 716 | $values[$valueName] = [$values[$valueName]]; |
| 717 | 717 | } |
| 718 | 718 | |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $instance = new $name(); |
| 739 | 739 | |
| 740 | 740 | foreach ($values as $property => $value) { |
| 741 | - if (! isset($this->metadata->get($name)->getProperties()[$property])) { |
|
| 741 | + if (!isset($this->metadata->get($name)->getProperties()[$property])) { |
|
| 742 | 742 | if ('value' !== $property) { |
| 743 | 743 | throw AnnotationException::creationError( |
| 744 | 744 | sprintf( |
@@ -776,13 +776,13 @@ discard block |
||
| 776 | 776 | { |
| 777 | 777 | $values = []; |
| 778 | 778 | |
| 779 | - if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
| 779 | + if (!$this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { |
|
| 780 | 780 | return $values; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | $this->match(DocLexer::T_OPEN_PARENTHESIS); |
| 784 | 784 | |
| 785 | - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
| 785 | + if (!$this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { |
|
| 786 | 786 | $values = $this->Values(); |
| 787 | 787 | } |
| 788 | 788 | |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | $token = $this->lexer->lookahead; |
| 811 | 811 | $value = $this->Value(); |
| 812 | 812 | |
| 813 | - if ( ! is_object($value) && ! is_array($value)) { |
|
| 813 | + if (!is_object($value) && !is_array($value)) { |
|
| 814 | 814 | $this->syntaxError('Value', $token); |
| 815 | 815 | } |
| 816 | 816 | |
@@ -820,10 +820,10 @@ discard block |
||
| 820 | 820 | foreach ($values as $k => $value) { |
| 821 | 821 | if (is_object($value) && $value instanceof \stdClass) { |
| 822 | 822 | $values[$value->name] = $value->value; |
| 823 | - } else if ( ! isset($values['value'])){ |
|
| 823 | + } else if (!isset($values['value'])) { |
|
| 824 | 824 | $values['value'] = $value; |
| 825 | 825 | } else { |
| 826 | - if ( ! is_array($values['value'])) { |
|
| 826 | + if (!is_array($values['value'])) { |
|
| 827 | 827 | $values['value'] = [$values['value']]; |
| 828 | 828 | } |
| 829 | 829 | |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | { |
| 848 | 848 | $identifier = $this->Identifier(); |
| 849 | 849 | |
| 850 | - if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
| 850 | + if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { |
|
| 851 | 851 | list($className, $const) = explode('::', $identifier); |
| 852 | 852 | |
| 853 | 853 | $pos = strpos($className, '\\'); |
@@ -869,12 +869,12 @@ discard block |
||
| 869 | 869 | case isset($this->imports[$loweredAlias]): |
| 870 | 870 | $found = true; |
| 871 | 871 | $className = (false !== $pos) |
| 872 | - ? $this->imports[$loweredAlias] . substr($className, $pos) |
|
| 872 | + ? $this->imports[$loweredAlias].substr($className, $pos) |
|
| 873 | 873 | : $this->imports[$loweredAlias]; |
| 874 | 874 | break; |
| 875 | 875 | |
| 876 | 876 | default: |
| 877 | - if(isset($this->imports['__NAMESPACE__'])) { |
|
| 877 | + if (isset($this->imports['__NAMESPACE__'])) { |
|
| 878 | 878 | $ns = $this->imports['__NAMESPACE__']; |
| 879 | 879 | |
| 880 | 880 | if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | if ($found) { |
| 889 | - $identifier = $className . '::' . $const; |
|
| 889 | + $identifier = $className.'::'.$const; |
|
| 890 | 890 | } |
| 891 | 891 | } |
| 892 | 892 | |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | private function Identifier() |
| 912 | 912 | { |
| 913 | 913 | // check if we have an annotation |
| 914 | - if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
| 914 | + if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { |
|
| 915 | 915 | $this->syntaxError('namespace separator or identifier'); |
| 916 | 916 | } |
| 917 | 917 | |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | $this->match(DocLexer::T_NAMESPACE_SEPARATOR); |
| 926 | 926 | $this->matchAny(self::$classIdentifiers); |
| 927 | 927 | |
| 928 | - $className .= '\\' . $this->lexer->token['value']; |
|
| 928 | + $className .= '\\'.$this->lexer->token['value']; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | return $className; |
@@ -973,11 +973,11 @@ discard block |
||
| 973 | 973 | |
| 974 | 974 | case DocLexer::T_INTEGER: |
| 975 | 975 | $this->match(DocLexer::T_INTEGER); |
| 976 | - return (int)$this->lexer->token['value']; |
|
| 976 | + return (int) $this->lexer->token['value']; |
|
| 977 | 977 | |
| 978 | 978 | case DocLexer::T_FLOAT: |
| 979 | 979 | $this->match(DocLexer::T_FLOAT); |
| 980 | - return (float)$this->lexer->token['value']; |
|
| 980 | + return (float) $this->lexer->token['value']; |
|
| 981 | 981 | |
| 982 | 982 | case DocLexer::T_TRUE: |
| 983 | 983 | $this->match(DocLexer::T_TRUE); |
@@ -1105,9 +1105,9 @@ discard block |
||
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { |
| 1108 | - $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\'; |
|
| 1108 | + $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\').'\\'; |
|
| 1109 | 1109 | |
| 1110 | - if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) { |
|
| 1110 | + if (0 === stripos(rtrim($name, '\\').'\\', $ignoredAnnotationNamespace)) { |
|
| 1111 | 1111 | return true; |
| 1112 | 1112 | } |
| 1113 | 1113 | } |
@@ -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 | ); |