#42775 [NEW]: BC safe refactorings of ArrayAccess and descendants

From: Date: Thu, 27 Sep 2007 06:26:24 +0000
Subject: #42775 [NEW]: BC safe refactorings of ArrayAccess and descendants
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-117891@lists.php.net to get a copy of this message
From: david dot nqd at gmail dot com Operating system: N/A PHP version: 5.2.4 PHP Bug Type: Feature/Change Request Bug description: BC safe refactorings of ArrayAccess and descendants Description: ------------ A new interface called 'AppendableArrayAccess' that extends ArrayAccess (and be implemented by ArrayIterator and ArrayObject). This new interface is simply a push up of the append() method from ArrayIterator and ArrayObject. Reproduce code: --------------- <?php class Example implements AppendableArrayAccess { public $array; public function __construct () { $this->array = array(); } public function offsetGet($offset) { return $this->array[$offset]; } public function offsetSet($offset, $value) { $this->array[$offset] = $value; } public function offsetExists($offset) { return isset($this->array[$offset]); } public function offsetUnset($offset) { unset($this->array[$offset]); } } $x = new Example(); $x[] = "abc"; $x[] = "def"; var_dump($x->array); ?> Expected result: ---------------- // Using ArrayAccess as opposed to AppendableArrayAccess // which doesn't currently exist the array: array('def') Actual result: -------------- the array: array('abc', 'def') -- Edit bug report at http://bugs.php.net/?id=42775&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42775&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42775&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42775&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42775&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42775&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42775&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42775&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42775&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42775&r=support Expected behavior: http://bugs.php.net/fix.php?id=42775&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42775&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42775&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42775&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42775&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42775&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42775&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42775&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42775&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42775&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42775&r=mysqlcfg

« previous php.bugs (#117891) next »