Problem/Motivation

On PHP 8.5, BoolDataType::getValue() triggers a deprecation because it uses the non-canonical (boolean) cast. PHP 8.5 deprecates the long-form scalar casts in favour of
their canonical short forms.

Deprecated: Non-canonical cast (boolean) is deprecated, use the (bool) cast instead in src/Plugin/search_api/data_type/BoolDataType.php on line 25

Root cause: BoolDataType::getValue() casts the value with (boolean) instead of (bool).

Steps to reproduce

  1. Run on PHP 8.5 with a Typesense index that has a boolean field (the typesense_bool data type).
  2. Index/transform content so BoolDataType::getValue() runs.
  3. Observe the Deprecated: Non-canonical cast (boolean) ... notice (or as a deprecation under PHPUnit --display-deprecations).

Proposed resolution

Use the canonical (bool) cast.

   public function getValue($value): bool {
  -    return (boolean) $value;
  +    return (bool) $value;
     }

Remaining tasks

  • Review the merge request.
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

ayalon created an issue. See original summary.

ayalon’s picture

Title: Search API Typesense (search_api_typesense) » PHP 8.5: Replace deprecated (boolean) cast with (bool) in BoolDataType::getValue()
pfrenssen’s picture

Status: Active » Reviewed & tested by the community

Simple fix, looks good! The PHPStan failure is unrelated, is handled in #3600935: PHPStan warning: using nullsafe method call on non-nullable type.

lussoluca made their first commit to this issue’s fork.

  • lussoluca committed 5abba75b on 1.0.x authored by jm.liip
    Issue #3598842 by ayalon: Replace deprecated (boolean) cast with (bool)...
lussoluca’s picture

Status: Reviewed & tested by the community » Fixed

Released in 1.2.0-beta3, thanks!

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.