|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-11-07 03:10 UTC] laruence@php.net
-Type: Bug
+Type: Feature/Change Request
[2022-04-22 13:32 UTC] ilutov@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: ilutov
[2022-04-22 13:32 UTC] ilutov@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 10:00:02 2025 UTC |
Description: ------------ Attempting to use instances of class SplObjectStorage as an array results in exceptions and generally does not work as expected. Test script: --------------- $s = new SplObjectStorage; $o = new stdClass; $s[$o]["key"] = "value"; var_export($s[$o]); // Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Object not found' Expected result: ---------------- The above sample code should create an array for the object key inside SplObjectStorage, and display: array ( 'key' => 'value', ) Compare the above code with: $s = array(); $o = "someKey"; $s[$o]["key"] = "value"; var_export($s[$o]); which works as expected and displays array ( 'key' => 'value', ) Actual result: -------------- Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Object not found' in Command line code:1 Stack trace: #0 Command line code(1): SplObjectStorage->offsetGet(Object(stdClass)) #1 {main} thrown in Command line code on line 1