#49331 [Opn]: extract(array('this' => 'abc')) in obj method

From: Date: Sat, 22 Aug 2009 16:36:50 +0000
Subject: #49331 [Opn]: extract(array('this' => 'abc')) in obj method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-141394@lists.php.net to get a copy of this message
 ID:               49331
 User updated by:  shenkong@php.net
 Reported By:      shenkong@php.net
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: win7
 PHP Version:      5.3.0
 New Comment:

class B {
    public function test1() {
        echo 'b';
    }
}
class A {
    public function test($arr) {
        extract($arr);
        var_dump($this);
        $this->test1();
    }
    public function test1() {
        echo 'a';
    }
}
$a = new A;
$b = new B;
$arr['this'] = $b;
$a->test($arr);

-----
object(B)#2 (0) {
}
a


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

[2009-08-22 16:23:11] shenkong@php.net

Description:
------------
class A {
    public function test() {
        var_dump($this);
        $this = 'oh, mygod';
        var_dump($this);
    }
}
$a = new A;
$a->test();

Fatal error: Cannot re-assign $this in D:\www\testthis.php on line 13


Reproduce code:
---------------
class A {
    public function test($arr) {
        var_dump($this);
        extract($arr);
        var_dump($this);
    }
}
$a = new A;
$arr['this'] = 'abc';
$a->test($arr);



Expected result:
----------------
Fatal error: Cannot re-assign $this in D:\www\testthis.php on line 13


Actual result:
--------------
it's ok!


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


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



Thread (3 messages)

« previous php.bugs (#141394) next »