Bug #80380 [Opn->Ver]: Cannot access numeric property in ArrayObject

From: Date: Thu, 19 Nov 2020 11:34:02 +0000
Subject: Bug #80380 [Opn->Ver]: Cannot access numeric property in ArrayObject
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230456@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80380&edit=1 ID: 80380 Updated by: cmb@php.net Reported by: anton at rudnikov dot net Summary: Cannot access numeric property in ArrayObject -Status: Open +Status: Verified Type: Bug Package: SPL related Operating System: any PHP Version: 7.4.12 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Given that numeric properties are accessible after array conversion as of PHP 7.2.0, it seems wrong that this is not the case with ArrayObjects. Previous Comments: ------------------------------------------------------------------------ [2020-11-19 09:42:17] anton at rudnikov dot net Changed package ------------------------------------------------------------------------ [2020-11-19 09:33:57] anton at rudnikov dot net Description: ------------ I pass an object to ArrayObject constructor, and trying to access its properties. I can access string properties, but I can't access numeric one Test script: --------------- <?php $object = new stdClass; $object->prop = 'test1'; $object->{'1'} = 'test2'; $arrayObject = new ArrayObject($object); echo $arrayObject['prop']; // test1 echo $arrayObject['1']; // Undefined index $arrayObject = new ArrayObject($object, ArrayObject::ARRAY_AS_PROPS); echo $arrayObject->prop; // test1 echo $arrayObject->{'1'}; // Undefined index Expected result: ---------------- test1 test2 test1 test2 Actual result: -------------- test1 Notice: Undefined index: 1 in /in/9UdHs on line 9 test1 Notice: Undefined index: 1 in /in/9UdHs on line 13 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80380&edit=1

« previous php.bugs (#230456) next »