Testing D7 Rules with PHP 8.1 shows some new errors due to deprecated methods in PHP. See https://www.drupal.org/pift-ci-job/2243125

These are similar to:
Return type of RulesRecursiveElementIterator::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Because we can't use return type hinting in Drupal 7, we will need to add the #[\ReturnTypeWillChange] attribute to tell PHP 8.1 to ignore these deprecation notices. The attribute is seen as a code comment so this won't break any code running on lower PHP versions.

This issue is a blocker for a new D7 release of Rules.

CommentFileSizeAuthor
#2 3250504-2-returntypewillchange.patch891 bytestr

Comments

TR created an issue. See original summary.

tr’s picture

Status: Active » Needs review
StatusFileSize
new891 bytes

  • TR committed 807fac0 on 7.x-2.x
    Issue #3250504 by TR: [D7] PHP 8.1 compatibility - #[\...
tr’s picture

Status: Needs review » Fixed
Issue tags: +PHP 8.1

Test results show this patch doesn't affect anything under PHP 5.3, as expected, and eliminates the errors mention in the issue summary under PHP 8.1.

Committed #2.

Status: Fixed » Closed (fixed)

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