Bug #66041 [NEW]: list() fails to unpack yielded ArrayAccess object

From: Date: Thu, 07 Nov 2013 04:39:24 +0000
Subject: Bug #66041 [NEW]: list() fails to unpack yielded ArrayAccess object
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182623@lists.php.net to get a copy of this message
From: stoffle at gmail dot com Operating system: OS X 10.8.5 - Mountain Lion PHP version: 5.5.5 Package: Scripting Engine problem Bug Type: Bug Bug description:list() fails to unpack yielded ArrayAccess object Description: ------------ Using list() to unpack the elements of an object (that implements ArrayAccess) provided via Generator::send() unpacks to NULL values. This issue occurs both with SPL objects that implement ArrayAccess (as in the example) and user-land objects. It does not affect arrays. When using a user-land object, offsetGet() is never called. Workaround: Keeping a reference to the yielded object inside the generator seems to make list() work as expected (see https://gist.github.com/jmalloc/7348967#file-workaround-php). Test script: --------------- <?php function dumpElement() { list($value) = yield; var_dump($value); }; $fixedArray = new SplFixedArray(1); $fixedArray[0] = 'the element'; $generator = dumpElement(); $generator->send($fixedArray); Expected result: ---------------- string(11) "the element" Actual result: -------------- NULL -- Edit bug report at https://bugs.php.net/bug.php?id=66041&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66041&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66041&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66041&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66041&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66041&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66041&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66041&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66041&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66041&r=support Expected behavior: https://bugs.php.net/fix.php?id=66041&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66041&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66041&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66041&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66041&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66041&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66041&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66041&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66041&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66041&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66041&r=mysqlcfg

« previous php.bugs (#182623) next »