Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ parameters:
- src/Serializer/AbstractConstraintViolationListNormalizer.php
- src/Symfony/Validator/Serializer/ValidationExceptionNormalizer.php

# See https://github.com/phpstan/phpstan-symfony/issues/27
-
message: '#^Service "[^"]+" is private.$#'
path: src


# Allow extra assertions in tests: https://github.com/phpstan/phpstan-strict-rules/issues/130
- '#^Call to (static )?method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#'

Expand Down
29 changes: 0 additions & 29 deletions src/State/SerializerAwareProviderInterface.php

This file was deleted.

40 changes: 0 additions & 40 deletions src/State/SerializerAwareProviderTrait.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/Symfony/Bundle/ApiPlatformBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\AttributeFilterPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\AttributeResourcePass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\AuthenticatorManagerPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\DataProviderPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\ElasticsearchClientPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\FilterPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\GraphQlResolverPass;
Expand Down Expand Up @@ -44,7 +43,6 @@ public function build(ContainerBuilder $container): void
{
parent::build($container);

$container->addCompilerPass(new DataProviderPass());
// Run the compiler pass before the {@see ResolveInstanceofConditionalsPass} to allow autoconfiguration of generated filter definitions.
$container->addCompilerPass(new AttributeFilterPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 101);
$container->addCompilerPass(new AttributeResourcePass());
Expand Down

This file was deleted.

28 changes: 24 additions & 4 deletions tests/Fixtures/TestBundle/State/SerializableProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@

use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use ApiPlatform\State\SerializerAwareProviderInterface;
use ApiPlatform\State\SerializerAwareProviderTrait;
use Psr\Container\ContainerInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

/**
* @author Vincent Chalamon <vincentchalamon@gmail.com>
*/
class SerializableProvider implements ProviderInterface, SerializerAwareProviderInterface
readonly class SerializableProvider implements ProviderInterface, ServiceSubscriberInterface
{
use SerializerAwareProviderTrait;
public function __construct(private ContainerInterface $container)
{
}

/**
* @return array<string, string>
*/
public static function getSubscribedServices(): array
{
return ['serializer' => SerializerInterface::class];
}

/**
* {@inheritDoc}
Expand All @@ -38,4 +49,13 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
}
JSON, $operation->getClass(), 'json');
}

private function getSerializer(): SerializerInterface
{
if (!$this->container->has('serializer')) {
throw new \LogicException('The serializer service is not available. Did you forget to install symfony/serializer?');
}

return $this->container->get('serializer');
}
}
3 changes: 3 additions & 0 deletions tests/Fixtures/app/config/config_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ services:
class: 'ApiPlatform\Tests\Fixtures\TestBundle\State\SerializableProvider'
tags:
- name: 'api_platform.state_provider'
arguments:
- !service_locator
serializer: '@Symfony\Component\Serializer\SerializerInterface'

ApiPlatform\Tests\Fixtures\TestBundle\State\FakeProvider:
class: 'ApiPlatform\Tests\Fixtures\TestBundle\State\FakeProvider'
Expand Down
2 changes: 0 additions & 2 deletions tests/Symfony/Bundle/ApiPlatformBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\AttributeFilterPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\AttributeResourcePass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\AuthenticatorManagerPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\DataProviderPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\ElasticsearchClientPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\FilterPass;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\GraphQlResolverPass;
Expand All @@ -43,7 +42,6 @@ class ApiPlatformBundleTest extends TestCase
public function testBuild(): void
{
$containerProphecy = $this->prophesize(ContainerBuilder::class);
$containerProphecy->addCompilerPass(Argument::type(DataProviderPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled();
$containerProphecy->addCompilerPass(Argument::type(AttributeFilterPass::class), PassConfig::TYPE_BEFORE_OPTIMIZATION, 101)->willReturn($containerProphecy->reveal())->shouldBeCalled();
$containerProphecy->addCompilerPass(Argument::type(AttributeResourcePass::class))->shouldBeCalled()->willReturn($containerProphecy->reveal())->shouldBeCalled();
$containerProphecy->addCompilerPass(Argument::type(FilterPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled();
Expand Down
Loading