diff --git a/Controller/DocumentationController.php b/Controller/DocumentationController.php index dd28427..0450d3a 100644 --- a/Controller/DocumentationController.php +++ b/Controller/DocumentationController.php @@ -11,11 +11,9 @@ namespace Nelmio\ApiDocBundle\Controller; -use Nelmio\ApiDocBundle\ApiDocGenerator; use OpenApi\Annotations\OpenApi; use OpenApi\Annotations\Server; use Psr\Container\ContainerInterface; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -24,22 +22,8 @@ final class DocumentationController { private $generatorLocator; - /** - * @param ContainerInterface $generatorLocator - */ - public function __construct($generatorLocator) + public function __construct(ContainerInterface $generatorLocator) { - if (!$generatorLocator instanceof ContainerInterface) { - if (!$generatorLocator instanceof ApiDocGenerator) { - throw new \InvalidArgumentException(sprintf('Providing an instance of "%s" to "%s" is not supported.', get_class($generatorLocator), __METHOD__)); - } - - @trigger_error(sprintf('Providing an instance of "%s" to "%s()" is deprecated since version 3.1. Provide it an instance of "%s" instead.', ApiDocGenerator::class, __METHOD__, ContainerInterface::class), E_USER_DEPRECATED); - $generatorLocator = new ServiceLocator(['default' => function () use ($generatorLocator): ApiDocGenerator { - return $generatorLocator; - }]); - } - $this->generatorLocator = $generatorLocator; } diff --git a/Controller/SwaggerUiController.php b/Controller/SwaggerUiController.php index ebff95b..b927d00 100644 --- a/Controller/SwaggerUiController.php +++ b/Controller/SwaggerUiController.php @@ -11,11 +11,9 @@ namespace Nelmio\ApiDocBundle\Controller; -use Nelmio\ApiDocBundle\ApiDocGenerator; use OpenApi\Annotations\OpenApi; use OpenApi\Annotations\Server; use Psr\Container\ContainerInterface; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -27,26 +25,12 @@ final class SwaggerUiController private $twig; - /** - * @param ContainerInterface $generatorLocator - */ - public function __construct($generatorLocator, $twig) + public function __construct(ContainerInterface $generatorLocator, $twig) { if (!$twig instanceof \Twig_Environment && !$twig instanceof Environment) { throw new \InvalidArgumentException(sprintf('Providing an instance of "%s" as twig is not supported.', get_class($twig))); } - if (!$generatorLocator instanceof ContainerInterface) { - if (!$generatorLocator instanceof ApiDocGenerator) { - throw new \InvalidArgumentException(sprintf('Providing an instance of "%s" to "%s" is not supported.', get_class($generatorLocator), __METHOD__)); - } - - @trigger_error(sprintf('Providing an instance of "%s" to "%s()" is deprecated since version 3.1. Provide it an instance of "%s" instead.', ApiDocGenerator::class, __METHOD__, ContainerInterface::class), E_USER_DEPRECATED); - $generatorLocator = new ServiceLocator(['default' => function () use ($generatorLocator): ApiDocGenerator { - return $generatorLocator; - }]); - } - $this->generatorLocator = $generatorLocator; $this->twig = $twig; } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 1b97a9f..797b59c 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -28,24 +28,6 @@ final class Configuration implements ConfigurationInterface } $rootNode - ->beforeNormalization() - ->ifTrue(function ($v) { - return !isset($v['areas']) && isset($v['routes']); - }) - ->then(function ($v) { - $v['areas'] = $v['routes']; - unset($v['routes']); - @trigger_error('The `nelmio_api_doc.routes` config option is deprecated. Please use `nelmio_api_doc.areas` instead (just replace `routes` by `areas` in your config).', E_USER_DEPRECATED); - - return $v; - }) - ->end() - ->beforeNormalization() - ->ifTrue(function ($v) { - return isset($v['routes']); - }) - ->thenInvalid('You must not use both `nelmio_api_doc.areas` and `nelmio_api_doc.routes` config options. Please update your config to only use `nelmio_api_doc.areas`.') - ->end() ->children() ->arrayNode('documentation') ->useAttributeAsKey('key') diff --git a/Tests/Controller/ControllersTest.php b/Tests/Controller/ControllersTest.php deleted file mode 100644 index 3c83e0d..0000000 --- a/Tests/Controller/ControllersTest.php +++ /dev/null @@ -1,47 +0,0 @@ -createMock('Twig_Environment'); - } else { - $twigMock = $this->createMock('Twig\Environment'); - } - - $controller = new SwaggerUiController(new ApiDocGenerator([], []), $twigMock); - $controller(new Request()); - } - - /** - * @group legacy - * @expectedDeprecation Providing an instance of "Nelmio\ApiDocBundle\ApiDocGenerator" to "Nelmio\ApiDocBundle\Controller\DocumentationController::__construct()" is deprecated since version 3.1. Provide it an instance of "Psr\Container\ContainerInterface" instead. - */ - public function testDocumentationControllerInstanciation() - { - $controller = new DocumentationController(new ApiDocGenerator([], [])); - $controller(new Request()); - } -} diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 3a7d545..306d706 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -144,39 +144,4 @@ class ConfigurationTest extends TestCase ], ], $config['models']['names']); } - - /** - * @group legacy - */ - public function testBothAreasAndRoutes() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('You must not use both `nelmio_api_doc.areas` and `nelmio_api_doc.routes` config options. Please update your config to only use `nelmio_api_doc.areas`.'); - - $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(), [['areas' => [], 'routes' => []]]); - } - - /** - * @group legacy - * @expectedDeprecation The `nelmio_api_doc.routes` config option is deprecated. Please use `nelmio_api_doc.areas` instead (just replace `routes` by `areas` in your config). - */ - public function testDefaultConfig() - { - $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(), [['routes' => ['path_patterns' => ['/foo']]]]); - - $this->assertSame( - [ - 'default' => [ - 'path_patterns' => ['/foo'], - 'host_patterns' => [], - 'name_patterns' => [], - 'with_annotation' => false, - 'documentation' => [], - ], - ], - $config['areas'] - ); - } }