From 44417765ecda8602296d5e8474152175464d63b5 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Fri, 23 Jul 2021 03:12:26 +0200
Subject: [PATCH 1/2] PHP 8.1: WP_Hook: silence return type missing deprecation
warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration) òr need to silence the deprecation warning using an attribute.
---
src/wp-includes/class-wp-hook.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php
index 432a01600f..cb49271ba4 100644
|
a
|
b
|
final class WP_Hook implements Iterator, ArrayAccess {
|
| 437 | 437 | * @param mixed $offset An offset to check for. |
| 438 | 438 | * @return bool True if the offset exists, false otherwise. |
| 439 | 439 | */ |
| | 440 | #[ReturnTypeWillChange] |
| 440 | 441 | public function offsetExists( $offset ) { |
| 441 | 442 | return isset( $this->callbacks[ $offset ] ); |
| 442 | 443 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 451 | 452 | * @param mixed $offset The offset to retrieve. |
| 452 | 453 | * @return mixed If set, the value at the specified offset, null otherwise. |
| 453 | 454 | */ |
| | 455 | #[ReturnTypeWillChange] |
| 454 | 456 | public function offsetGet( $offset ) { |
| 455 | 457 | return isset( $this->callbacks[ $offset ] ) ? $this->callbacks[ $offset ] : null; |
| 456 | 458 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 465 | 467 | * @param mixed $offset The offset to assign the value to. |
| 466 | 468 | * @param mixed $value The value to set. |
| 467 | 469 | */ |
| | 470 | #[ReturnTypeWillChange] |
| 468 | 471 | public function offsetSet( $offset, $value ) { |
| 469 | 472 | if ( is_null( $offset ) ) { |
| 470 | 473 | $this->callbacks[] = $value; |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 482 | 485 | * |
| 483 | 486 | * @param mixed $offset The offset to unset. |
| 484 | 487 | */ |
| | 488 | #[ReturnTypeWillChange] |
| 485 | 489 | public function offsetUnset( $offset ) { |
| 486 | 490 | unset( $this->callbacks[ $offset ] ); |
| 487 | 491 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 495 | 499 | * |
| 496 | 500 | * @return array Of callbacks at current priority. |
| 497 | 501 | */ |
| | 502 | #[ReturnTypeWillChange] |
| 498 | 503 | public function current() { |
| 499 | 504 | return current( $this->callbacks ); |
| 500 | 505 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 508 | 513 | * |
| 509 | 514 | * @return array Of callbacks at next priority. |
| 510 | 515 | */ |
| | 516 | #[ReturnTypeWillChange] |
| 511 | 517 | public function next() { |
| 512 | 518 | return next( $this->callbacks ); |
| 513 | 519 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 521 | 527 | * |
| 522 | 528 | * @return mixed Returns current priority on success, or NULL on failure |
| 523 | 529 | */ |
| | 530 | #[ReturnTypeWillChange] |
| 524 | 531 | public function key() { |
| 525 | 532 | return key( $this->callbacks ); |
| 526 | 533 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 534 | 541 | * |
| 535 | 542 | * @return bool Whether the current position is valid. |
| 536 | 543 | */ |
| | 544 | #[ReturnTypeWillChange] |
| 537 | 545 | public function valid() { |
| 538 | 546 | return key( $this->callbacks ) !== null; |
| 539 | 547 | } |
| … |
… |
final class WP_Hook implements Iterator, ArrayAccess {
|
| 545 | 553 | * |
| 546 | 554 | * @link https://www.php.net/manual/en/iterator.rewind.php |
| 547 | 555 | */ |
| | 556 | #[ReturnTypeWillChange] |
| 548 | 557 | public function rewind() { |
| 549 | 558 | reset( $this->callbacks ); |
| 550 | 559 | } |