Skip to content

Commit d03f5d1

Browse files
committed
attempt
1 parent 146c1fd commit d03f5d1

File tree

5 files changed

+14
-32
lines changed

5 files changed

+14
-32
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ parameters:
8282
message: '#Service "test" is not registered in the container\.#'
8383
path: src/GraphQl/Tests/Type/TypesContainerTest.php
8484

85-
# Expected, due to optional interfaces
86-
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::denormalize\(\) invoked with (2|3|4) parameters, 1 required\.#'
87-
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with (2|3|4) parameters, 1 required\.#'
88-
8985
# Expected, due to backward compatibility
9086
- '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#'
9187
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#'
@@ -97,16 +93,6 @@ parameters:
9793
- "#Call to function method_exists\\(\\) with Symfony\\\\Component\\\\Serializer\\\\Normalizer\\\\NormalizerInterface and 'getSupportedTypes' will always evaluate to true\\.#"
9894
- "#Call to function method_exists\\(\\) with Doctrine\\\\ODM\\\\MongoDB\\\\Configuration and 'setMetadataCache' will always evaluate to true\\.#"
9995
- "#Call to function method_exists\\(\\) with Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\|Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata and 'isChangeTrackingDef…' will always evaluate to true\\.#"
100-
-
101-
message: '#Instanceof between Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface and Symfony\\Component\\Serializer\\NameConverter\\MetadataAwareNameConverter will always evaluate to false\.#'
102-
paths:
103-
- src/GraphQl/Serializer/SerializerContextBuilder.php
104-
- src/GraphQl/Type/FieldsBuilder.php
105-
-
106-
message: '#Instanceof between Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface\|null and Symfony\\Component\\Serializer\\NameConverter\\MetadataAwareNameConverter will always evaluate to false\.#'
107-
paths:
108-
- src/Serializer/AbstractConstraintViolationListNormalizer.php
109-
- src/Symfony/Validator/Serializer/ValidationExceptionNormalizer.php
11096

11197
# See https://github.com/phpstan/phpstan-symfony/issues/27
11298
-

src/Metadata/Property/Factory/PropertyInfoPropertyMetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function create(string $resourceClass, string $property, array $options =
4949
// TODO: remove in 5.x
5050
if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
5151
if (!$propertyMetadata->getBuiltinTypes()) {
52-
$types = $this->propertyInfo->getTypes($resourceClass, $property, $options) ?? [];
52+
$types = $this->propertyInfo->getTypes($resourceClass, $property, $options) ?? []; // @phpstan-ignore-line
5353

5454
foreach ($types as $i => $type) {
5555
// Temp fix for https://github.com/symfony/symfony/pull/52699

src/Serializer/Mapping/Loader/PropertyMetadataLoader.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
6464
$attribute = $a->newInstance();
6565
if ($attribute instanceof DiscriminatorMap) {
6666
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
67-
$attribute->getTypeProperty(),
68-
$attribute->getMapping()
67+
$attribute->typeProperty,
68+
$attribute->mapping
6969
));
7070
continue;
7171
}
7272

7373
if ($attribute instanceof Groups) {
74-
$classGroups = $attribute->getGroups();
74+
$classGroups = $attribute->groups;
7575

7676
continue;
7777
}
@@ -116,16 +116,16 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
116116
// This code is adapted from Symfony\Component\Serializer\Mapping\Loader\AttributeLoader
117117
foreach ($attributes[$propertyName] as $attr) {
118118
if ($attr instanceof Groups) {
119-
foreach ($attr->getGroups() as $group) {
119+
foreach ($attr->groups as $group) {
120120
$attributeMetadata->addGroup($group);
121121
}
122122
continue;
123123
}
124124

125125
match (true) {
126-
$attr instanceof MaxDepth => $attributeMetadata->setMaxDepth($attr->getMaxDepth()),
127-
$attr instanceof SerializedName => $attributeMetadata->setSerializedName($attr->getSerializedName()),
128-
$attr instanceof SerializedPath => $attributeMetadata->setSerializedPath($attr->getSerializedPath()),
126+
$attr instanceof MaxDepth => $attributeMetadata->setMaxDepth($attr->maxDepth),
127+
$attr instanceof SerializedName => $attributeMetadata->setSerializedName($attr->serializedName),
128+
$attr instanceof SerializedPath => $attributeMetadata->setSerializedPath($attr->serializedPath),
129129
$attr instanceof Ignore => $attributeMetadata->setIgnore(true),
130130
$attr instanceof Context => $this->setAttributeContextsForGroups($attr, $attributeMetadata),
131131
default => null,
@@ -148,10 +148,10 @@ private function addAttributeMetadata(ApiProperty $attribute, array &$attributes
148148

149149
private function setAttributeContextsForGroups(Context $annotation, AttributeMetadataInterface $attributeMetadata): void
150150
{
151-
$context = $annotation->getContext();
152-
$groups = $annotation->getGroups();
153-
$normalizationContext = $annotation->getNormalizationContext();
154-
$denormalizationContext = $annotation->getDenormalizationContext();
151+
$context = $annotation->context;
152+
$groups = $annotation->groups;
153+
$normalizationContext = $annotation->normalizationContext;
154+
$denormalizationContext = $annotation->denormalizationContext;
155155
if ($normalizationContext || $context) {
156156
$attributeMetadata->setNormalizationContextForGroups($normalizationContext ?: $context, $groups);
157157
}

tests/Fixtures/TestBundle/Entity/DummyCarColor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use ApiPlatform\Metadata\ApiFilter;
1818
use ApiPlatform\Metadata\ApiResource;
1919
use Doctrine\ORM\Mapping as ORM;
20-
use Symfony\Component\Serializer\Attributes as Serializer;
20+
use Symfony\Component\Serializer\Attribute\Groups;
2121
use Symfony\Component\Validator\Constraints as Assert;
2222

2323
#[ApiResource]
@@ -38,7 +38,7 @@ class DummyCarColor
3838
#[ApiFilter(SearchFilter::class)]
3939
#[ORM\Column(nullable: false)]
4040
#[Assert\NotBlank]
41-
#[Serializer\Groups(['colors'])]
41+
#[Groups(['colors'])]
4242
private string $prop = '';
4343

4444
public function getId(): ?int

tests/Fixtures/TestBundle/Entity/UidIdentified.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use ApiPlatform\Metadata\ApiProperty;
1717
use ApiPlatform\Metadata\Put;
1818
use Doctrine\ORM\Mapping as ORM;
19-
use Symfony\Component\Serializer\Attribute\Ignore as LegacyIgnore;
20-
use Symfony\Component\Serializer\Attribute\SerializedName as LegacySerializedName;
2119
use Symfony\Component\Serializer\Attribute\Ignore;
2220
use Symfony\Component\Serializer\Attribute\SerializedName;
2321
use Symfony\Component\Uid\Uuid;
@@ -40,13 +38,11 @@ class UidIdentified
4038
#[ORM\GeneratedValue]
4139
#[ApiProperty(identifier: false)]
4240
#[Ignore]
43-
#[LegacyIgnore]
4441
private ?int $id = null;
4542

4643
#[ORM\Column(type: 'symfony_uuid', unique: true, nullable: false)]
4744
#[ApiProperty(identifier: true)]
4845
#[SerializedName('id')]
49-
#[LegacySerializedName('id')]
5046
private ?Uuid $uuid = null;
5147

5248
/**

0 commit comments

Comments
 (0)