php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81411 Casting object with numeric keys to array
Submitted: 2021-09-03 08:57 UTC Modified: -
From: biziclop at vipmail dot hu Assigned:
Status: Open Package: Arrays related
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: biziclop at vipmail dot hu
New email:
PHP Version: OS:

 

 [2021-09-03 08:57 UTC] biziclop at vipmail dot hu
Description:
------------
---
From manual page:  
https://www.php.net/manual/en/language.types.array.php#language.types.array.casting
---

"with a few notable exceptions: integer properties are unaccessible"  

This is fortunately untrue since PHP 7.2:  

https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts  

The reverse direction (array to object casts) are already documented:  
https://www.php.net/manual/en/language.types.object.php#language.types.object.casting

"Note that in this case before PHP 7.2.0 numeric keys have been inaccessible unless iterated."

Test script:
---------------
https://3v4l.org/cJPlX


Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC