Skip to content

Commit

Permalink
Remove NamedArgumentConstructorAnnotation interface (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Dec 19, 2022
1 parent 9dc2866 commit 455db74
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 78 deletions.
2 changes: 2 additions & 0 deletions 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
Expand Down
3 changes: 1 addition & 2 deletions lib/Doctrine/Common/Annotations/DocParser.php
Expand Up @@ -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']) {
Expand Down

This file was deleted.

62 changes: 0 additions & 62 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Expand Up @@ -7,7 +7,6 @@
use Doctrine\Common\Annotations\Annotation\Target;
use Doctrine\Common\Annotations\AnnotationException;
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants;
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants;
Expand Down Expand Up @@ -1602,42 +1601,6 @@ public function testWillParseAnnotationSucceededByANonImmediateDash(): void
self::assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]);
}

public function testNamedArgumentsConstructorInterface(): void
{
$result = $this
->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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 455db74

Please sign in to comment.