|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42016 Call to a parent's parent non-static method statically is allowed
Submitted: 2007-07-17 06:24 UTC Modified: 2007-07-23 23:13 UTC
Avg. Score:4.3 ± 0.5
Reproduced:0 of 0 (0.0%)
From: reto at buxaprojects dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
45 - 32 = ?
Subscribe to this entry?

 [2007-07-17 06:24 UTC] reto at buxaprojects dot com
I expected, that i cannot call a non-static method in a parent's parent class with ParentClassName::method() from a child class. But it works even on E_STRICT. I think this should be a bug!

Reproduce code:
class A {
    private $myVar;   
    public function test() { 
        $this->myVar = 'test';
        echo 'A::test()' . "\n";
class B extends A { 
    public function test() { 
        echo 'B::test()' . "\n"; 
class C extends B { 
    public function test() 
        echo 'C::test()' . "\n";
$c = new C; 

Expected result:
Non-static method A::test() should not be called statically

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-17 07:51 UTC]
And why do you think this is a bug?
 [2007-07-17 08:17 UTC] reto at buxaprojects dot com
Because a non-static method should not be called statically! This should also apply for a parents parent class! Class C and B should only be able to call parent:: . If class C must access the method test() of class A, class B shouldn't override the method test().
 [2007-07-23 23:13 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

It is just the way it works. If it sees it is coming from the right context this call version doe snot enforce a static call. Instead it will simply keep $this and be happy with it.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 10:01:29 2024 UTC