ID:               36566
 User updated by:  stochnagara at hotmail dot com
 Reported By:      stochnagara at hotmail dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Class/Object related
 Operating System: win xp
 PHP Version:      5CVS-2006-03-01 (CVS)
 New Comment:

I've just simplified that test example to match bug reporting
requirements for a short example.
I will extend it a little so you can understand what I mean.
I have a function called objectPool which returns an object of class
Pool. Class Pool has a method
__get which return an instance of an ORM class. The ORM class itself
binds offsetUnset($id) to
DELETE FROM table WHERE id=$id.
I have a function that gets two parametes - $id and $module. I
guarantee that this function receives correct
parameters. I intended to use 'unset (objectPool()->$module[$id]);' so
i get the ORM class for the module $module
and delete its record with id $id. Unfortunately, PHP echoes the fatal
error about the empty property.
Now my workaround is this:
        $q = objectPool()->$module;
        unset ($q[$id]);
which works perfect. I think that 'unset (objectPool()->$module[$id]);'
should also work perfect.

P.S. I've tested offsetExists, offsetSet and offsetUnset are also
buggy. offsetSet also raises a fatal error,
offsetExists always returns false and offsetGet returns as if it were
'objectPool()->$module' instead of
'objectPool()->$module[$id]'


Previous Comments:
------------------------------------------------------------------------

[2006-03-01 08:37:48] [EMAIL PROTECTED]

<?php
$m = 'o';
$p = 5;
var_dump($m[$p]);
?>
What do you expect to get in this case?
NOT empty result? Why?


------------------------------------------------------------------------

[2006-03-01 08:29:18] stochnagara at hotmail dot com

Description:
------------
when property and array overloading is used in a combination with a
property and array offset taken from variable,
not from constants, PHP fails with 'cannot access empty property
message' which is wrong.

Reproduce code:
---------------
<?
class foo_1 implements ArrayAccess {
        function offsetGet($q){}
        function offsetSet($q,$r){}
        function offsetExists($q){}
        function offsetUnset ($q) {
                echo "unset successful";
        }
}
class foo_2 {
        function __get($q) {
                return new foo_1;
        }
}
$f = new foo2;
$m = 'o';
$p = 5;
unset ($f->$m[$p]);

Expected result:
----------------
unset successful

Actual result:
--------------
Cannot access empty property


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36566&edit=1

Reply via email to