8000 minor #52159 [Serializer] Replace "annotation" wording by "attribute"… · symfony/symfony@2f247cf · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f247cf

Browse files
minor #52159 [Serializer] Replace "annotation" wording by "attribute" (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [Serializer] Replace "annotation" wording by "attribute" | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT Commits ------- 8cdac69 [Serializer] Replace "annotation" wording by "attribute"
2 parents 7402279 + 8cdac69 commit 2f247cf

17 files changed

+24
-27
lines changed

src/Symfony/Component/Routing/Loader/AttributeClassLoader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public function setRouteAnnotationClass(string $class)
109109
}
110110

111111
/**
112-
* Loads from annotations from a class.
113-
*
114112
* @throws \InvalidArgumentException When route can't be parsed
115113
*/
116114
public function load(mixed $class, string $type = null): RouteCollection
@@ -121,7 +119,7 @@ public function load(mixed $class, string $type = null): RouteCollection
121119

122120
$class = new \ReflectionClass($class);
123121
if ($class->isAbstract()) {
124-
throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName()));
122+
throw new \InvalidArgumentException(sprintf('Attributes from class "%s" cannot be read as it is abstract.', $class->getName()));
125123
}
126124

127125
$this->hasDeprecatedAnnotations = false;

src/Symfony/Component/Routing/Loader/AttributeFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AttributeFileLoader extends FileLoader
3030
public function __construct(FileLocatorInterface $locator, AttributeClassLoader $loader)
3131
{
3232
if (!\function_exists('token_get_all')) {
33-
throw new \LogicException('The Tokenizer extension is required for the routing annotation loaders.');
33+
throw new \LogicException('The Tokenizer extension is required for the routing attribute loader.');
3434
}
3535

3636
parent::__construct($locator);
@@ -39,7 +39,7 @@ public function __construct(FileLocatorInterface $locator, AttributeClassLoader
3939
}
4040

4141
/**
42-
* Loads from annotations from a file.
42+
* Loads from attributes from a file.
4343
*
4444
* @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed
4545
*/

src/Symfony/Component/Serializer/Annotation/Context.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public function __construct(
3939
string|array $groups = [],
4040
) {
4141
if (!$context && !$normalizationContext && !$denormalizationContext) {
42-
throw new InvalidArgumentException(sprintf('At least one of the "context", "normalizationContext", or "denormalizationContext" options of annotation "%s" must be provided as a non-empty array.', static::class));
42+
throw new InvalidArgumentException(sprintf('At least one of the "context", "normalizationContext", or "denormalizationContext" options must be provided as a non-empty array to "%s".', static::class));
4343
}
4444

4545
$this->groups = (array) $groups;
4646

4747
foreach ($this->groups as $group) {
4848
if (!\is_string($group)) {
49-
throw new InvalidArgumentException(sprintf('Parameter "groups" of annotation "%s" must be a string or an array of strings. Got "%s".', static::class, get_debug_type($group)));
49+
throw new InvalidArgumentException(sprintf('Parameter "groups" given to "%s" must be a string or an array of strings, "%s" given.', static::class, get_debug_type($group)));
5050
}
5151
}
5252
}

src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public function __construct(
3030
private readonly array $mapping,
3131
) {
3232
if (empty($typeProperty)) {
33-
throw new InvalidArgumentException(sprintf('Parameter "typeProperty" of annotation "%s" cannot be empty.', static::class));
33+
throw new InvalidArgumentException(sprintf('Parameter "typeProperty" given to "%s" cannot be empty.', static::class));
3434
}
3535

3636
if (empty($mapping)) {
37-
throw new InvalidArgumentException(sprintf('Parameter "mapping" of annotation "%s" cannot be empty.', static::class));
37+
throw new InvalidArgumentException(sprintf('Parameter "mapping" given to "%s" cannot be empty.', static::class));
3838
}
3939
}
4040

src/Symfony/Component/Serializer/Annotation/Groups.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public function __construct(string|array $groups)
3838
$this->groups = (array) $groups;
3939

4040
if (!$this->groups) {
41-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', static::class));
41+
throw new InvalidArgumentException(sprintf('Parameter given to "%s" cannot be empty.', static::class));
4242
}
4343

4444
foreach ($this->groups as $group) {
4545
if (!\is_string($group) || '' === $group) {
46-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of non-empty strings.', static::class));
46+
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a string or an array of non-empty strings.', static::class));
4747
}
4848
}
4949
}

src/Symfony/Component/Serializer/Annotation/MaxDepth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MaxDepth
2828
public function __construct(private readonly int $maxDepth)
2929
{
3030
if ($maxDepth <= 0) {
31-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a positive integer.', static::class));
31+
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a positive integer.', static::class));
3232
}
3333
}
3434

src/Symfony/Component/Serializer/Annotation/SerializedName.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class SerializedName
2828
public function __construct(private readonly string $serializedName)
2929
{
3030
if ('' === $serializedName) {
31-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a non-empty string.', self::class));
31+
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a non-empty string.', self::class));
3232
}
3333
}
3434

src/Symfony/Component/Serializer/Annotation/SerializedPath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(string $serializedPath)
3434
try {
3535
$this->serializedPath = new PropertyPath($serializedPath);
3636
} catch (InvalidPropertyPathException $pathException) {
37-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a valid property path.', self::class));
37+
throw new InvalidArgumentException(sprintf('Parameter given to "%s" must be a valid property path.', self::class));
3838
}
3939
}
4040

src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private function getCacheValueForNormalization(string $propertyName, string $cla
8080
}
8181

8282
if (null !== $attributesMetadata[$propertyName]->getSerializedName() && null !== $attributesMetadata[$propertyName]->getSerializedPath()) {
83-
throw new LogicException(sprintf('Found SerializedName and SerializedPath annotations on property "%s" of class "%s".', $propertyName, $class));
83+
throw new LogicException(sprintf('Found SerializedName and SerializedPath attributes on property "%s" of class "%s".', $propertyName, $class));
8484
}
8585

8686
return $attributesMetadata[$propertyName]->getSerializedName() ?? null;
@@ -124,7 +124,7 @@ private function getCacheValueForAttributesMetadata(string $class, array $contex
124124
}
125125

126126
if (null !== $metadata->getSerializedName() && null !== $metadata->getSerializedPath()) {
127-
throw new LogicException(sprintf('Found SerializedName and SerializedPath annotations on property "%s" of class "%s".', $name, $class));
127+
throw new LogicException(sprintf('Found SerializedName and SerializedPath attributes on property "%s" of class "%s".', $name, $class));
128128
}
129129

130130
$metadataGroups = $metadata->getGroups();

src/Symfony/Component/Serializer/Normalizer/AbstractObjectN 2851 ormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
349349
$notConverted = $attribute;
350350
$attribute = $this->nameConverter->denormalize($attribute, $resolvedClass, $format, $context);
351351
if (isset($nestedData[$notConverted]) && !isset($originalNestedData[$attribute])) {
352-
throw new LogicException(sprintf('Duplicate values for key "%s" found. One value is set via the SerializedPath annotation: "%s", the other one is set via the SerializedName annotation: "%s".', $notConverted, implode('->', $nestedAttributes[$notConverted]->getElements()), $attribute));
352+
throw new LogicException(sprintf('Duplicate values for key "%s" found. One value is set via the SerializedPath attribute: "%s", the other one is set via the SerializedName attribute: "%s".', $notConverted, implode('->', $nestedAttributes[$notConverted]->getElements()), $attribute));
353353
}
354354
}
355355

@@ -756,7 +756,7 @@ private function isUninitializedValueError(\Error $e): bool
756756
}
757757

