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

 ID:                 54984
 Updated by:         fel...@php.net
 Reported by:        pwharman at gmail dot com
 Summary:            ArrayObject creates invalid variable reference
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            SPL related
 Operating System:   Windows/Linux
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

This makes no sense, Are you reproducing it just with this posted test script?!


Previous Comments:
------------------------------------------------------------------------
[2011-06-03 12:49:42] pwharman at gmail dot com

Description:
------------
If ArrayAccess is extended and then the subclass accessed using object notation 
then unpredicatable results occur. In the test script below an undefined 
variable $xyz is somehow referencing the ArrayObject subclass Foo.



The same result occurs on Linux systems.



This came to light when using an unitialised value in the Zend Framework 
Zend_Registry class, although it is not limited to that.

Test script:
---------------
<?php

class Foo extends ArrayObject{

    public function __construct(){

        parent::__construct(array(), parent::ARRAY_AS_PROPS);

    }

}

$f = new Foo;

$f->Foo['bar'] = 1;

var_dump($xyz['xyz']); # This should throw a warning then null??

?>

Expected result:
----------------
PHP Notice:  Undefined index:  Foo in C:\jirasource\ABC\sites\partners.rfp-gener

ator.com\web\test.html.php on line 8

PHP Stack trace:

PHP   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht

ml.php:0



Notice: Undefined index:  Foo in C:\jirasource\ABC\sites\partners.rfp-generator.

com\web\test.html.php on line 8



Call Stack:

    0.0212      60112   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat

or.com\web\test.html.php:0



PHP Notice:  Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-gen

erator.com\web\test.html.php on line 9

PHP Stack trace:

PHP   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht

ml.php:0



Notice: Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-generato

r.com\web\test.html.php on line 9



Call Stack:

    0.0212      60112   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat

or.com\web\test.html.php:0



PHP Notice:  Undefined index:  xyz in C:\jirasource\ABC\sites\partners.rfp-gener

ator.com\web\test.html.php on line 9

PHP Stack trace:

PHP   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht

ml.php:0



Notice: Undefined index:  xyz in C:\jirasource\ABC\sites\partners.rfp-generator.

com\web\test.html.php on line 9



Call Stack:

    0.0212      60112   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat

or.com\web\test.html.php:0



null

Actual result:
--------------
PHP Notice:  Undefined index:  Foo in C:\jirasource\ABC\sites\partners.rfp-gener

ator.com\web\test.html.php on line 8

PHP Stack trace:

PHP   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht

ml.php:0



Notice: Undefined index:  Foo in C:\jirasource\ABC\sites\partners.rfp-generator.

com\web\test.html.php on line 8



Call Stack:

    0.0212      60112   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat

or.com\web\test.html.php:0



PHP Notice:  Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-gen

erator.com\web\test.html.php on line 9

PHP Stack trace:

PHP   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht

ml.php:0



Notice: Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-generato

r.com\web\test.html.php on line 9



Call Stack:

    0.0212      60112   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat

or.com\web\test.html.php:0



PHP Notice:  Undefined index:  xyz in C:\jirasource\ABC\sites\partners.rfp-gener

ator.com\web\test.html.php on line 9

PHP Stack trace:

PHP   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht

ml.php:0



Notice: Undefined index:  xyz in C:\jirasource\ABC\sites\partners.rfp-generator.

com\web\test.html.php on line 9



Call Stack:

    0.0212      60112   1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat

or.com\web\test.html.php:0



array(1) {

  ["bar"]=>

  int(1)

}




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



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

Reply via email to