diff --git a/phpstan.neon.dist b/phpstan.neon.dist index ee3f9221f4..cf6d06c07f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -85,7 +85,6 @@ parameters: # Expected, due to backward compatibility - '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#' - - "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\PropertyInfo\\\\\\\\PropertyInfoExtractor' and 'getType' will always evaluate to true\\.#" - "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\HttpFoundation\\\\\\\\Request' and 'getContentTypeFormat' will always evaluate to true\\.#" - '#Call to an undefined method Symfony\\Component\\HttpFoundation\\Request::getContentType\(\)\.#' - "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\Serializer\\\\\\\\Serializer' and 'getSupportedTypes' will always evaluate to true\\.#" diff --git a/src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php b/src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php index 901b7ed7ef..7cba33c90b 100644 --- a/src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php +++ b/src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php @@ -25,7 +25,6 @@ use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; use ApiPlatform\Metadata\ResourceClassResolverInterface; use PHPUnit\Framework\TestCase; -use Symfony\Component\PropertyInfo\PropertyInfoExtractor; use Symfony\Component\TypeInfo\Type; class SchemaPropertyMetadataFactoryTest extends TestCase @@ -88,10 +87,6 @@ public function testWithCustomOpenApiContextWithoutTypeDefinition(): void public function testUnionTypeAnyOfIsArray(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); $apiProperty = new ApiProperty(nativeType: Type::union(Type::string(), Type::int())); $decorated = $this->createMock(PropertyMetadataFactoryInterface::class); @@ -115,10 +110,6 @@ public function testUnionTypeAnyOfIsArray(): void */ public function testRelationWithGenIdFalseIsEmbeddedInOutputSchema(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); $resourceClassResolver->method('isResourceClass')->willReturn(true); @@ -143,10 +134,6 @@ public function testRelationWithGenIdFalseIsEmbeddedInOutputSchema(): void */ public function testRelationOnNonResourceParentFollowsReadableLinkInOutputSchema(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); // the parent (DummyWithEnum) is not a resource, the related class (Dummy) is $resourceClassResolver->method('isResourceClass')->willReturnCallback(static fn (string $class): bool => Dummy::class === $class); @@ -170,10 +157,6 @@ public function testRelationOnNonResourceParentFollowsReadableLinkInOutputSchema */ public function testNonResourceRelationOnNonResourceParentIsEmbeddedInOutputSchema(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); // neither the parent nor the property type is a resource $resourceClassResolver->method('isResourceClass')->willReturn(false); @@ -195,10 +178,6 @@ public function testNonResourceRelationOnNonResourceParentIsEmbeddedInOutputSche */ public function testRelationOnResourceParentStaysIriReference(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); // both the parent and the related class are resources $resourceClassResolver->method('isResourceClass')->willReturn(true); @@ -216,10 +195,6 @@ public function testRelationOnResourceParentStaysIriReference(): void public function testMixed(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); $apiProperty = new ApiProperty(nativeType: Type::mixed()); $decorated = $this->createMock(PropertyMetadataFactoryInterface::class); diff --git a/src/JsonSchema/Tests/SchemaFactoryTest.php b/src/JsonSchema/Tests/SchemaFactoryTest.php index d61a8adf6a..2699a588c0 100644 --- a/src/JsonSchema/Tests/SchemaFactoryTest.php +++ b/src/JsonSchema/Tests/SchemaFactoryTest.php @@ -41,7 +41,6 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use Symfony\Component\PropertyInfo\PropertyInfoExtractor; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\TypeInfo\Type; @@ -51,10 +50,6 @@ class SchemaFactoryTest extends TestCase public function testBuildSchemaForNonResourceClass(): void { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class); $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class); @@ -599,10 +594,6 @@ public function testBuildSchemaKeepsPropertyMetadataAlongsideAnIntersectionOfRef */ private function buildPropertiesWithReference(string $propertyName, ApiProperty $propertyMetadata): array { - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true - $this->markTestSkipped('This test only supports type-info component'); - } - $propertyNameCollectionFactory = $this->createStub(PropertyNameCollectionFactoryInterface::class); $propertyNameCollectionFactory->method('create')->willReturnCallback( static fn (string $class): PropertyNameCollection => new PropertyNameCollection( diff --git a/tests/Functional/UnionIriCollectionTest.php b/tests/Functional/UnionIriCollectionTest.php index b8c53720ad..25d21098b5 100644 --- a/tests/Functional/UnionIriCollectionTest.php +++ b/tests/Functional/UnionIriCollectionTest.php @@ -18,7 +18,6 @@ use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\UnionIriCollection\Container; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\UnionIriCollection\Foo; use ApiPlatform\Tests\SetupClassResourcesTrait; -use Symfony\Component\PropertyInfo\PropertyInfoExtractor; final class UnionIriCollectionTest extends ApiTestCase { @@ -36,12 +35,6 @@ public static function getResources(): array public function testDenormalizeCollectionAcceptsIriOfEachUnionMember(): void { - // The union-collection IRI guard relies on the native type; the legacy - // property-info path (< 7.1) only keeps the first collection value type. - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { - $this->markTestSkipped('Requires symfony/property-info >= 7.1 (native types).'); - } - $response = self::createClient()->request('POST', '/union_iri_collection_containers', [ 'headers' => ['Content-Type' => 'application/ld+json', 'Accept' => 'application/ld+json'], 'json' => ['attachments' => ['/union_iri_collection_foos/1', '/union_iri_collection_bars/2']], diff --git a/tests/Functional/ValidationTest.php b/tests/Functional/ValidationTest.php index 7c9f4c214a..6498f1822f 100644 --- a/tests/Functional/ValidationTest.php +++ b/tests/Functional/ValidationTest.php @@ -18,7 +18,6 @@ use ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyWithCollectDenormalizationErrors; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy; use ApiPlatform\Tests\SetupClassResourcesTrait; -use Symfony\Component\PropertyInfo\PropertyInfoExtractor; /** * Tests denormalization error collection feature. @@ -92,35 +91,19 @@ public function testPostWithDenormalizationErrorsCollected(): void $violationQux = $findViolation('qux'); $this->assertNotNull($violationQux); - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { - $this->assertSame('This value should be of type string.', $violationQux['message']); - } else { - $this->assertSame('This value should be of type null|string.', $violationQux['message']); - } + $this->assertSame('This value should be of type null|string.', $violationQux['message']); $violationFoo = $findViolation('foo'); $this->assertNotNull($violationFoo); - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { - $this->assertSame('This value should be of type bool.', $violationFoo['message']); - } else { - $this->assertSame('This value should be of type bool|null.', $violationFoo['message']); - } + $this->assertSame('This value should be of type bool|null.', $violationFoo['message']); $violationBar = $findViolation('bar'); $this->assertNotNull($violationBar); - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { - $this->assertSame('This value should be of type int.', $violationBar['message']); - } else { - $this->assertSame('This value should be of type int|null.', $violationBar['message']); - } + $this->assertSame('This value should be of type int|null.', $violationBar['message']); $violationUuid = $findViolation('uuid'); $this->assertNotNull($violationUuid); - if (!method_exists(PropertyInfoExtractor::class, 'getType')) { - $this->assertSame('This value should be of type uuid.', $violationUuid['message']); - } else { - $this->assertSame('This value should be of type uuid|null.', $violationUuid['message']); - } + $this->assertSame('This value should be of type uuid|null.', $violationUuid['message']); $this->assertArrayHasKey('hint', $violationUuid); $this->assertSame('Invalid UUID string: y', $violationUuid['hint']);