diff options
author | catch <catch@35733.no-reply.drupal.org> | 2024-06-01 10:15:22 +0100 |
---|---|---|
committer | catch <catch@35733.no-reply.drupal.org> | 2024-06-01 10:15:22 +0100 |
commit | 06aeda306c260f1b22ca5ee5e9b59361cc13ff92 (patch) | |
tree | 1a0b709e568f8162301e50027559ededf9ee9a25 /core/tests | |
parent | a62995de4249c36366a0c94fe81d9f7906b250b0 (diff) | |
download | drupal-06aeda306c260f1b22ca5ee5e9b59361cc13ff92.tar.gz drupal-06aeda306c260f1b22ca5ee5e9b59361cc13ff92.zip |
Issue #3427999 by andypost, Ayesh, bbrala: [PHP 8.4] Fix implicitly nullable type declarations
Diffstat (limited to 'core/tests')
31 files changed, 66 insertions, 66 deletions
diff --git a/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php b/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php index afdd7fcbcb5..11774331a81 100644 --- a/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php +++ b/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php @@ -547,7 +547,7 @@ abstract class BuildTestBase extends TestCase { * (optional) Relative path within the test workspace file system that will * contain the copy of the codebase. Defaults to the workspace directory. */ - public function copyCodebase(\Iterator $iterator = NULL, $working_dir = NULL) { + public function copyCodebase(?\Iterator $iterator = NULL, $working_dir = NULL) { $working_path = $this->getWorkingPath($working_dir); if ($iterator === NULL) { diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php index 96484e3c46b..2086e2783c0 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php @@ -593,7 +593,7 @@ JS; * @param int $timeout * Optional timeout in milliseconds, defaults to 10000. */ - public function statusMessageExistsAfterWait(string $type = NULL, int $timeout = 10000): void { + public function statusMessageExistsAfterWait(?string $type = NULL, int $timeout = 10000): void { $selector = $this->buildJavascriptStatusMessageSelector(NULL, $type); $status_message_element = $this->waitForElement('xpath', $selector, $timeout); if ($type) { @@ -615,7 +615,7 @@ JS; * @param int $timeout * Optional timeout in milliseconds, defaults to 10000. */ - public function statusMessageNotExistsAfterWait(string $type = NULL, int $timeout = 10000): void { + public function statusMessageNotExistsAfterWait(?string $type = NULL, int $timeout = 10000): void { $selector = $this->buildJavascriptStatusMessageSelector(NULL, $type); $status_message_element = $this->waitForElement('xpath', $selector, $timeout); if ($type) { @@ -637,7 +637,7 @@ JS; * @param int $timeout * Optional timeout in milliseconds, defaults to 10000. */ - public function statusMessageContainsAfterWait(string $message, string $type = NULL, int $timeout = 10000): void { + public function statusMessageContainsAfterWait(string $message, ?string $type = NULL, int $timeout = 10000): void { $selector = $this->buildJavascriptStatusMessageSelector($message, $type); $status_message_element = $this->waitForElement('xpath', $selector, $timeout); if ($type) { @@ -661,7 +661,7 @@ JS; * @param int $timeout * Optional timeout in milliseconds, defaults to 10000. */ - public function statusMessageNotContainsAfterWait(string $message, string $type = NULL, int $timeout = 10000): void { + public function statusMessageNotContainsAfterWait(string $message, ?string $type = NULL, int $timeout = 10000): void { $selector = $this->buildJavascriptStatusMessageSelector($message, $type); $status_message_element = $this->waitForElement('xpath', $selector, $timeout); if ($type) { @@ -691,7 +691,7 @@ JS; * @throws \InvalidArgumentException * Thrown when $type is not an allowed type. */ - private function buildJavascriptStatusMessageSelector(string $message = NULL, string $type = NULL): string { + private function buildJavascriptStatusMessageSelector(?string $message = NULL, ?string $type = NULL): string { $allowed_types = [ 'status', 'error', diff --git a/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php b/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php index 470596a8751..dd0fdbd9614 100644 --- a/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php +++ b/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php @@ -130,7 +130,7 @@ class AssetOptimizationTest extends BrowserTestBase { * @param string|null $content_type * The expected content type, or NULL to skip checking. */ - protected function assertAggregate(string $url, bool $from_php = TRUE, string $content_type = NULL): void { + protected function assertAggregate(string $url, bool $from_php = TRUE, ?string $content_type = NULL): void { $url = $this->getAbsoluteUrl($url); if (!stripos($url, $this->fileAssetsPath) !== FALSE) { return; diff --git a/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php index 3d057a79319..9fd06a29d39 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php @@ -306,7 +306,7 @@ class LibraryDiscoveryIntegrationTest extends KernelTestBase { * * @internal */ - protected function assertAssetInLibrary(string $asset, string $extension, string $library_name, string $sub_key, string $message = NULL): void { + protected function assertAssetInLibrary(string $asset, string $extension, string $library_name, string $sub_key, ?string $message = NULL): void { if (!isset($message)) { $message = sprintf('Asset %s found in library "%s/%s"', $asset, $extension, $library_name); } @@ -335,7 +335,7 @@ class LibraryDiscoveryIntegrationTest extends KernelTestBase { * * @internal */ - protected function assertNoAssetInLibrary(string $asset, string $extension, string $library_name, string $sub_key, string $message = NULL): void { + protected function assertNoAssetInLibrary(string $asset, string $extension, string $library_name, string $sub_key, ?string $message = NULL): void { if (!isset($message)) { $message = sprintf('Asset %s not found in library "%s/%s"', $asset, $extension, $library_name); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php index 3c520012d27..d8f410aca2b 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php @@ -53,7 +53,7 @@ abstract class DriverSpecificSchemaTestBase extends DriverSpecificKernelTestBase * @param string|null $column * Optional column to test. */ - abstract public function checkSchemaComment(string $description, string $table, string $column = NULL): void; + abstract public function checkSchemaComment(string $description, string $table, ?string $column = NULL): void; /** * Tests inserting data into an existing table. diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php index 609fda1bf2d..6fd3182ea27 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php @@ -492,7 +492,7 @@ class DriverSpecificTransactionTestBase extends DriverSpecificDatabaseTestBase { * * @internal */ - public function assertRowPresent(string $name, string $message = NULL): void { + public function assertRowPresent(string $name, ?string $message = NULL): void { $present = (boolean) $this->connection->query('SELECT 1 FROM {test} WHERE [name] = :name', [':name' => $name])->fetchField(); $this->assertTrue($present, $message ?? "Row '{$name}' should be present, but it actually does not exist."); } @@ -507,7 +507,7 @@ class DriverSpecificTransactionTestBase extends DriverSpecificDatabaseTestBase { * * @internal */ - public function assertRowAbsent(string $name, string $message = NULL): void { + public function assertRowAbsent(string $name, ?string $message = NULL): void { $present = (boolean) $this->connection->query('SELECT 1 FROM {test} WHERE [name] = :name', [':name' => $name])->fetchField(); $this->assertFalse($present, $message ?? "Row '{$name}' should be absent, but it actually exists."); } diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php index ffb9f5540df..eb8dd5f64b1 100644 --- a/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php @@ -44,7 +44,7 @@ class DatelistElementFormTest extends KernelTestBase implements FormInterface, T /** * {@inheritdoc} */ - public function datelistDateCallbackTrusted(array &$element, FormStateInterface $form_state, DrupalDateTime $date = NULL) { + public function datelistDateCallbackTrusted(array &$element, FormStateInterface $form_state, ?DrupalDateTime $date = NULL) { $element['datelistDateCallbackExecuted'] = [ '#value' => TRUE, ]; @@ -54,7 +54,7 @@ class DatelistElementFormTest extends KernelTestBase implements FormInterface, T /** * {@inheritdoc} */ - public function datelistDateCallback(array &$element, FormStateInterface $form_state, DrupalDateTime $date = NULL) { + public function datelistDateCallback(array &$element, FormStateInterface $form_state, ?DrupalDateTime $date = NULL) { $element['datelistDateCallbackExecuted'] = [ '#value' => TRUE, ]; diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php index 80689d3865a..12792adb067 100644 --- a/core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php @@ -44,7 +44,7 @@ class DatetimeElementFormTest extends KernelTestBase implements FormInterface, T /** * {@inheritdoc} */ - public function datetimeDateCallbackTrusted(array &$element, FormStateInterface $form_state, DrupalDateTime $date = NULL) { + public function datetimeDateCallbackTrusted(array &$element, FormStateInterface $form_state, ?DrupalDateTime $date = NULL) { $element['datetimeDateCallbackExecuted'] = [ '#value' => TRUE, ]; @@ -54,7 +54,7 @@ class DatetimeElementFormTest extends KernelTestBase implements FormInterface, T /** * {@inheritdoc} */ - public static function datetimeDateCallback(array &$element, FormStateInterface $form_state, DrupalDateTime $date = NULL) { + public static function datetimeDateCallback(array &$element, FormStateInterface $form_state, ?DrupalDateTime $date = NULL) { $element['datetimeDateCallbackExecuted'] = [ '#value' => TRUE, ]; @@ -64,7 +64,7 @@ class DatetimeElementFormTest extends KernelTestBase implements FormInterface, T /** * {@inheritdoc} */ - public function datetimeTimeCallbackTrusted(array &$element, FormStateInterface $form_state, DrupalDateTime $date = NULL) { + public function datetimeTimeCallbackTrusted(array &$element, FormStateInterface $form_state, ?DrupalDateTime $date = NULL) { $element['timeCallbackExecuted'] = [ '#value' => TRUE, ]; @@ -74,7 +74,7 @@ class DatetimeElementFormTest extends KernelTestBase implements FormInterface, T /** * {@inheritdoc} */ - public static function datetimeTimeCallback(array &$element, FormStateInterface $form_state, DrupalDateTime $date = NULL) { + public static function datetimeTimeCallback(array &$element, FormStateInterface $form_state, ?DrupalDateTime $date = NULL) { $element['timeCallbackExecuted'] = [ '#value' => TRUE, ]; @@ -159,7 +159,7 @@ class DatetimeElementFormTest extends KernelTestBase implements FormInterface, T * @dataProvider providerUntrusted * @group legacy */ - public function testDatetimeElementUntrustedCallbacks(string $date_callback = 'datetimeDateCallbackTrusted', string $time_callback = 'datetimeTimeCallbackTrusted', string $expected_exception = NULL) : void { + public function testDatetimeElementUntrustedCallbacks(string $date_callback = 'datetimeDateCallbackTrusted', string $time_callback = 'datetimeTimeCallbackTrusted', ?string $expected_exception = NULL) : void { if ($expected_exception) { $this->expectException(UntrustedCallbackException::class); $this->expectExceptionMessage($expected_exception); diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index e3d3b2f5d2e..37bda0da403 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -56,7 +56,7 @@ class DrupalKernelTest extends KernelTestBase { * @return \Drupal\Core\DrupalKernel * New kernel for testing. */ - protected function getTestKernel(Request $request, array $modules_enabled = NULL) { + protected function getTestKernel(Request $request, ?array $modules_enabled = NULL) { // Manually create kernel to avoid replacing settings. $class_loader = require $this->root . '/autoload.php'; $kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php index 07c9797120f..933f8566f5e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php @@ -43,7 +43,7 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase { * * @internal */ - public function assertEntityAccess(array $ops, AccessibleInterface $object, AccountInterface $account = NULL): void { + public function assertEntityAccess(array $ops, AccessibleInterface $object, ?AccountInterface $account = NULL): void { foreach ($ops as $op => $result) { $message = new FormattableMarkup("Entity access returns @result with operation '@op'.", [ '@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'), diff --git a/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php b/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php index fd7dc6c6521..582f395ebfb 100644 --- a/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php +++ b/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php @@ -92,7 +92,7 @@ class TestSiteInstallCommand extends Command { * @todo Remove and fix test to not rely on super user. * @see https://www.drupal.org/project/drupal/issues/3437620 */ - public function __construct(string $name = NULL) { + public function __construct(?string $name = NULL) { parent::__construct($name); $this->usesSuperUserAccessPolicy = TRUE; } diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 486e86def42..d0027e13743 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -526,7 +526,7 @@ abstract class BrowserTestBase extends TestCase { * @return array * Associative array of option keys and values. */ - protected function getOptions($select, Element $container = NULL) { + protected function getOptions($select, ?Element $container = NULL) { if (is_string($select)) { $select = $this->assertSession()->selectExists($select, $container); } diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php index ed1f19a6868..271bef19ca0 100644 --- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php @@ -432,7 +432,7 @@ class TestServiceMethodWithParameter { class TestServiceComplexMethod { - public function complexMethod(string $parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = []): array { + public function complexMethod(string $parameter, callable $function, ?TestServiceNoMethod $test_service = NULL, array &$elements = []): array { return []; } diff --git a/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php b/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php index c50b832aa72..ce176d26299 100644 --- a/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php +++ b/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php @@ -91,7 +91,7 @@ class PhpTransliterationTest extends TestCase { * * @dataProvider providerTestPhpTransliteration */ - public function testPhpTransliteration(string $langcode, string $original, string $expected, string $unknown_character = '?', int $max_length = NULL): void { + public function testPhpTransliteration(string $langcode, string $original, string $expected, string $unknown_character = '?', ?int $max_length = NULL): void { $transliterator_class = new PhpTransliteration(); $actual = $transliterator_class->transliterate($original, $langcode, $unknown_character, $max_length); $this->assertSame($expected, $actual); diff --git a/core/tests/Drupal/Tests/Component/Utility/XssTest.php b/core/tests/Drupal/Tests/Component/Utility/XssTest.php index 27ed10a57c5..e25dd3e5dfc 100644 --- a/core/tests/Drupal/Tests/Component/Utility/XssTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/XssTest.php @@ -68,7 +68,7 @@ class XssTest extends TestCase { * * @dataProvider providerTestFilterXssNormalized */ - public function testFilterXssNormalized($value, $expected, $message, array $allowed_tags = NULL) { + public function testFilterXssNormalized($value, $expected, $message, ?array $allowed_tags = NULL) { if ($allowed_tags === NULL) { $value = Xss::filter($value); } @@ -135,7 +135,7 @@ class XssTest extends TestCase { * * @dataProvider providerTestFilterXssNotNormalized */ - public function testFilterXssNotNormalized($value, $expected, $message, array $allowed_tags = NULL) { + public function testFilterXssNotNormalized($value, $expected, $message, ?array $allowed_tags = NULL) { if ($allowed_tags === NULL) { $value = Xss::filter($value); } diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php index b25c5072a98..624aaa59f6c 100644 --- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php +++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php @@ -237,7 +237,7 @@ class Fixtures { * * @see \Drupal\Composer\Plugin\Scaffold\ScaffoldFilePath::destinationPath() */ - public function destinationPath($destination, Interpolator $interpolator = NULL, $package_name = NULL) { + public function destinationPath($destination, ?Interpolator $interpolator = NULL, $package_name = NULL) { $interpolator = $interpolator ?: $this->getLocationReplacements(); $package_name = $package_name ?: $interpolator->interpolate('[package-name]'); return ScaffoldFilePath::destinationPath($package_name, $destination, $interpolator); diff --git a/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php b/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php index b53040970b2..64a11e90de4 100644 --- a/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php @@ -492,7 +492,7 @@ class VariationCacheTest extends UnitTestCase { * (optional) The cacheability that should have been used. Does not apply * when checking for cache redirects. */ - protected function assertCacheBackendItem(string $cid, $data, CacheableMetadata $cacheability = NULL) { + protected function assertCacheBackendItem(string $cid, $data, ?CacheableMetadata $cacheability = NULL) { $cache_backend_item = $this->memoryBackend->get($cid); $this->assertNotFalse($cache_backend_item, 'The data was stored and retrieved successfully.'); $this->assertEquals($data, $cache_backend_item->data, 'Cache item contains the right data.'); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php index 49ae87a2cf9..f148e18af83 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php @@ -520,7 +520,7 @@ class BasicForm extends FormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_test = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ?EntityInterface $entity_test = NULL) { return []; } @@ -571,7 +571,7 @@ class BasicFormNoContainerInjectionInterface implements FormInterface { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_test = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ?EntityInterface $entity_test = NULL) { return []; } diff --git a/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php b/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php index 70c7358bf01..629ebc8dc2e 100644 --- a/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php +++ b/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php @@ -25,7 +25,7 @@ class FieldItemListTest extends UnitTestCase { * * @dataProvider providerTestEquals */ - public function testEquals($expected, FieldItemInterface $first_field_item = NULL, FieldItemInterface $second_field_item = NULL) { + public function testEquals($expected, ?FieldItemInterface $first_field_item = NULL, ?FieldItemInterface $second_field_item = NULL) { // Mock the field type manager and place it in the container. $field_type_manager = $this->createMock('Drupal\Core\Field\FieldTypePluginManagerInterface'); @@ -167,7 +167,7 @@ class FieldItemListTest extends UnitTestCase { * * @dataProvider providerTestEquals */ - public function testHasAffectingChanges($expected, FieldItemInterface $first_field_item = NULL, FieldItemInterface $second_field_item = NULL) { + public function testHasAffectingChanges($expected, ?FieldItemInterface $first_field_item = NULL, ?FieldItemInterface $second_field_item = NULL) { // Mock the field type manager and place it in the container. $field_type_manager = $this->createMock(FieldTypePluginManagerInterface::class); $container = new ContainerBuilder(); diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php index 5e9c909e4a3..c1f253096a1 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php @@ -192,7 +192,7 @@ class EntityContextDefinitionIsSatisfiedTest extends UnitTestCase { * * @dataProvider providerTestIsSatisfiedByGenerateBundledEntity */ - public function testIsSatisfiedByGenerateBundledEntity($expected, array $requirement_bundles, array $candidate_bundles, array $bundles_to_instantiate = NULL) { + public function testIsSatisfiedByGenerateBundledEntity($expected, array $requirement_bundles, array $candidate_bundles, ?array $bundles_to_instantiate = NULL) { // If no bundles are explicitly specified, instantiate all bundles. if (!$bundles_to_instantiate) { $bundles_to_instantiate = $candidate_bundles; diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php index c290c873346..43ccb8fd864 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php @@ -18,7 +18,7 @@ class DefaultSingleLazyPluginCollectionTest extends LazyPluginCollectionTestBase /** * {@inheritdoc} */ - protected function setupPluginCollection(InvocationOrder $create_count = NULL) { + protected function setupPluginCollection(?InvocationOrder $create_count = NULL) { $definitions = $this->getPluginDefinitions(); $this->pluginInstances['apple'] = new ConfigurablePlugin(['id' => 'apple', 'key' => 'value'], 'apple', $definitions['apple']); $this->pluginInstances['banana'] = new ConfigurablePlugin(['id' => 'banana', 'key' => 'other_value'], 'banana', $definitions['banana']); diff --git a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php index d14cff7867f..a4f169b1565 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php +++ b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php @@ -66,7 +66,7 @@ abstract class LazyPluginCollectionTestBase extends UnitTestCase { * called. For example, $this->any(), $this->once(), $this->exactly(6). * Defaults to $this->never(). */ - protected function setupPluginCollection(InvocationOrder $create_count = NULL) { + protected function setupPluginCollection(?InvocationOrder $create_count = NULL) { $this->pluginInstances = []; $map = []; foreach ($this->getPluginDefinitions() as $plugin_id => $definition) { diff --git a/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php b/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php index 4f001bfda58..3acf540c4b5 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php +++ b/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php @@ -29,7 +29,7 @@ class TestPluginManager extends DefaultPluginManager { * @param string $interface * (optional) The interface required for the plugins. */ - public function __construct(\Traversable $namespaces, array $definitions, ModuleHandlerInterface $module_handler = NULL, $alter_hook = NULL, $interface = NULL) { + public function __construct(\Traversable $namespaces, array $definitions, ?ModuleHandlerInterface $module_handler = NULL, $alter_hook = NULL, $interface = NULL) { // Create the object that can be used to return definitions for all the // plugins available for this type. Most real plugin managers use a richer // discovery implementation, but StaticDiscovery lets us add some simple diff --git a/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php index 969c70a345d..8f2c03d76d7 100644 --- a/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php @@ -167,7 +167,7 @@ class TestServiceNoMethod { class TestServiceComplexMethod { - public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = []) { + public function complexMethod($parameter, callable $function, ?TestServiceNoMethod $test_service = NULL, array &$elements = []) { } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 552fbee231d..d14a083c177 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -41,7 +41,7 @@ class RendererTest extends RendererTestBase { * * @dataProvider providerTestRenderBasic */ - public function testRenderBasic($build, $expected, callable $setup_code = NULL) { + public function testRenderBasic($build, $expected, ?callable $setup_code = NULL) { if (isset($setup_code)) { $setup_code = $setup_code->bindTo($this); $setup_code($this->themeManager); diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index e35d06a7306..068f13f23b7 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -515,7 +515,7 @@ class UrlGeneratorTest extends UnitTestCase { $path_processor = $this->createMock(OutboundPathProcessorInterface::CLASS); $path_processor->expects($this->atLeastOnce()) ->method('processOutbound') - ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + ->willReturnCallback(function ($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) { $options['query'] = ['zoo' => 5]; $options['fragment'] = 'foo'; return $path; diff --git a/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php b/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php index 070f1d12631..b7f55934346 100644 --- a/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php +++ b/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php @@ -60,7 +60,7 @@ class RequestSanitizerTest extends UnitTestCase { * * @dataProvider providerTestRequestSanitization */ - public function testRequestSanitization(Request $request, array $expected = [], array $expected_errors = NULL, array $whitelist = []) { + public function testRequestSanitization(Request $request, array $expected = [], ?array $expected_errors = NULL, array $whitelist = []) { // Set up globals. $_GET = $request->query->all(); $_POST = $request->request->all(); diff --git a/core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php b/core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php index a3d0b64d2b5..ebd6002999c 100644 --- a/core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php @@ -369,11 +369,11 @@ class AccessPolicyProcessorTest extends UnitTestCase { * @return \Drupal\Core\Session\AccessPolicyProcessorInterface */ protected function setUpAccessPolicyProcessor( - VariationCacheInterface $variation_cache = NULL, - VariationCacheInterface $variation_cache_static = NULL, - CacheBackendInterface $cache_static = NULL, - AccountProxyInterface $current_user = NULL, - AccountSwitcherInterface $account_switcher = NULL, + ?VariationCacheInterface $variation_cache = NULL, + ?VariationCacheInterface $variation_cache_static = NULL, + ?CacheBackendInterface $cache_static = NULL, + ?AccountProxyInterface $current_user = NULL, + ?AccountSwitcherInterface $account_switcher = NULL, ) { // Prophecy does not accept a willReturn call on a mocked method if said // method has a return type of void. However, without willReturn() or any diff --git a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php index a1a6aed5c92..d0eb9c871a7 100644 --- a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php @@ -154,7 +154,7 @@ class UnroutedUrlAssemblerTest extends UnitTestCase { $this->setupRequestStack(FALSE); $this->pathProcessor->expects($this->exactly(2)) ->method('processOutbound') - ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + ->willReturnCallback(function ($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) { if ($bubbleable_metadata) { $bubbleable_metadata->setCacheContexts(['some-cache-context']); } @@ -179,7 +179,7 @@ class UnroutedUrlAssemblerTest extends UnitTestCase { $this->pathProcessor->expects($this->exactly(2)) ->method('processOutbound') ->with('/test-uri', $this->anything(), $this->anything(), $this->anything()) - ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + ->willReturnCallback(function ($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) { $bubbleable_metadata?->setCacheContexts(['some-cache-context']); return '/test-other-uri'; }); diff --git a/core/tests/Drupal/Tests/PhpCs/SortTest.php b/core/tests/Drupal/Tests/PhpCs/SortTest.php index 41ffab51b38..6927f442ccd 100644 --- a/core/tests/Drupal/Tests/PhpCs/SortTest.php +++ b/core/tests/Drupal/Tests/PhpCs/SortTest.php @@ -81,7 +81,7 @@ class SortTest extends TestCase { * @param null|string $column * The column of the value or NULL. */ - private function assertSorted(array $input, string $column = NULL) { + private function assertSorted(array $input, ?string $column = NULL) { $input_sorted = $input; if ($column === NULL) { diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php index c3d2a69824f..a60597aa665 100644 --- a/core/tests/Drupal/Tests/WebAssert.php +++ b/core/tests/Drupal/Tests/WebAssert.php @@ -145,7 +145,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * When the element doesn't exist. */ - public function buttonExists($button, TraversableElement $container = NULL) { + public function buttonExists($button, ?TraversableElement $container = NULL) { if (!is_string($button)) { // @todo Trigger deprecation in // https://www.drupal.org/project/drupal/issues/3421105. @@ -172,7 +172,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ExpectationException * When the button exists. */ - public function buttonNotExists($button, TraversableElement $container = NULL) { + public function buttonNotExists($button, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $node = $container->findButton($button); @@ -193,7 +193,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * When the element doesn't exist. */ - public function selectExists($select, TraversableElement $container = NULL) { + public function selectExists($select, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $node = $container->find('named', [ 'select', @@ -223,7 +223,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * When the element doesn't exist. */ - public function optionExists($select, $option, TraversableElement $container = NULL) { + public function optionExists($select, $option, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $select_field = $container->find('named', [ 'select', @@ -256,7 +256,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * When the select element doesn't exist. */ - public function optionNotExists($select, $option, TraversableElement $container = NULL) { + public function optionNotExists($select, $option, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $select_field = $container->find('named', [ 'select', @@ -601,7 +601,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * @throws \Behat\Mink\Exception\ExpectationException */ - public function fieldDisabled($field, TraversableElement $container = NULL) { + public function fieldDisabled($field, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $node = $container->findField($field); @@ -630,7 +630,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * @throws \Behat\Mink\Exception\ExpectationException */ - public function fieldEnabled($field, TraversableElement $container = NULL) { + public function fieldEnabled($field, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $node = $container->findField($field); @@ -658,7 +658,7 @@ class WebAssert extends MinkWebAssert { * * @throws \Behat\Mink\Exception\ElementNotFoundException */ - public function hiddenFieldExists($field, TraversableElement $container = NULL) { + public function hiddenFieldExists($field, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); if ($node = $container->find('hidden_field_selector', ['hidden_field', $field])) { return $node; @@ -676,7 +676,7 @@ class WebAssert extends MinkWebAssert { * * @throws \Behat\Mink\Exception\ExpectationException */ - public function hiddenFieldNotExists($field, TraversableElement $container = NULL) { + public function hiddenFieldNotExists($field, ?TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $node = $container->find('hidden_field_selector', ['hidden_field', $field]); $this->assert($node === NULL, "A hidden field '$field' exists on this page, but it should not."); @@ -695,7 +695,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * @throws \Behat\Mink\Exception\ExpectationException */ - public function hiddenFieldValueEquals($field, $value, TraversableElement $container = NULL) { + public function hiddenFieldValueEquals($field, $value, ?TraversableElement $container = NULL) { $node = $this->hiddenFieldExists($field, $container); $actual = $node->getValue(); $regex = '/^' . preg_quote($value, '/') . '$/ui'; @@ -716,7 +716,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * @throws \Behat\Mink\Exception\ExpectationException */ - public function hiddenFieldValueNotEquals($field, $value, TraversableElement $container = NULL) { + public function hiddenFieldValueNotEquals($field, $value, ?TraversableElement $container = NULL) { $node = $this->hiddenFieldExists($field, $container); $actual = $node->getValue(); $regex = '/^' . preg_quote($value, '/') . '$/ui'; @@ -813,7 +813,7 @@ class WebAssert extends MinkWebAssert { * @param string|null $type * The optional message type: status, error, or warning. */ - public function statusMessageExists(string $type = NULL): void { + public function statusMessageExists(?string $type = NULL): void { $selector = $this->buildStatusMessageSelector(NULL, $type); try { $this->elementExists('xpath', $selector); @@ -829,7 +829,7 @@ class WebAssert extends MinkWebAssert { * @param string|null $type * The optional message type: status, error, or warning. */ - public function statusMessageNotExists(string $type = NULL): void { + public function statusMessageNotExists(?string $type = NULL): void { $selector = $this->buildStatusMessageSelector(NULL, $type); try { $this->elementNotExists('xpath', $selector); @@ -847,7 +847,7 @@ class WebAssert extends MinkWebAssert { * @param string|null $type * The optional message type: status, error, or warning. */ - public function statusMessageContains(string $message, string $type = NULL): void { + public function statusMessageContains(string $message, ?string $type = NULL): void { $selector = $this->buildStatusMessageSelector($message, $type); try { $this->elementExists('xpath', $selector); @@ -865,7 +865,7 @@ class WebAssert extends MinkWebAssert { * @param string|null $type * The optional message type: status, error, or warning. */ - public function statusMessageNotContains(string $message, string $type = NULL): void { + public function statusMessageNotContains(string $message, ?string $type = NULL): void { $selector = $this->buildStatusMessageSelector($message, $type); try { $this->elementNotExists('xpath', $selector); @@ -894,7 +894,7 @@ class WebAssert extends MinkWebAssert { * @throws \InvalidArgumentException * Thrown when $type is not an allowed type. */ - protected function buildStatusMessageSelector(string $message = NULL, string $type = NULL): string { + protected function buildStatusMessageSelector(?string $message = NULL, ?string $type = NULL): string { $allowed_types = [ 'status', 'error', @@ -978,7 +978,7 @@ class WebAssert extends MinkWebAssert { /** * {@inheritdoc} */ - public function fieldValueEquals(string $field, $value, TraversableElement $container = NULL) { + public function fieldValueEquals(string $field, $value, ?TraversableElement $container = NULL) { if (!is_string($value)) { // @todo Trigger deprecation in // https://www.drupal.org/project/drupal/issues/3421105. |