From:             jason at amp-design dot net
Operating system: Cent OS 4
PHP version:      5CVS-2005-05-09 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Bogus error message when using ArrayAccess / References

Description:
------------
I'm not 100% sure this is considered a "bug" as such, anyway, I thought
I'd point it out, and let you decide. It's more a case of the error
message being a little fuzzy.

When trying to assign an item by reference by using the reference
operator, &, to an element inside a class that implements ArrayAccess
produces a werid error message.

Admittedly, the code I've provided is probably not valid PHP code, because
the nature of the ArrayAccess interface means that data is assigned and
returned from offsetSet and offsetGet by value, so using refernces should
probably not work.

However, the when you do try this, you get an error about about post/pre
increment/decrement. I'm not sure what this refers to, but it doesn't seem
to be very descriptive.

Reproduce code:
---------------
<?php

class ArrayAccessImpl implements ArrayAccess {
        private $data = array();

        public function offsetUnset($index) {}

        public function offsetSet($index, $value) {
                $this->data[$index] = $value;
        }

        public function offsetGet($index) {
                return $this->data[$index];
        }

        public function offsetExists($index) {
                return isset($this->data[$index]);
        }
}

$data = new ArrayAccessImpl();
$test = 'some data';
$data['element'] = &$test;

?>

Expected result:
----------------
Unsure, probably an error message relating to the fact ArrayAccess objects
can not assign by reference

Actual result:
--------------
Fatal error: Objects used as arrays in post/pre increment/decrement must
return values by reference

-- 
Edit bug report at http://bugs.php.net/?id=32983&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32983&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32983&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32983&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32983&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32983&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32983&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32983&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32983&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32983&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32983&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32983&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32983&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32983&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32983&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32983&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32983&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32983&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32983&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32983&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32983&r=mysqlcfg

Reply via email to