diff --git a/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php b/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php index 0f4d679c3588..a91d82f4d226 100644 --- a/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php +++ b/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php @@ -38,11 +38,6 @@ final class DoctrineAnnotationTagValueNode extends AbstractTagValueNode implemen */ private $hasChanged = false; - /** - * @var string|null - */ - private $silentKey; - /** * @param array $values */ @@ -59,7 +54,6 @@ public function __construct( $this->annotationClass = $annotationClass; $this->docContent = $docContent; $this->values = $values; - $this->silentKey = $silentKey; $this->hasChanged = true; parent::__construct( @@ -72,7 +66,7 @@ public function __construct( public function __toString(): string { - if ($this->hasChanged === false) { + if (! $this->hasChanged) { if ($this->docContent === null) { return ''; } @@ -126,11 +120,10 @@ public function getValuesWithExplicitSilentAndWithoutQuotes(): array { $explicitKeysValues = []; - foreach ($this->values as $key => $value) { + foreach (array_keys($this->values) as $key) { $valueWithoutQuotes = $this->getValueWithoutQuotes($key); if (is_int($key)) { - $explicitKeysValues[$this->silentKey] = $valueWithoutQuotes; } else { $explicitKeysValues[$key] = $valueWithoutQuotes; } @@ -244,8 +237,10 @@ private function stringifyValue($value): string if ($value === true) { return 'true'; } - - if (is_int($value) || is_float($value)) { + if (is_int($value)) { + return (string) $value; + } + if (is_float($value)) { return (string) $value; } diff --git a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php index 120f4ec936f1..d2966da001e2 100644 --- a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php +++ b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php @@ -320,11 +320,14 @@ public function getByAnnotationClass(string $class): ?DoctrineAnnotationTagValue if ($annotationClass === $class) { return $phpDocChildNode->value; } - // fnmatch - if (Strings::contains($class, '*') && fnmatch($class, $annotationClass, FNM_NOESCAPE)) { - return $phpDocChildNode->value; + if (! Strings::contains($class, '*')) { + continue; } + if (! fnmatch($class, $annotationClass, FNM_NOESCAPE)) { + continue; + } + return $phpDocChildNode->value; } return null; diff --git a/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php b/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php index c6b9730e93c2..7709e8366260 100644 --- a/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php +++ b/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php @@ -7,7 +7,7 @@ final class SilentKeyMap { /** - * @var array + * @var array */ public const CLASS_NAMES_TO_SILENT_KEYS = [ 'Symfony\Component\Routing\Annotation\Route' => 'path', diff --git a/packages/BetterPhpDocParser/ValueObject/NodeTypes.php b/packages/BetterPhpDocParser/ValueObject/NodeTypes.php index 92bde382dd64..4951c81da06b 100644 --- a/packages/BetterPhpDocParser/ValueObject/NodeTypes.php +++ b/packages/BetterPhpDocParser/ValueObject/NodeTypes.php @@ -25,7 +25,7 @@ final class NodeTypes ]; /** - * @var array + * @var string[] */ public const TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES = [ 'JMS\Serializer\Annotation\Type',