Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove NamedArgumentConstructorAnnotation interface #470

Merged
merged 1 commit into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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