php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49331 extract(array('this' => 'abc')) in obj method
Submitted: 2009-08-22 16:23 UTC Modified: 2009-08-24 14:45 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: shenkong@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.0 OS: win7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shenkong@php.net
New email:
PHP Version: OS:

 

 [2009-08-22 16:23 UTC] 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!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-22 16:36 UTC] shenkong@php.net
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
 [2009-08-24 14:45 UTC] jani@php.net
See bug #47409, and next time: SEARCH BEFORE REPORTING SAME SHIT AGAIN! You haven't really earned the right to use @php.net address..
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 28 09:00:02 2025 UTC