Skip to content
Snippets Groups Projects
Verified Commit 49283982 authored by Dave Long's avatar Dave Long
Browse files

Issue #3402007 by marvil07, mstrelan, quietone, smustgrave, larowlan: Fix...

Issue #3402007 by marvil07, mstrelan, quietone, smustgrave, larowlan: Fix strict type errors in test modules

(cherry picked from commit d43e2ba8)
parent 16039786
No related branches found
No related tags found
10 merge requests!12802Issue #3537193 by opauwlo: Add enable absolute path option for CKEditor5 image uploads,!12745Fixed: Path alias language doesn't changes on changing of node language,!12684Issue #3220784,!12537Add ViewsConfigUpdater deprecation support for default_argument_skip_url,!12523Issue #3493858 by vidorado, xavier.masson, smustgrave: Extend ViewsBlockBase...,!122353526426-warning-for-missing,!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Checking pipeline status
Showing
with 21 additions and 18 deletions
......@@ -20,7 +20,7 @@ public function __invoke(): \Closure {
return function ($handler) {
return function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
$test_end_point = \Drupal::state()->get('announce_test_endpoint');
if ($test_end_point && str_contains($request->getUri(), '://www.drupal.org/announcements.json')) {
if ($test_end_point && str_contains((string) $request->getUri(), '://www.drupal.org/announcements.json')) {
// Only override $uri if it matches the advisories JSON feed to avoid
// changing any other uses of the 'http_client' service during tests with
// this module installed.
......
......@@ -22,7 +22,7 @@ public function testMultipleForms() {
// see if there's only one in the tests.
$post_render_callable = function ($elements) {
$matches = [];
preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', $elements, $matches);
preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', (string) $elements, $matches);
$action_values = $matches[2];
......
......@@ -18,7 +18,7 @@ public function __invoke() {
return function ($handler) {
return function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
$test_end_point = \Drupal::state()->get('advisories_test_endpoint');
if ($test_end_point && str_contains($request->getUri(), '://updates.drupal.org/psa.json')) {
if ($test_end_point && str_contains((string) $request->getUri(), '://updates.drupal.org/psa.json')) {
// Only override $uri if it matches the advisories JSON feed to avoid
// changing any other uses of the 'http_client' service during tests with
// this module installed.
......
......@@ -59,7 +59,7 @@ public function testMethod() {
* @return \Symfony\Component\HttpFoundation\Response
* CSRF token.
*/
public function getCsrfToken($num) {
public function getCsrfToken(int $num) {
sleep($num);
return new JsonResponse($this->tokenGenerator->get());
}
......
......@@ -94,7 +94,7 @@ public function response() {
public function responseEarly() {
$render_array = $this->earlyRenderContent();
return new Response($this->renderer->render($render_array));
return new Response((string) $this->renderer->render($render_array));
}
public function responseWithAttachments() {
......@@ -103,7 +103,7 @@ public function responseWithAttachments() {
public function responseWithAttachmentsEarly() {
$render_array = $this->earlyRenderContent();
return new AttachmentsTestResponse($this->renderer->render($render_array));
return new AttachmentsTestResponse((string) $this->renderer->render($render_array));
}
public function cacheableResponse() {
......@@ -112,7 +112,7 @@ public function cacheableResponse() {
public function cacheableResponseEarly() {
$render_array = $this->earlyRenderContent();
return new CacheableTestResponse($this->renderer->render($render_array));
return new CacheableTestResponse((string) $this->renderer->render($render_array));
}
public function domainObject() {
......
......@@ -61,7 +61,7 @@ public function generateWarnings($collect_errors = FALSE) {
public function generateFatalErrors() {
$function = function (array $test) {
};
// Use an incorrect parameter type, string, for testing a fatal error.
$function("test-string");
return [];
}
......
......@@ -43,7 +43,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $first =
foreach ($args as $arg) {
$name = 'button' . ++$i;
// 's', 'b', or 'i' in the argument define the button type wanted.
if (str_contains($arg, 's')) {
if (!is_string($arg)) {
$type = NULL;
}
elseif (str_contains($arg, 's')) {
$type = 'submit';
}
elseif (str_contains($arg, 'b')) {
......
......@@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
* @see \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
*/
public static function postRender($rendered_form) {
return str_replace('value="two"', 'value="FORGERY"', $rendered_form);
return str_replace('value="two"', 'value="FORGERY"', (string) $rendered_form);
}
/**
......
......@@ -11,7 +11,7 @@ class RenderArrayNonHtmlSubscriberTestController extends ControllerBase {
* @return string
*/
public function rawString() {
return new Response($this->t('Raw controller response.'));
return new Response((string) $this->t('Raw controller response.'));
}
/**
......
......@@ -111,7 +111,7 @@ public function noSet($test_value) {
*/
public function setMessage() {
$this->messenger()->addStatus($this->t('This is a dummy message.'));
return new Response($this->t('A message was set.'));
return new Response((string) $this->t('A message was set.'));
// Do not return anything, so the current request does not result in a themed
// page with messages. The message will be displayed in the following request
// instead.
......@@ -240,8 +240,8 @@ public function hasSessionBagFlag(Request $request) {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
return new Response(empty($bag->hasFlag())
? $this->t('Flag is absent from session bag')
: $this->t('Flag is present in session bag')
? (string) $this->t('Flag is absent from session bag')
: (string) $this->t('Flag is present in session bag')
);
}
......
......@@ -27,7 +27,7 @@ class SessionTestSubscriber implements EventSubscriberInterface {
*/
public function onKernelRequestSessionTest(RequestEvent $event) {
$session = $event->getRequest()->getSession();
$this->emptySession = (int) !($session && $session->start());
$this->emptySession = !($session && $session->start());
}
/**
......@@ -39,7 +39,7 @@ public function onKernelRequestSessionTest(RequestEvent $event) {
public function onKernelResponseSessionTest(ResponseEvent $event) {
// Set header for session testing.
$response = $event->getResponse();
$response->headers->set('X-Session-Empty', $this->emptySession);
$response->headers->set('X-Session-Empty', $this->emptySession ? '1' : '0');
}
/**
......
......@@ -303,7 +303,7 @@ public function setHeader(Request $request) {
$response = new CacheableResponse();
$response->headers->set($query['name'], $query['value']);
$response->getCacheableMetadata()->addCacheContexts(['url.query_args:name', 'url.query_args:value']);
$response->setContent($this->t('The following header was set: %name: %value', ['%name' => $query['name'], '%value' => $query['value']]));
$response->setContent((string) $this->t('The following header was set: %name: %value', ['%name' => $query['name'], '%value' => $query['value']]));
return $response;
}
......
......@@ -85,7 +85,7 @@ public function renderPage() {
* @param int $code
* The status code.
*/
public function httpResponseException($code) {
public function httpResponseException(int $code) {
throw new HttpException($code);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment