diff --git a/UPGRADE.md b/UPGRADE.md index 6e88871cd..df069092c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,7 @@ # Upgrade from 1.0.x to 2.0.x +- The `NamedArgumentConstructorAnnotation` has been removed. Use the `@NamedArgumentConstructor` + annotation instead. - `SimpleAnnotationReader` has been removed. - `DocLexer::peek()` and `DocLexer::glimpse` now return `Doctrine\Common\Lexer\Token` objects. When using `doctrine/lexer` 2, these diff --git a/lib/Doctrine/Common/Annotations/DocParser.php b/lib/Doctrine/Common/Annotations/DocParser.php index d82119286..dc06bcbf8 100644 --- a/lib/Doctrine/Common/Annotations/DocParser.php +++ b/lib/Doctrine/Common/Annotations/DocParser.php @@ -523,8 +523,7 @@ class_exists(NamedArgumentConstructor::class); 'is_annotation' => strpos($docComment, '@Annotation') !== false, ]; - $metadata['has_named_argument_constructor'] = $metadata['has_constructor'] - && $class->implementsInterface(NamedArgumentConstructorAnnotation::class); + $metadata['has_named_argument_constructor'] = false; // verify that the class is really meant to be an annotation if ($metadata['is_annotation']) { diff --git a/lib/Doctrine/Common/Annotations/NamedArgumentConstructorAnnotation.php b/lib/Doctrine/Common/Annotations/NamedArgumentConstructorAnnotation.php deleted file mode 100644 index 8af224c0b..000000000 --- a/lib/Doctrine/Common/Annotations/NamedArgumentConstructorAnnotation.php +++ /dev/null @@ -1,14 +0,0 @@ -createTestParser() - ->parse('/** @NamedAnnotation(foo="baz", bar=2222) */'); - - self::assertCount(1, $result); - self::assertInstanceOf(NamedAnnotation::class, $result[0]); - self::assertSame('baz', $result[0]->getFoo()); - self::assertSame(2222, $result[0]->getBar()); - } - - public function testNamedReorderedArgumentsConstructorInterface(): void - { - $result = $this - ->createTestParser() - ->parse('/** @NamedAnnotation(bar=2222, foo="baz") */'); - - self::assertCount(1, $result); - self::assertInstanceOf(NamedAnnotation::class, $result[0]); - self::assertSame('baz', $result[0]->getFoo()); - self::assertSame(2222, $result[0]->getBar()); - } - - public function testNamedArgumentsConstructorInterfaceWithDefaultValue(): void - { - $result = $this - ->createTestParser() - ->parse('/** @NamedAnnotation(foo="baz") */'); - - self::assertCount(1, $result); - self::assertInstanceOf(NamedAnnotation::class, $result[0]); - self::assertSame('baz', $result[0]->getFoo()); - self::assertSame(1234, $result[0]->getBar()); - } - public function testNamedArgumentsConstructorAnnotation(): void { $result = $this @@ -1751,31 +1714,6 @@ public function expectExceptionMessageMatches(string $regularExpression): void } } -/** @Annotation */ -class NamedAnnotation implements NamedArgumentConstructorAnnotation -{ - /** @var string */ - private $foo; - /** @var int */ - private $bar; - - public function __construct(string $foo, int $bar = 1234) - { - $this->foo = $foo; - $this->bar = $bar; - } - - public function getFoo(): string - { - return $this->foo; - } - - public function getBar(): int - { - return $this->bar; - } -} - /** * @Annotation * @NamedArgumentConstructor