From a184cb8ef4853db21ee0be8d99f58ef8b13ccb67 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Sat, 11 Dec 2021 14:19:43 +0100 Subject: [PATCH] Fix deprecations (#1923) --- DependencyInjection/Configuration.php | 2 +- PropertyDescriber/ObjectPropertyDescriber.php | 2 +- Resources/doc/index.rst | 2 +- Tests/Functional/ArrayItemsErrorTest.php | 3 ++- Tests/Functional/BazingaFunctionalTest.php | 3 ++- Tests/Functional/JMSFunctionalTest.php | 4 +++- Tests/Functional/TestKernel.php | 6 +++--- Tests/Functional/WebTestCase.php | 3 ++- 8 files changed, 15 insertions(+), 10 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 5a4c2e3..e23380d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -16,7 +16,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; final class Configuration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('nelmio_api_doc'); diff --git a/PropertyDescriber/ObjectPropertyDescriber.php b/PropertyDescriber/ObjectPropertyDescriber.php index ef1aabc..34361d8 100644 --- a/PropertyDescriber/ObjectPropertyDescriber.php +++ b/PropertyDescriber/ObjectPropertyDescriber.php @@ -28,8 +28,8 @@ class ObjectPropertyDescriber implements PropertyDescriberInterface, ModelRegist false, $types[0]->getClassName(), $types[0]->isCollection(), - $types[0]->getCollectionKeyType(), // BC layer for symfony < 5.3 + method_exists($types[0], 'getCollectionKeyTypes') ? $types[0]->getCollectionKeyTypes() : $types[0]->getCollectionKeyType(), method_exists($types[0], 'getCollectionValueTypes') ? ($types[0]->getCollectionValueTypes()[0] ?? null) : $types[0]->getCollectionValueType() diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 9daa3ea..95e2944 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -39,7 +39,7 @@ Open a command console, enter your project directory and execute the following c class AppKernel extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { $bundles = [ // ... diff --git a/Tests/Functional/ArrayItemsErrorTest.php b/Tests/Functional/ArrayItemsErrorTest.php index 57a0ea0..cfeaa6d 100644 --- a/Tests/Functional/ArrayItemsErrorTest.php +++ b/Tests/Functional/ArrayItemsErrorTest.php @@ -12,6 +12,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; use Nelmio\ApiDocBundle\Exception\UndocumentedArrayItemsException; +use Symfony\Component\HttpKernel\KernelInterface; class ArrayItemsErrorTest extends WebTestCase { @@ -30,7 +31,7 @@ class ArrayItemsErrorTest extends WebTestCase $this->getOpenApiDefinition(); } - protected static function createKernel(array $options = []) + protected static function createKernel(array $options = []): KernelInterface { return new TestKernel(TestKernel::ERROR_ARRAY_ITEMS); } diff --git a/Tests/Functional/BazingaFunctionalTest.php b/Tests/Functional/BazingaFunctionalTest.php index ff46e8d..d7f9146 100644 --- a/Tests/Functional/BazingaFunctionalTest.php +++ b/Tests/Functional/BazingaFunctionalTest.php @@ -12,6 +12,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; use Hateoas\Configuration\Embedded; +use Symfony\Component\HttpKernel\KernelInterface; class BazingaFunctionalTest extends WebTestCase { @@ -123,7 +124,7 @@ class BazingaFunctionalTest extends WebTestCase ], json_decode($this->getModel('BazingaUserTyped')->toJson(), true)); } - protected static function createKernel(array $options = []) + protected static function createKernel(array $options = []): KernelInterface { return new TestKernel(TestKernel::USE_JMS | TestKernel::USE_BAZINGA); } diff --git a/Tests/Functional/JMSFunctionalTest.php b/Tests/Functional/JMSFunctionalTest.php index 221800d..9bcc3c3 100644 --- a/Tests/Functional/JMSFunctionalTest.php +++ b/Tests/Functional/JMSFunctionalTest.php @@ -11,6 +11,8 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; +use Symfony\Component\HttpKernel\KernelInterface; + class JMSFunctionalTest extends WebTestCase { protected function setUp(): void @@ -333,7 +335,7 @@ class JMSFunctionalTest extends WebTestCase ], json_decode($this->getModel('JMSNamingStrategyConstraints')->toJson(), true)); } - protected static function createKernel(array $options = []) + protected static function createKernel(array $options = []): KernelInterface { return new TestKernel(TestKernel::USE_JMS); } diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index 5de564d..3f3f668 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -53,7 +53,7 @@ class TestKernel extends Kernel /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { $bundles = [ new FrameworkBundle(), @@ -275,7 +275,7 @@ class TestKernel extends Kernel /** * {@inheritdoc} */ - public function getCacheDir() + public function getCacheDir(): string { return parent::getCacheDir().'/'.$this->flags; } @@ -283,7 +283,7 @@ class TestKernel extends Kernel /** * {@inheritdoc} */ - public function getLogDir() + public function getLogDir(): string { return parent::getLogDir().'/'.$this->flags; } diff --git a/Tests/Functional/WebTestCase.php b/Tests/Functional/WebTestCase.php index 2268de2..e8a5da4 100644 --- a/Tests/Functional/WebTestCase.php +++ b/Tests/Functional/WebTestCase.php @@ -13,10 +13,11 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; use OpenApi\Annotations as OA; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase; +use Symfony\Component\HttpKernel\KernelInterface; class WebTestCase extends BaseWebTestCase { - protected static function createKernel(array $options = []) + protected static function createKernel(array $options = []): KernelInterface { return new TestKernel(); }