Skip to content

PHP 8.4 deprecation: UnicodeString ArrayAccess methods are missing void return types #8

@savinmikhail

Description

@savinmikhail

Hi,

we are seeing PHP 8.4 deprecation notices coming from opis/string when UnicodeString is loaded.

Environment:

  • PHP 8.4.x
  • opis/json-schema 2.6.0
  • opis/string 2.1.0

The deprecations point to Opis\String\UnicodeString implementing ArrayAccess without the updated return types on:

  • offsetSet()
  • offsetUnset()

Current methods appear to be:

public function offsetSet($offset, $value)                                                                                                                                                                                        
public function offsetUnset($offset)                                                                                                                                                                                              
                                                                                                                                                                                                                                  
With PHP 8.4 we get deprecation notices like:                                                                                                                                                                                     
                                                                                                                                                                                                                                  
- Method "ArrayAccess::offsetSet()" might add "void" as a native return type declaration in the future. Do the same in implementation "Opis\String\UnicodeString" now to avoid errors or add an explicit @return annotation to    
  suppress this message.                                                                                                                                                                                                          
- Method "ArrayAccess::offsetUnset()" might add "void" as a native return type declaration in the future. Do the same in implementation "Opis\String\UnicodeString" now to avoid errors or add an explicit @return annotation to  
  suppress this message.                                                                                                                                                                                                          
                                                                                                                                                                                                                                  
From our side this is reproducible while using opis/json-schema, because it pulls in opis/string. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions