Req #52308 [NEW]: ArrayAccess does not automatically $obj[] = $x

From: Date: Sun, 11 Jul 2010 15:50:53 +0000
Subject: Req #52308 [NEW]: ArrayAccess does not automatically $obj[] = $x
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4673@lists.php.net to get a copy of this message
From: ch Operating system: PHP version: Irrelevant Package: Documentation problem Bug Type: Feature/Change Request Bug description:ArrayAccess does not automatically $obj[] = $x Description: ------------ When implementing the ArrayAccess Interface one could be tempted to think that if "$obj[3] = $x" works, the common syntax "$obj[] = $x" would work as well. But it doesn't. For this to work one has to enhance the offsetSet() method. As it's only a one-liner I propose to put it into the example code on http://de2.php.net/manual/en/class.arrayaccess.php Expected result: ---------------- public function offsetSet($offset, $value) { if ($offset == "") $this->container[] = $value; else $this->container[$offset] = $value; } Actual result: -------------- public function offsetSet($offset, $value) { $this->container[$offset] = $value; } -- Edit bug report at http://bugs.php.net/bug.php?id=52308&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52308&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52308&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52308&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52308&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52308&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52308&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52308&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52308&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52308&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52308&r=support Expected behavior: http://bugs.php.net/fix.php?id=52308&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52308&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52308&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52308&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52308&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52308&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52308&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52308&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52308&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52308&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52308&r=mysqlcfg

« previous php.doc.bugs (#4673) next »