Make WordPress Core

Changeset 51529


Ignore:
Timestamp:
08/02/2021 10:30:04 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Silence the deprecation warnings for missing return type in WP_Theme.

This fixes the "Deprecated: Return type of WP_Theme::[METHODNAME]($offset) should be compatible with ArrayAccess::[METHODNAME](): type" warnings on PHP 8.1.

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), or need to silence the deprecation warning using the #[ReturnTypeWillChange] attribute.

Follow-up to [51517].

Props jrf.
See #53635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r51328 r51529  
    557557         * @param mixed $value
    558558         */
     559        #[ReturnTypeWillChange]
    559560        public function offsetSet( $offset, $value ) {}
    560561
    … …  
    566567         * @param mixed $offset
    567568         */
     569        #[ReturnTypeWillChange]
    568570        public function offsetUnset( $offset ) {}
    569571
    … …  
    576578         * @return bool
    577579         */
     580        #[ReturnTypeWillChange]
    578581        public function offsetExists( $offset ) {
    579582                static $keys = array(
    … …  
    617620         * @return mixed
    618621         */
     622        #[ReturnTypeWillChange]
    619623        public function offsetGet( $offset ) {
    620624                switch ( $offset ) {
Note: See TracChangeset for help on using the changeset viewer.