diff --git a/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php b/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php index 7f12b37e5dbf9ba24947c2d003b56d65db25660e..42d61eee5ae4ffc5a358cd80887ccee0eb135f22 100644 --- a/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php +++ b/core/modules/ban/tests/src/Unit/BanMiddlewareTest.php @@ -78,7 +78,7 @@ public function testUnbannedIp() { $request = Request::create('/test-path'); $request->server->set('REMOTE_ADDR', $unbanned_ip); - $expected_response = new Response(200); + $expected_response = new Response(status: 200); $this->kernel->expects($this->once()) ->method('handle') ->with($request, HttpKernelInterface::MAIN_REQUEST, TRUE) diff --git a/core/modules/migrate_drupal/tests/src/Unit/MigrationStateUnitTest.php b/core/modules/migrate_drupal/tests/src/Unit/MigrationStateUnitTest.php index ea4b54356ea665bc835426235bb22d15233f3d4b..1dd8f926960f2a97dc7e6141f4066cd0729a8b3e 100644 --- a/core/modules/migrate_drupal/tests/src/Unit/MigrationStateUnitTest.php +++ b/core/modules/migrate_drupal/tests/src/Unit/MigrationStateUnitTest.php @@ -48,7 +48,7 @@ public function testGetUpgradeStates($modules_to_enable, $files, $field_plugins, foreach ($files as $module => $contents) { $path = $url . '/' . $module . '/migrations/state'; - mkdir($path, '0755', TRUE); + mkdir($path, 0755, TRUE); file_put_contents($path . '/' . $module . '.migrate_drupal.yml', $contents); } $moduleHandler->getModuleDirectories() diff --git a/core/modules/phpass/tests/src/Unit/PasswordVerifyTest.php b/core/modules/phpass/tests/src/Unit/PasswordVerifyTest.php index f080bd2396deff3b6516a04f6bdb86d703218ddc..c130029ee185887b15b0d5e21683fd3c9f9fb985 100644 --- a/core/modules/phpass/tests/src/Unit/PasswordVerifyTest.php +++ b/core/modules/phpass/tests/src/Unit/PasswordVerifyTest.php @@ -149,7 +149,7 @@ public function providerLongPasswords() { // Check a string of 3-byte UTF-8 characters, 510 byte long password is // allowed. - $len = floor(PasswordInterface::PASSWORD_MAX_LENGTH / 3); + $len = (int) floor(PasswordInterface::PASSWORD_MAX_LENGTH / 3); $diff = PasswordInterface::PASSWORD_MAX_LENGTH % 3; $passwords['utf8'] = [str_repeat('€', $len), TRUE]; // 512 byte long password is allowed. diff --git a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php index cde0a60c3dedc5baf367a1aba700a03155436709..2c1256e9f94ae43f801f5e9399be3ea9470d4790 100644 --- a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php +++ b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php @@ -178,7 +178,7 @@ public function testUpdateFetcherNoFallback() { // First, try without the HTTP fallback setting, and HTTPS mocked to fail. $settings = new Settings([]); $this->mockClient( - new Response('500', [], 'HTTPS failed'), + new Response(500, [], 'HTTPS failed'), ); $update_fetcher = new UpdateFetcher($this->mockConfigFactory, $this->mockHttpClient, $settings, $this->logger); @@ -206,8 +206,8 @@ public function testUpdateFetcherNoFallback() { public function testUpdateFetcherHttpFallback() { $settings = new Settings(['update_fetch_with_http_fallback' => TRUE]); $this->mockClient( - new Response('500', [], 'HTTPS failed'), - new Response('200', [], 'HTTP worked'), + new Response(500, [], 'HTTPS failed'), + new Response(200, [], 'HTTP worked'), ); $update_fetcher = new UpdateFetcher($this->mockConfigFactory, $this->mockHttpClient, $settings, $this->logger); diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php index 6e128c632afa621816c1f9ab3b95698aa518cb64..dcfa56ca91357fe2992f0f13df56420b96589214 100644 --- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php @@ -186,7 +186,7 @@ public function testDateTimestamp($input, array $initial, array $transform) { * * @param \Drupal\Component\Datetime\DateTimePlus $date * DateTimePlus to test. - * @param string $input + * @param string|int $input * The original input passed to the test method. * @param array $initial * @see testTimestamp() @@ -195,7 +195,7 @@ public function testDateTimestamp($input, array $initial, array $transform) { * * @internal */ - public function assertDateTimestamp(DateTimePlus $date, string $input, array $initial, array $transform): void { + public function assertDateTimestamp(DateTimePlus $date, string|int $input, array $initial, array $transform): void { // Check format. $value = $date->format($initial['format']); $this->assertEquals($initial['expected_date'], $value, sprintf("Test new DateTimePlus(%s, %s): should be %s, found %s.", $input, $initial['timezone'], $initial['expected_date'], $value)); @@ -694,7 +694,7 @@ public function providerTestDateDiff() { ], [ 'input1' => DateTimePlus::createFromFormat('U', 3600), - 'input2' => \DateTime::createFromFormat('U', 0), + 'input2' => \DateTime::createFromFormat('U', '0'), 'absolute' => FALSE, 'expected' => $negative_1_hour, ], @@ -706,7 +706,7 @@ public function providerTestDateDiff() { ], [ 'input1' => DateTimePlus::createFromFormat('U', 3600), - 'input2' => \DateTime::createFromFormat('U', 0), + 'input2' => \DateTime::createFromFormat('U', '0'), 'absolute' => TRUE, 'expected' => $positive_1_hour, ], diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php index 90a2486bb741d3848842dd8a466643746821edd0..3f9547b2e572faf129c53734f16c440781731961 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php @@ -554,7 +554,7 @@ public function publicPrivateDataProvider() { public function testGetServiceDefinitionForDecoratedService() { $bar_definition = new Definition('\stdClass'); $bar_definition->setPublic(TRUE); - $bar_definition->setDecoratedService(new Reference('foo')); + $bar_definition->setDecoratedService((string) new Reference('foo')); $services['bar'] = $bar_definition; $this->containerBuilder->getDefinitions()->willReturn($services); diff --git a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php index 070aa13b1b0b644615eff6ece4f4e34cbfe625d5..d9d70051a81736979b7a0f438518add8472c5a90 100644 --- a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php +++ b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php @@ -109,7 +109,7 @@ public function providerTestDateDiff() { ], [ 'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings), - 'input2' => \DateTime::createFromFormat('U', 0), + 'input2' => \DateTime::createFromFormat('U', '0'), 'absolute' => FALSE, 'expected' => $negative_1_hour, ], @@ -121,7 +121,7 @@ public function providerTestDateDiff() { ], [ 'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings), - 'input2' => \DateTime::createFromFormat('U', 0), + 'input2' => \DateTime::createFromFormat('U', '0'), 'absolute' => TRUE, 'expected' => $positive_1_hour, ], diff --git a/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php index fe3b81afbc73f26d5854b3d50a4ac25012c99d55..6f3f4e44f628c015f39d3aa36eb15915849a2c00 100644 --- a/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php @@ -184,7 +184,7 @@ public function testOnExceptionBrokenPostRequest() { $container->set('renderer', $renderer); \Drupal::setContainer($container); - $exception = new BrokenPostRequestException(32 * 1e6); + $exception = new BrokenPostRequestException((int) (32 * 1e6)); $request = new Request([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]); $event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MAIN_REQUEST, $exception); diff --git a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php index 7269077e23d3be3c4dfa3467053865330e7e5081..8f48f16fcc12eb9d6e28e963ff42eee999b7de82 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php @@ -368,10 +368,10 @@ public function testTemporaryValue() { $this->assertFalse($form_state->hasTemporaryValue('rainbow_sparkles')); $form_state->setTemporaryValue('rainbow_sparkles', 'yes'); $this->assertSame($form_state->getTemporaryValue('rainbow_sparkles'), 'yes'); - $this->assertTrue($form_state->hasTemporaryValue('rainbow_sparkles'), TRUE); + $this->assertTrue($form_state->hasTemporaryValue('rainbow_sparkles')); $form_state->setTemporaryValue(['rainbow_sparkles', 'magic_ponies'], 'yes'); $this->assertSame($form_state->getTemporaryValue(['rainbow_sparkles', 'magic_ponies']), 'yes'); - $this->assertTrue($form_state->hasTemporaryValue(['rainbow_sparkles', 'magic_ponies']), TRUE); + $this->assertTrue($form_state->hasTemporaryValue(['rainbow_sparkles', 'magic_ponies'])); } /** diff --git a/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php b/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php index 21f7266d019ca5230b23d3f5dfa34cb6109aacdc..f781fd7d6e94f7f6c735135d915a6f23ad9d6bb0 100644 --- a/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php +++ b/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php @@ -112,7 +112,7 @@ public function providerLongPasswords() { // Check a string of 3-byte UTF-8 characters, 510 byte long password is // allowed. - $len = floor(PasswordInterface::PASSWORD_MAX_LENGTH / 3); + $len = (int) floor(PasswordInterface::PASSWORD_MAX_LENGTH / 3); $diff = PasswordInterface::PASSWORD_MAX_LENGTH % 3; $passwords['utf8'] = [str_repeat('€', $len), TRUE]; // 512 byte long password is allowed. diff --git a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php index 5d3e7d493ac407b42a5009ea5e9aa294970afbdf..eec25807ded579be61b084461c40858a05b351b7 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php @@ -471,7 +471,7 @@ public function testBubblingWithPrerender($test_element) { ); // Simulate the rendering of an entire response (i.e. a root call). - $output = $this->renderer->renderRoot($test_element); + $output = (string) $this->renderer->renderRoot($test_element); // First, assert the render array is of the expected form. $this->assertEquals('Cache context!Cache tag!Asset!Placeholder!barquxNested!Cached nested!', trim($output), 'Expected HTML generated.'); diff --git a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php index ce26cf14d906076f12b32a2d526cd53ea733dab5..d9716c39ed298adb063aa6aabd9386163851ac75 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php @@ -70,7 +70,7 @@ public function testRenderRecursionWithNestedRender() { $this->setUpRequest(); $callable = function ($markup) { - $this->assertStringStartsWith('<drupal-render-placeholder', $markup, 'Rendered complex child output as expected, without the placeholder replaced, i.e. with just the placeholder.'); + $this->assertStringStartsWith('<drupal-render-placeholder', (string) $markup, 'Rendered complex child output as expected, without the placeholder replaced, i.e. with just the placeholder.'); return $markup; }; diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 3fdefb20e5a0642e98e782cf19b312a5d1226770..de08a3d32228b3a86cc2e90c264d47393292e1ff 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -497,7 +497,7 @@ public function testRenderSorting() { '#markup' => $first, ], ]; - $output = $this->renderer->renderRoot($elements); + $output = (string) $this->renderer->renderRoot($elements); // The lowest weight element should appear last in $output. $this->assertGreaterThan(strpos($output, $first), strpos($output, $second)); @@ -533,7 +533,7 @@ public function testRenderSortingWithSetHashSorted() { ], '#sorted' => TRUE, ]; - $output = $this->renderer->renderRoot($elements); + $output = (string) $this->renderer->renderRoot($elements); // The elements should appear in output in the same order as the array. $this->assertLessThan(strpos($output, $first), strpos($output, $second)); diff --git a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php index 1aa2da366a1cca8fc61463dd3e4483f6869e4bfb..21b1ffe7bba31679344e9e7a957646c8d27c0664 100644 --- a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php +++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php @@ -107,7 +107,7 @@ public function testEscaping($template, $expected) { $nodes = $twig->parse($twig->tokenize(new Source($template, $name))); $this->assertSame($expected, $nodes->getNode('body') - ->getNode(0) + ->getNode('0') ->getNode('expr') instanceof FilterExpression); } diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index a64af6173edc34127a3c1c125fbdb99a9d06afcc..189056d6f87fd86d1730046d44839cf86ee1e5f5 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -411,7 +411,7 @@ public function testGenerateXss() { $url = new Url('test_route_4'); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate("<script>alert('XSS!')</script>", $url); - $this->assertNoXPathResults('//a[@href="/test-route-4"]/script', $result); + $this->assertNoXPathResults('//a[@href="/test-route-4"]/script', (string) $result); } /** @@ -450,7 +450,7 @@ public function testGenerateWithHtml() { 'tag' => 'em', ], ], $result); - $this->assertStringContainsString('<em>HTML output</em>', $result); + $this->assertStringContainsString('<em>HTML output</em>', (string) $result); } /** @@ -499,7 +499,7 @@ public function testGenerateActive() { $url = new Url('test_route_1', [], ['set_active_class' => FALSE]); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertNoXPathResults('//a[@data-drupal-link-system-path="test-route-1"]', $result); + $this->assertNoXPathResults('//a[@data-drupal-link-system-path="test-route-1"]', (string) $result); // Render a link with an associated language. $url = new Url('test_route_1', [], [