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
- Run on PHP 8.5 with a Typesense index that has a boolean field (the
typesense_booldata type). - Index/transform content so
BoolDataType::getValue()runs. - 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.
Issue fork search_api_typesense-3598842
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
ayalon commentedComment #4
pfrenssenSimple fix, looks good! The PHPStan failure is unrelated, is handled in #3600935: PHPStan warning: using nullsafe method call on non-nullable type.
Comment #7
lussolucaReleased in 1.2.0-beta3, thanks!