File tree Expand file tree Collapse file tree 6 files changed +32
-13
lines changed
Expand file tree Collapse file tree 6 files changed +32
-13
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ public function fromClassReflection(
8484 }
8585 $ class ->setProperties ($ props );
8686
87- $ methods = [];
87+ $ methods = $ resolutions = [];
8888 foreach ($ from ->getMethods () as $ method ) {
8989 $ realMethod = Reflection::getMethodDeclaringMethod ($ method );
9090 $ declaringClass = ($ materializeTraits ? $ method : $ realMethod )->getDeclaringClass ();
@@ -103,12 +103,21 @@ public function fromClassReflection(
103103 }
104104 }
105105 }
106+
107+ $ modifier = $ realMethod ->getModifiers () !== $ method ->getModifiers ()
108+ ? ' ' . $ this ->getVisibility ($ method )
109+ : null ;
110+ $ alias = $ realMethod ->name !== $ method ->name ? ' ' . $ method ->name : '' ;
111+ if ($ modifier || $ alias ) {
112+ $ resolutions [] = $ realMethod ->name . ' as ' . $ modifier . $ alias ;
113+ }
106114 }
107115 $ class ->setMethods ($ methods );
108116
109117 if (!$ materializeTraits ) {
110118 foreach ($ from ->getTraitNames () as $ trait ) {
111- $ class ->addTrait ($ trait );
119+ $ class ->addTrait ($ trait , $ resolutions );
120+ $ resolutions = [];
112121 }
113122 }
114123
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ class Class3 extends ParentClass
108108 }
109109
110110
111- public function aliased()
111+ protected function aliased()
112112 {
113113 echo 'Trait1::f1';
114114 }
@@ -144,7 +144,7 @@ class Class5
144144 public $x1;
145145
146146
147- public function f1()
147+ private function f1()
148148 {
149149 echo 'Trait1b::f1';
150150 }
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class Class3 extends ParentClass
9797 }
9898
9999
100- public function aliased()
100+ protected function aliased()
101101 {
102102 }
103103}
@@ -129,7 +129,7 @@ class Class5
129129 public $x1;
130130
131131
132- public function f1()
132+ private function f1()
133133 {
134134 }
135135}
Original file line number Diff line number Diff line change @@ -62,7 +62,9 @@ class Class2 extends ParentClass
6262
6363class Class3 extends ParentClass
6464{
65- use Trait2;
65+ use Trait2 {
66+ f1 as protected aliased;
67+ }
6668
6769 /** info */
6870 public $x1;
@@ -86,6 +88,8 @@ class Class4 extends ParentClass
8688
8789class Class5
8890{
89- use Trait1;
91+ use Trait1 {
92+ f1 as private;
93+ }
9094 use Trait1b;
9195}
Original file line number Diff line number Diff line change @@ -57,7 +57,9 @@ class Class2 extends ParentClass
5757
5858class Class3 extends ParentClass
5959{
60- use Trait2;
60+ use Trait2 {
61+ f1 as protected aliased;
62+ }
6163
6264 /** info */
6365 public $x1;
@@ -79,6 +81,8 @@ class Class4 extends ParentClass
7981
8082class Class5
8183{
82- use Trait1;
84+ use Trait1 {
85+ f1 as private;
86+ }
8387 use Trait1b;
8488}
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ public function f1()
6767class Class3 extends ParentClass
6868{
6969 use Trait2 {
70- Trait2::f1 as aliased;
70+ f1 as protected aliased;
71+ f1 as private ; // ignored because Class3::f1() exists
7172 }
7273
7374 /** info */
@@ -84,7 +85,7 @@ public function f1()
8485class Class4 extends ParentClass
8586{
8687 use Trait2 {
87- Trait2:: f1 as aliased;
88+ f1 as protected aliased; // ignored because Class4::aliased() exists
8889 }
8990
9091
@@ -107,6 +108,7 @@ public function f1()
107108class Class5
108109{
109110 use Trait1, Trait1b {
110- Trait1b::f1 insteadof Trait1;
111+ Trait1b::f1 insteadof Trait1; // not yet supported
112+ Trait1b::f1 as private ;
111113 }
112114}
You can’t perform that action at this time.
0 commit comments