Bug #80380 [NEW]: Cannot access numeric property in ArrayObject
| From: | anton at rudnikov dot net | Date: | Thu, 19 Nov 2020 09:33:57 +0000 |
| Subject: | Bug #80380 [NEW]: Cannot access numeric property in ArrayObject | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-230451@lists.php.net to get a copy of this message | ||
From: anton at rudnikov dot net
Operating system: any
PHP version: 7.4.12
Package: *Programming Data Structures
Bug Type: Bug
Bug description:Cannot access numeric property in ArrayObject
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 bug report at https://bugs.php.net/bug.php?id=80380&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80380&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80380&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80380&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80380&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80380&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80380&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80380&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80380&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80380&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80380&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80380&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80380&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80380&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80380&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80380&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80380&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80380&r=mysqlcfg