|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76870 Can override static with non-static method if imported by trait
Submitted: 2018-09-12 13:53 UTC Modified: 2020-01-08 13:37 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: Irrelevant 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:
24 + 47 = ?
Subscribe to this entry?

 [2018-09-12 13:53 UTC]
An abstract static method can be overridden by a non-static method in a child class if it originates from a trait. Usually this would generate a compile error.

Test script:

trait T {
    public function foo() {}

abstract class A {
    abstract static function foo();

class B extends A {
    // This throws an error:
    // Cannot make static method A::foo() non static in class B
    //public function foo() {}

    // This doesn't:
    use T;

Expected result:
Fatal error: Cannot make static method A::foo() non static in class B

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-08 13:37 UTC]
-Status: Open +Status: Duplicate
 [2020-01-08 13:37 UTC]
Apparently I fixed this in bug #78776 in the meantime.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 03:05:53 2022 UTC