758758
/**
759-
* Returns all attributes with a SerializedPath annotation and the respective path.
759+
* Returns all attributes with a SerializedPath attribute and the respective path.
760760
*/
761761
private function getNestedAttributes(string $class): array
762762
{

src/Symfony/Component/Serializer/Tests/Annotation/ContextTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ protected function setUp(): void
3232
public function testThrowsOnEmptyContext()
3333
{
3434
$this->expectException(InvalidArgumentException::class);
35-
$this->expectExceptionMessage('At least one of the "context", "normalizationContext", or "denormalizationContext" options of annotation "Symfony\Component\Serializer\Annotation\Context" must be provided as a non-empty array.');
35+
$this->expectExceptionMessage('At least one of the "context", "normalizationContext", or "denormalizationContext" options must be provided as a non-empty array to "Symfony\Component\Serializer\Annotation\Context".');
3636

3737
new Context();
3838
}
3939

4040
public function testInvalidGroupOption()
4141
{
4242
$this->expectException(InvalidArgumentException::class);
43-
$this->expectExceptionMessage(sprintf('Parameter "groups" of annotation "%s" must be a string or an array of strings. Got "stdClass"', Context::class));
43+
$this->expectExceptionMessage(sprintf('Parameter "groups" given to "%s" must be a string or an array of strings, "stdClass" given', Context::class));
4444

4545
new Context(context: ['foo' => 'bar'], groups: ['fine', new \stdClass()]);
4646
}

src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MaxDepthTest extends TestCase
2727
public function testNotAnIntMaxDepthParameter(int $value)
2828
{
2929
$this->expectException(InvalidArgumentException::class);
30-
$this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.');
30+
$this->expectExceptionMessage('Parameter given to "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.');
3131
new MaxDepth($value);
3232
}
3333

src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SerializedNameTest extends TestCase
2323
public function testNotAStringSerializedNameParameter()
2424
{
2525
$this->expectException(InvalidArgumentException::class);
26-
$this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" must be a non-empty string.');
26+
$this->expectExceptionMessage('Parameter given to "Symfony\Component\Serializer\Annotation\SerializedName" must be a non-empty string.');
2727

2828
new SerializedName('');
2929
}

src/Symfony/Component/Serializer/Tests/Annotation/SerializedPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SerializedPathTest extends TestCase
2424
public function testEmptyStringSerializedPathParameter()
2525
{
2626
$this->expectException(InvalidArgumentException::class);
27-
$this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedPath" must be a valid property path.');
27+
$this->expectExceptionMessage('Parameter given to "Symfony\Component\Serializer\Annotation\SerializedPath" must be a valid property path.');
2828

2929
new SerializedPath('');
3030
}

src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function testDenormalizeWithNestedPathAndName()
168168
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
169169
$nameConverter = new MetadataAwareNameConverter($classMetadataFactory);
170170
$this->expectException(LogicException::class);
171-
$this->expectExceptionMessage('Found SerializedName and SerializedPath annotations on property "foo" of class "Symfony\Component\Serializer\Tests\NameConverter\NestedPathAndName".');
171+
$this->expectExceptionMessage('Found SerializedName and SerializedPath attributes on property "foo" of class "Symfony\Component\Serializer\Tests\NameConverter\NestedPathAndName".');
172172
$nameConverter->denormalize('foo', NestedPathAndName::class);
173173
}
174174

@@ -177,7 +177,7 @@ public function testNormalizeWithNestedPathAndName()
177177
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
178178
$nameConverter = new MetadataAwareNameConverter($classMetadataFactory);
179179
$this->expectException(LogicException::class);
180-
$this->expectExceptionMessage('Found SerializedName and SerializedPath annotations on property "foo" of class "Symfony\Component\Serializer\Tests\NameConverter\NestedPathAndName".');
180+
$this->expectExceptionMessage('Found SerializedName and SerializedPath attributes on property "foo" of class "Symfony\Component\Serializer\Tests\NameConverter\NestedPathAndName".');
181181
$nameConverter->normalize('foo', NestedPathAndName::class);
182182
}
183183
}

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function testDenormalizeWithNestedAttributes()
187187
public function testDenormalizeWithNestedAttributesDuplicateKeys()
188188
{
189189
$this->expectException(LogicException::class);
190-
$this->expectExceptionMessage('Duplicate values for key "quux" found. One value is set via the SerializedPath annotation: "one->four", the other one is set via the SerializedName annotation: "notquux".');
190+
$this->expectExceptionMessage('Duplicate values for key "quux" found. One value is set via the SerializedPath attribute: "one->four", the other one is set via the SerializedName attribute: "notquux".');
191191
$normalizer = new AbstractObjectNormalizerWithMetadata();
192192
$data = [
193193
'one' => [

src/Symfony/Component/Validator/Constraints/GroupSequence.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class GroupSequence
8383
*/
8484
public function __construct(array $groups)
8585
{
86-
// Support for Doctrine annotations
8786
$this->groups = $groups['value'] ?? $groups;
8887
}
8988
}

0 commit comments

Comments
 (0)
0