#33710 [Ver->Csd]: ArrayAccess objects doen't initialize $this

From: Date: Tue, 19 Jul 2005 07:34:53 +0000
Subject: #33710 [Ver->Csd]: ArrayAccess objects doen't initialize $this
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-82119@lists.php.net to get a copy of this message
 ID:               33710
 Updated by:       dmitry@php.net
 Reported By:      pornel at despammed dot com
-Status:           Verified
+Status:           Closed
 Bug Type:         Class/Object related
 Operating System: *
 PHP Version:      5.1.0b3
-Assigned To:      
+Assigned To:      dmitry
 New Comment:

Fixed in CVS HEAD and PHP_5_0.

The test case produces memory leaks in PHP_5_0.
These leaks are fixed in HEAD only.


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

[2005-07-15 15:14:35] pornel at despammed dot com

Description:
------------
In object that implements ArrayAccess and accesses itself as array
inside its own method, $this is not available ("Undefined variable:
this")


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

class Foo implements ArrayAccess
{
	function offsetExists ($offset) {/*...*/}
 	function offsetGet ($offset) {/*...*/}
 	function offsetSet ($offset, $value) {/*...*/}
 	function offsetUnset ($offset) {/*...*/}

 	function fail()
 	{
	 	$this['blah'];
 	}

 	function succeed()
 	{
	 	$this;
	 	$this['blah'];
 	}

}

$bar = new Foo();
$bar->succeed();
$bar->fail();



Expected result:
----------------
No error. Both methods should work.

Actual result:
--------------
Notice: Undefined variable: this in c:\www\test.php5 on line 13


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


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


Thread (3 messages)

« previous php.bugs (#82119) next »