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
| Comment | File | Size | Author |
|---|
Issue fork search_api-3558624
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
Comment #3
solideogloria commentedComment #5
dpiComment #6
drunken monkeyI’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.
Comment #7
drunken monkeyUpdated 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.
Comment #8
drunken monkeySeems 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().)
Comment #9
drunken monkeyMerged.
Thanks again for your work on this, @solideogloria!
Comment #12
dpiSure, it seemed like narrowly scoped issues were the direction. Defer to your preference.
Comment #14
herved commentedMR 301 diff (minus .ignored-deprecations.txt changes)