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
 [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

Pull Requests

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: Tue Dec 03 17:01:29 2024 UTC