Skip to content

Commit 455db74

Browse files
authored
Remove NamedArgumentConstructorAnnotation interface (#470)
1 parent 9dc2866 commit 455db74

File tree

4 files changed

+3
-78
lines changed

4 files changed

+3
-78
lines changed

UPGRADE.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Upgrade from 1.0.x to 2.0.x
22

3+
- The `NamedArgumentConstructorAnnotation` has been removed. Use the `@NamedArgumentConstructor`
4+
annotation instead.
35
- `SimpleAnnotationReader` has been removed.
46
- `DocLexer::peek()` and `DocLexer::glimpse` now return
57
`Doctrine\Common\Lexer\Token` objects. When using `doctrine/lexer` 2, these

lib/Doctrine/Common/Annotations/DocParser.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,7 @@ class_exists(NamedArgumentConstructor::class);
523523
'is_annotation' => strpos($docComment, '@Annotation') !== false,
524524
];
525525

526-
$metadata['has_named_argument_constructor'] = $metadata['has_constructor']
527-
&& $class->implementsInterface(NamedArgumentConstructorAnnotation::class);
526+
$metadata['has_named_argument_constructor'] = false;
528527

529528
// verify that the class is really meant to be an annotation
530529
if ($metadata['is_annotation']) {

lib/Doctrine/Common/Annotations/NamedArgumentConstructorAnnotation.php

-14
This file was deleted.

tests/Doctrine/Tests/Common/Annotations/DocParserTest.php

-62
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\Common\Annotations\Annotation\Target;
88
use Doctrine\Common\Annotations\AnnotationException;
99
use Doctrine\Common\Annotations\DocParser;
10-
use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation;
1110
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
1211
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants;
1312
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants;
@@ -1602,42 +1601,6 @@ public function testWillParseAnnotationSucceededByANonImmediateDash(): void
16021601
self::assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]);
16031602
}
16041603

1605-
public function testNamedArgumentsConstructorInterface(): void
1606-
{
1607-
$result = $this
1608-
->createTestParser()
1609-
->parse('/** @NamedAnnotation(foo="baz", bar=2222) */');
1610-
1611-
self::assertCount(1, $result);
1612-
self::assertInstanceOf(NamedAnnotation::class, $result[0]);
1613-
self::assertSame('baz', $result[0]->getFoo());
1614-
self::assertSame(2222, $result[0]->getBar());
1615-
}
1616-
1617-
public function testNamedReorderedArgumentsConstructorInterface(): void
1618-
{
1619-
$result = $this
1620-
->createTestParser()
1621-
->parse('/** @NamedAnnotation(bar=2222, foo="baz") */');
1622-
1623-
self::assertCount(1, $result);
1624-
self::assertInstanceOf(NamedAnnotation::class, $result[0]);
1625-
self::assertSame('baz', $result[0]->getFoo());
1626-
self::assertSame(2222, $result[0]->getBar());
1627-
}
1628-
1629-
public function testNamedArgumentsConstructorInterfaceWithDefaultValue(): void
1630-
{
1631-
$result = $this
1632-
->createTestParser()
1633-
->parse('/** @NamedAnnotation(foo="baz") */');
1634-
1635-
self::assertCount(1, $result);
1636-
self::assertInstanceOf(NamedAnnotation::class, $result[0]);
1637-
self::assertSame('baz', $result[0]->getFoo());
1638-
self::assertSame(1234, $result[0]->getBar());
1639-
}
1640-
16411604
public function testNamedArgumentsConstructorAnnotation(): void
16421605
{
16431606
$result = $this
@@ -1751,31 +1714,6 @@ public function expectExceptionMessageMatches(string $regularExpression): void
17511714
}
17521715
}
17531716

1754-
/** @Annotation */
1755-
class NamedAnnotation implements NamedArgumentConstructorAnnotation
1756-
{
1757-
/** @var string */
1758-
private $foo;
1759-
/** @var int */
1760-
private $bar;
1761-
1762-
public function __construct(string $foo, int $bar = 1234)
1763-
{
1764-
$this->foo = $foo;
1765-
$this->bar = $bar;
1766-
}
1767-
1768-
public function getFoo(): string
1769-
{
1770-
return $this->foo;
1771-
}
1772-
1773-
public function getBar(): int
1774-
{
1775-
return $this->bar;
1776-
}
1777-
}
1778-
17791717
/**
17801718
* @Annotation
17811719
* @NamedArgumentConstructor

0 commit comments

Comments
 (0)