php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34833 Incorrect this assignment
Submitted: 2005-10-11 21:18 UTC Modified: 2005-10-11 22:39 UTC
From: stochnagara at hotmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.0RC1 OS: windows xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stochnagara at hotmail dot com
New email:
PHP Version: OS:

 

 [2005-10-11 21:18 UTC] stochnagara at hotmail dot com
Description:
------------
$this is assigned incorrectly. See the sample code below.

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

class abc {
 function a() { echo "abc::a\n"; $this->b(); }
 function b() { echo "abc::b\n"; }
}

class def {
 function c() { echo "def::c\n"; abc::a(); }
}

$test = new def();
$test->c();


Expected result:
----------------
def::c abc::a
some error message

Actual result:
--------------
def::c abc::a
Fatal error: Call to undefined method def::b() in ...php on line 4


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-11 21:26 UTC] tony2001@php.net
Declare static methods as static, this way there won't be $this at all.
This is done to keep BC with PHP4 and won't change in the nearest future.
 [2005-10-11 22:39 UTC] stochnagara at hotmail dot com
Actually "Won't Fix" is a better bug status since it is not an expected behaviour. I expect an error message for example:) But that's not important.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 01 13:01:33 2024 UTC