From d4ccafddda8498b6d5ba0cb4211adc2eb1fc879c Mon Sep 17 00:00:00 2001 From: Ankit Pathak Date: Fri, 26 May 2023 10:07:35 +0530 Subject: [PATCH 1/2] Issue-3362322: PHP 8.2 deprecation fixes. --- .../{RequestTestNull.php => RequestNullTest.php} | 16 +--------------- tests/src/Functional/RequestTestBase.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 19 deletions(-) rename tests/src/Functional/{RequestTestNull.php => RequestNullTest.php} (78%) diff --git a/tests/src/Functional/RequestTestNull.php b/tests/src/Functional/RequestNullTest.php similarity index 78% rename from tests/src/Functional/RequestTestNull.php rename to tests/src/Functional/RequestNullTest.php index 1763338..9c49201 100644 --- a/tests/src/Functional/RequestTestNull.php +++ b/tests/src/Functional/RequestNullTest.php @@ -7,27 +7,13 @@ namespace Drupal\Tests\openapi\Functional; * * @group openapi */ -final class RequestTestNull extends RequestTestBase { +final class RequestNullTest extends RequestTestBase { /** * The API module being tested. */ const API_MODULE = 'null'; - /** - * {@inheritdoc} - */ - public static $modules = [ - 'user', - 'field', - 'filter', - 'text', - 'taxonomy', - 'serialization', - 'openapi', - 'openapi_test', - ]; - /** * Tests OpenAPI requests. * diff --git a/tests/src/Functional/RequestTestBase.php b/tests/src/Functional/RequestTestBase.php index 1db961b..f2e9fa0 100644 --- a/tests/src/Functional/RequestTestBase.php +++ b/tests/src/Functional/RequestTestBase.php @@ -20,8 +20,9 @@ abstract class RequestTestBase extends BrowserTestBase { /** * Set to TRUE to run this test to generate expectation files. - * * The test will be marked as a fail when generating test files. + * + * @var bool */ protected static $generateExpectationFiles = FALSE; @@ -38,6 +39,11 @@ abstract class RequestTestBase extends BrowserTestBase { 'paths' => 'paths', ]; + /** + * List of entity bundles for test. + * + * @var array + */ protected static $entityTestBundles = [ "taxonomy_term" => [ "camelids", @@ -54,7 +60,7 @@ abstract class RequestTestBase extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'user', 'field', 'filter', @@ -244,7 +250,7 @@ abstract class RequestTestBase extends BrowserTestBase { // CSRF Token will never have an auth collector, all others shoud. $this->assertTrue(array_key_exists($definition_id, $auth_providers), 'Security definition ' . $definition_id . ' not an auth collector.'); } - $this->assertTrue(in_array($definition['type'], $supported_security_types), 'Security definition schema ' . $definition_id . ' has invalid type '. $definition['type']); + $this->assertTrue(in_array($definition['type'], $supported_security_types), 'Security definition schema ' . $definition_id . ' has invalid type ' . $definition['type']); } // Test paths for valid tags, schema, security, and definitions. @@ -375,7 +381,7 @@ abstract class RequestTestBase extends BrowserTestBase { * The base path. */ private function getBasePath() { - $path = rtrim(parse_url($this->baseUrl, PHP_URL_PATH), '/'); + $path = rtrim((string) parse_url($this->baseUrl, PHP_URL_PATH), '/'); // OpenAPI spec states that the base path must start with a '/'. if (strlen($path) == 0) { -- GitLab From bd284519c321f720a3fc8287637d73af3c2bd547 Mon Sep 17 00:00:00 2001 From: Vova Vavryniuk Date: Sat, 25 Nov 2023 15:56:18 +0200 Subject: [PATCH 2/2] Issue #3362322: PHP 8.2 Deprecations. Fixed "Deprecated: Creation of dynamic property Drupal\openapi\Controller\OpenApiListController::$openapiUiManager is deprecated" warning. --- src/Controller/OpenApiListController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Controller/OpenApiListController.php b/src/Controller/OpenApiListController.php index a023e84..57528e4 100644 --- a/src/Controller/OpenApiListController.php +++ b/src/Controller/OpenApiListController.php @@ -19,12 +19,19 @@ class OpenApiListController extends ControllerBase { */ public $openapiGeneratorManager; + /** + * UI library plugin manager instance. NULL if the module is not enabled. + * + * @var \Drupal\Component\Plugin\PluginManagerInterface|null + */ + private ?PluginManagerInterface $openapiUiManager; + /** * Creates a new OpenApiListController. * * @param \Drupal\Component\Plugin\PluginManagerInterface $openapi_generator_manager * The current openapi generator plugin manager instance. - * @param \Drupal\Component\Plugin\PluginManagerInterface $openapi_ui_manager + * @param ?\Drupal\Component\Plugin\PluginManagerInterface $openapi_ui_manager * ui library plugin manager instance. NULL if the module is not enabled. */ public function __construct(PluginManagerInterface $openapi_generator_manager, PluginManagerInterface $openapi_ui_manager = NULL) { -- GitLab