|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47891 static method bound to calling object
Submitted: 2009-04-03 16:36 UTC Modified: 2009-04-03 16:52 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: slava at forma dot kharkov dot ua Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.2.9 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-04-03 16:36 UTC] slava at forma dot kharkov dot ua
this code prints instance of object "b" and doesn't throw any errors or exceptions. If a::stat has modificator "static" it says "Notice: Undefined variable: this" and prints null.

Reproduce code:
class a
	public function stat()

class b
	public function test()

$b= new b();

Expected result:
throws some errors or exceptions. 

Actual result:
prints instance of object "b"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-03 16:52 UTC]
This is expected, :: calls a method of a class using th current context as call context. Hence $this in a::stat is a b object. It will issue a Strict warning.

It's kept that way in PHP5 for PHP4 backward compatibility reasons but it may be cleaned up in PHP6.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Aug 06 04:01:23 2021 UTC