WordPress.org

Make WordPress Core

Ticket #53635: 53635-WP_Theme-arrayaccess.patch

File 53635-WP_Theme-arrayaccess.patch, 1.7 KB (added by jrf, 2 months ago)

Fix various "Deprecated: Return type of WP_Theme::[METHODNAME]($offset) should either be compatible with ArrayAccess::[METHODNAME](): type, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice"

  • src/wp-includes/class-wp-theme.php

    From 82ebaa6591dd79d7c68d67d939584bb6dab27d71 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Fri, 23 Jul 2021 03:12:46 +0200
    Subject: [PATCH 2/2] PHP 8.1: WP_Theme: 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-theme.php | 4 ++++
     1 file changed, 4 insertions(+)
    
    diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php
    index a3c996e59f..d0607528b5 100644
    a b final class WP_Theme implements ArrayAccess { 
    556556         * @param mixed $offset
    557557         * @param mixed $value
    558558         */
     559        #[ReturnTypeWillChange]
    559560        public function offsetSet( $offset, $value ) {}
    560561
    561562        /**
    final class WP_Theme implements ArrayAccess { 
    565566         *
    566567         * @param mixed $offset
    567568         */
     569        #[ReturnTypeWillChange]
    568570        public function offsetUnset( $offset ) {}
    569571
    570572        /**
    final class WP_Theme implements ArrayAccess { 
    575577         * @param mixed $offset
    576578         * @return bool
    577579         */
     580        #[ReturnTypeWillChange]
    578581        public function offsetExists( $offset ) {
    579582                static $keys = array(
    580583                        'Name',
    final class WP_Theme implements ArrayAccess { 
    616619         * @param mixed $offset
    617620         * @return mixed
    618621         */
     622        #[ReturnTypeWillChange]
    619623        public function offsetGet( $offset ) {
    620624                switch ( $offset ) {
    621625                        case 'Name':