Problem/Motivation

The code contains a non-canonical scalar type cast, like (boolean), which is deprecated in PHP 8.5. The alternate type names are not supported in parameter, return, or property types, either.

https://php.watch/versions/8.5/boolean-double-integer-binary-casts-depre...

Steps to reproduce

  protected function createDbQuery(QueryInterface $query, array $fields) {
    $keys = &$query->getKeys();
    $keys_set = (boolean) $keys;

and

              // Make sure the value is never negative.
              $value = max($value, 0);
              $item->setBoost($item->getBoost() * (double) $value * (double) $settings['boost_factor']);

and

      $item_boost = (double) ($boosts[$datasource_id]['datasource_boost'] ?? 1.0);
      if ($bundle && isset($boosts[$datasource_id]['bundle_boosts'][$bundle])) {
        $item_boost = (double) $boosts[$datasource_id]['bundle_boosts'][$bundle];
      }

Search the code using the regex \(integer\)|\(boolean\)|\(double\)|\(binary\) to find type casts. There may be parameters, return types, or property types that need to be updated as well.

Proposed resolution

int instead of integer
float instead of double
bool instead of boolean
string instead of binary

Remaining tasks

CommentFileSizeAuthor
#14 3558624-14.diff25.52 KBherved

Issue fork search_api-3558624

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

solideogloria created an issue. See original summary.

solideogloria’s picture

Status: Active » Needs review

drunken monkey made their first commit to this issue’s fork.

dpi’s picture

Title: PHP 8.5 compatibility » PHP 8.5 deprecations: Non-canonical scalar type casts
Related issues: +#3561397: PHP 8.5 deprecations: Using null as an array offset deprecation
drunken monkey’s picture

Title: PHP 8.5 deprecations: Non-canonical scalar type casts » PHP 8.5 compatibility
Assigned: Unassigned » drunken monkey
Related issues: -#3561397: PHP 8.5 deprecations: Using null as an array offset deprecation

I’m already working on this, and yes, on the whole PHP 8.5 compatibility. No need for a second issue or change of title, and also no need to link the two issues in both directions.

drunken monkey’s picture

Updated with some more fixes and also added a change record for some silly mistake I noticed in a service method.
Let’s see what the test bot says.

drunken monkey’s picture

Seems I managed to get all the PHP 8.5 deprecations now, just had a single test I broke with a fix. Should be passing now.
(The remaining deprecations in the “max PHP version” tests were due to Drupal 11.3 deprecations we will fix in #3562994: Adapt to deprecation of hook_requirements().)

drunken monkey’s picture

Status: Needs review » Fixed

Merged.
Thanks again for your work on this, @solideogloria!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

dpi’s picture

Sure, it seemed like narrowly scoped issues were the direction. Defer to your preference.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

herved’s picture

StatusFileSize
new25.52 KB

MR 301 diff (minus .ignored-deprecations.txt changes)