php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73853 Aliasing a method still throws errors about static / non-static
Submitted: 2017-01-02 21:54 UTC Modified: 2017-01-11 20:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: bowersbros at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bowersbros at gmail dot com
New email:
PHP Version: OS:

 

 [2017-01-02 21:54 UTC] bowersbros at gmail dot com
Description:
------------
A method that is declared as static, and has a trait override the method that is non-static, but is aliased, a fatal error is still thrown, even though it is aliased.

Example: https://3v4l.org/Ig0Al

Test script:
---------------
<?php

trait MyTest
{
    public function name()
    {
        return 'other string';
    }
}

abstract class Testing
{
    public static function name()
    {
        return 'string';
    }
}

class AnotherExample extends Testing
{
    use MyTest {
        MyTest::name as newName;
    }
}




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-11 05:03 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2017-01-11 05:03 UTC] krakjoe@php.net
There are mistakes or incorrect assumptions in your code.
 [2017-01-11 20:53 UTC] nikic@php.net
To expand on Joe's comment, the problem is that aliasing in trait resolution is just that: Aliasing. If you alias something, both the old *and* the new name are present. It's stupid behavior IMHO, but this is how it works.

See https://3v4l.org/jcoA9.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 13:00:02 2026 UTC