php.net |  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
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: nikic@php.net 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:
MUST BE VALID
Solve the problem:
2 + 32 = ?
Subscribe to this entry?

 
 [2018-09-12 13:53 UTC] nikic@php.net
Description:
------------
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:
---------------
<?php

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:
--------------
Nothing

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-08 13:37 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2020-01-08 13:37 UTC] nikic@php.net
Apparently I fixed this in bug #78776 in the meantime.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC