diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 881d695b4aeee7009cf360380a2c8de5cf12b1fd..94c81ed3a10276b35cea9901cd173dcecbd8249e 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -201,7 +201,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { } // The file properties add more entropy not easily accessible to others. $key = $private_key . filectime(__FILE__) . fileinode(__FILE__); - $time_diff = time() - $time; + $time_diff = time() - (int) $time; $test_hmac = Crypt::hmacBase64($check_string, $key); // Since we are making a local request a 600 second time window is allowed, // and the HMAC must match. diff --git a/core/lib/Drupal/Component/Utility/Bytes.php b/core/lib/Drupal/Component/Utility/Bytes.php index 429b6b428b8d9b8e8001cc9b0a44078abe19ad5a..f28b7788c3e4ec751b8583285ea81ebf2833ec3e 100644 --- a/core/lib/Drupal/Component/Utility/Bytes.php +++ b/core/lib/Drupal/Component/Utility/Bytes.php @@ -79,7 +79,7 @@ public static function toNumber($size): float { if ($unit) { // Find the position of the unit in the ordered string which is the power // of magnitude to multiply a kilobyte by. - return round($size * pow(self::KILOBYTE, stripos('bkmgtpezy', $unit[0]))); + return round((float) $size * pow(self::KILOBYTE, stripos('bkmgtpezy', $unit[0]))); } else { // Ensure size is a proper number type. diff --git a/core/lib/Drupal/Component/Uuid/Php.php b/core/lib/Drupal/Component/Uuid/Php.php index 579e3ef3d8688f6b87873e94ce3c2205b61f7b3a..962d5e42065d1cb2ac5f3440a56de74dbd4ee606 100644 --- a/core/lib/Drupal/Component/Uuid/Php.php +++ b/core/lib/Drupal/Component/Uuid/Php.php @@ -32,6 +32,7 @@ public function generate() { // Use characters 16-17 to generate 8-bit $clock_seq_hi_and_reserved. // The 2 most significant bits are set to one and zero respectively. + /** @var int $clock_seq_hi_and_reserved */ $clock_seq_hi_and_reserved = base_convert(substr($hex, 16, 2), 16, 10); $clock_seq_hi_and_reserved &= 0b00111111; $clock_seq_hi_and_reserved |= 0b10000000; diff --git a/core/lib/Drupal/Component/Version/Constraint.php b/core/lib/Drupal/Component/Version/Constraint.php index d2f8af1a0f0aaffc8ced75bfcee60786cbc0e678..02950ca53ddc9e256d14c195161cfa76395ecb21 100644 --- a/core/lib/Drupal/Component/Version/Constraint.php +++ b/core/lib/Drupal/Component/Version/Constraint.php @@ -103,7 +103,7 @@ private function parseConstraint($constraint_string, $core_compatibility) { } // Equivalence can be checked by adding two restrictions. if ($op == '=' || $op == '==') { - $this->constraintArray[] = ['op' => '<', 'version' => ($matches['major'] + 1) . '.x']; + $this->constraintArray[] = ['op' => '<', 'version' => (((int) $matches['major']) + 1) . '.x']; $op = '>='; } } diff --git a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php index 5119ffc743c72b02fdb7009d151b1ef69e8304fe..e8e34ba30adf5e305b3fd6777891157dec699232 100644 --- a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php +++ b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php @@ -40,7 +40,7 @@ protected static function datetimeRangeYears($string, $date = NULL) { $year_pattern = '@^[0-9]{4}@'; if (!preg_match($year_pattern, $min_year, $matches)) { if (preg_match($plus_pattern, $min_year, $matches)) { - $min_year = $this_year + $matches[0]; + $min_year = $this_year . $matches[0]; } else { $min_year = $this_year; @@ -48,7 +48,7 @@ protected static function datetimeRangeYears($string, $date = NULL) { } if (!preg_match($year_pattern, $max_year, $matches)) { if (preg_match($plus_pattern, $max_year, $matches)) { - $max_year = $this_year + $matches[0]; + $max_year = $this_year . $matches[0]; } else { $max_year = $this_year; diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php index c91b28eabf962af84bf8e5d7fcfff413b4d0b94b..29fa19b7f1394fb67318257b19543c3456672e8f 100644 --- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php +++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php @@ -104,7 +104,9 @@ public function testGlobalLoginFloodControl(): void { $user = $this->drupalCreateUser([]); $incorrect_user = clone $user; - $incorrect_user->pass_raw .= 'incorrect'; + /** @var string $pass_raw */ + $pass_raw = $incorrect_user->pass_raw; + $incorrect_user->pass_raw = $pass_raw . 'incorrect'; $url = Url::fromRoute('router_test.11'); // Try 2 failed logins. @@ -129,7 +131,9 @@ public function testPerUserLoginFloodControl(): void { $user = $this->drupalCreateUser([]); $incorrect_user = clone $user; - $incorrect_user->pass_raw .= 'incorrect'; + /** @var string $pass_raw */ + $pass_raw = $incorrect_user->pass_raw; + $incorrect_user->pass_raw = $pass_raw . 'incorrect'; $user2 = $this->drupalCreateUser([]); $url = Url::fromRoute('router_test.11'); diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php index fa6652781540f7f4c4237194d59505ab884fcb7f..81126e138b5a336c1b743b2051e408155b6dc92d 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestProviderTrait.php @@ -203,7 +203,7 @@ public function testWidth(string $width): void { // of the image. $expected_computed_height = $width; if (!str_ends_with($width, '%')) { - $ratio = $width / (int) $this->imageAttributes()['width']; + $ratio = (int) $width / (int) $this->imageAttributes()['width']; $expected_computed_height = (string) (int) round($ratio * (int) $this->imageAttributes()['height']); } diff --git a/core/modules/jsonapi/tests/src/Functional/EntryPointTest.php b/core/modules/jsonapi/tests/src/Functional/EntryPointTest.php index 8e6aa6d09b2ff9a650580cf382a9908ee3e25473..55838912e756e5fb553d9673841946e472c9d19c 100644 --- a/core/modules/jsonapi/tests/src/Functional/EntryPointTest.php +++ b/core/modules/jsonapi/tests/src/Functional/EntryPointTest.php @@ -61,7 +61,9 @@ public function testEntryPoint(): void { // A `me` link must be present for authenticated users. $user = $this->createUser(); - $request_options[RequestOptions::HEADERS]['Authorization'] = 'Basic ' . base64_encode($user->name->value . ':' . $user->passRaw); + /** @var string $user_pass_raw */ + $user_pass_raw = $user->passRaw; + $request_options[RequestOptions::HEADERS]['Authorization'] = 'Basic ' . base64_encode($user->getAccountName() . ':' . $user_pass_raw); $response = $this->request('GET', Url::fromUri('base://jsonapi'), $request_options); $document = $this->getDocumentFromResponse($response); $this->assertArrayHasKey('meta', $document); diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 864f52dbfbe81619dbbd17dd9b89efaacfa36a5f..bd5238024a8b82e09db6df2ade29fb09a95c0824 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -421,7 +421,9 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI // be sorted from small to large, since the first matching source will // be used. We multiply it by 100 so multipliers with up to two decimals // can be used. - $srcset[intval(mb_substr($multiplier, 0, -1) * 100)] = _responsive_image_image_style_url($image_style_mapping['image_mapping'], $variables['uri']) . ' ' . $multiplier; + /** @var int $multiplier_number */ + $multiplier_number = ((float) mb_substr($multiplier, 0, -1)) * 100; + $srcset[$multiplier_number] = _responsive_image_image_style_url($image_style_mapping['image_mapping'], $variables['uri']) . ' ' . $multiplier; $dimensions = responsive_image_get_image_dimensions($image_style_mapping['image_mapping'], ['width' => $width, 'height' => $height], $variables['uri']); break; } diff --git a/core/modules/system/tests/src/Functional/Menu/LinksetControllerTestBase.php b/core/modules/system/tests/src/Functional/Menu/LinksetControllerTestBase.php index 8327991765212936315c33b1a90afc7632cd1ca2..d50ed2eb5660a8953e8ed021dee0b0eb85d86b6e 100644 --- a/core/modules/system/tests/src/Functional/Menu/LinksetControllerTestBase.php +++ b/core/modules/system/tests/src/Functional/Menu/LinksetControllerTestBase.php @@ -72,7 +72,9 @@ abstract class LinksetControllerTestBase extends BrowserTestBase { protected function doRequest(string $method, Url $url, $expected_status = 200, ?UserInterface $account = NULL): Response { $request_options = []; if (!is_null($account)) { - $credentials = $account->name->value . ':' . $account->passRaw; + /** @var string $account_pass_raw */ + $account_pass_raw = $account->passRaw; + $credentials = $account->getAccountName() . ':' . $account_pass_raw; $request_options[RequestOptions::HEADERS] = [ 'Authorization' => 'Basic ' . base64_encode($credentials), ]; diff --git a/core/modules/user/src/Form/UserPermissionsForm.php b/core/modules/user/src/Form/UserPermissionsForm.php index 0428925fa03228888d87c77c1b70a31bda8f1384..2e321859f1f0b7a552275faf34d094abb5bbd1d2 100644 --- a/core/modules/user/src/Form/UserPermissionsForm.php +++ b/core/modules/user/src/Form/UserPermissionsForm.php @@ -198,6 +198,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#markup' => $this->moduleExtensionList->getName($provider), ], ]; + /** @var array $perm_item */ foreach ($permissions as $perm => $perm_item) { // Fill in default values for the permission. $perm_item += [ diff --git a/core/modules/user/tests/src/Functional/UserLoginHttpTest.php b/core/modules/user/tests/src/Functional/UserLoginHttpTest.php index 4d4cc84ff95ade5656bb6866cdd3e01ed31b5cb3..11a925b1f4a5ca90880f0e864eebc759c674a9f1 100644 --- a/core/modules/user/tests/src/Functional/UserLoginHttpTest.php +++ b/core/modules/user/tests/src/Functional/UserLoginHttpTest.php @@ -305,7 +305,9 @@ public function doTestGlobalLoginFloodControl(string $format): void { $user = $this->drupalCreateUser([]); $incorrect_user = clone $user; - $incorrect_user->passRaw .= 'incorrect'; + /** @var string $pass_raw */ + $pass_raw = $incorrect_user->passRaw; + $incorrect_user->passRaw = $pass_raw . 'incorrect'; // Try 2 failed logins. for ($i = 0; $i < 2; $i++) { @@ -380,7 +382,9 @@ public function doTestPerUserLoginFloodControl($format): void { $user1 = $this->drupalCreateUser([]); $incorrect_user1 = clone $user1; - $incorrect_user1->passRaw .= 'incorrect'; + /** @var string $pass_raw */ + $pass_raw = $incorrect_user1->passRaw; + $incorrect_user1->passRaw = $pass_raw . 'incorrect'; $user2 = $this->drupalCreateUser([]); diff --git a/core/modules/user/tests/src/Functional/UserLoginTest.php b/core/modules/user/tests/src/Functional/UserLoginTest.php index 26c7807fe975d39064aafc736dd6a69829cfa327..f0318578328a5492b98252482316fab9f405152a 100644 --- a/core/modules/user/tests/src/Functional/UserLoginTest.php +++ b/core/modules/user/tests/src/Functional/UserLoginTest.php @@ -59,7 +59,9 @@ public function testGlobalLoginFloodControl(): void { $user1 = $this->drupalCreateUser([]); $incorrect_user1 = clone $user1; - $incorrect_user1->passRaw .= 'incorrect'; + /** @var string $pass_raw */ + $pass_raw = $incorrect_user1->passRaw; + $incorrect_user1->passRaw = $pass_raw . 'incorrect'; // Try 2 failed logins. for ($i = 0; $i < 2; $i++) { @@ -103,7 +105,9 @@ public function testPerUserLoginFloodControl(): void { $user1 = $this->drupalCreateUser([]); $incorrect_user1 = clone $user1; - $incorrect_user1->passRaw .= 'incorrect'; + /** @var string $pass_raw */ + $pass_raw = $incorrect_user1->passRaw; + $incorrect_user1->passRaw = $pass_raw . 'incorrect'; $user2 = $this->drupalCreateUser([]); diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index ebe81790854d3eeca29de4fc203328b812a80a0c..e956449507edcf324216c7ced7389ea6a82b53f9 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -274,8 +274,8 @@ public static function providerCoreIncompatibility() { $version = preg_replace('/-dev$/', '', \Drupal::VERSION); [$major, $minor] = explode('.', $version, 2); - $next_minor = $minor + 1; - $next_major = $major + 1; + $next_minor = (int) $minor + 1; + $next_major = (int) $major + 1; return [ 'next_minor' => [ 'next_minor',