php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74939 Nested traits' aliased methods are lowercased
Submitted: 2017-07-17 11:45 UTC Modified: 2020-03-03 10:57 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jakub at chabek dot cz Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2017-07-17 11:45 UTC] jakub at chabek dot cz
Description:
------------
Reflection API returns lower case method name when multiple traits are nested.

Test script:
---------------
trait TraitA {
        function sameName() {}
}

trait TraitB {
        use TraitA {sameName as someOtherName;}   
        function sameName() {}   
}

class SomeClass {
        use TraitB {sameName as yetAnotherName;}   

        function sameName() {}   
}

$reflection = new \ReflectionClass(SomeClass::class);
var_dump($reflection->getMethod('someOtherName')->getName());

Expected result:
----------------
string(13) "someOtherName"

Actual result:
--------------
string(13) "someothername"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-17 15:06 UTC] requinix@php.net
-Summary: ReflectionMethod:getName returns incorrect case when nesting traits +Summary: Nested traits' methods are lowercased -Package: Reflection related +Package: Scripting Engine problem -Operating System: linux, probably irrelevant +Operating System: Irrelevant
 [2017-07-17 15:06 UTC] requinix@php.net
The lowercasing is happening in the engine - reflection is working correctly.

Showing all methods: https://3v4l.org/gqENX
T1's method is lowercased while T2's is not.
 [2017-07-17 15:06 UTC] requinix@php.net
-Summary: Nested traits' methods are lowercased +Summary: Nested traits' aliased methods are lowercased
 [2020-03-02 20:01 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2020-03-03 10:57 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC