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(
84
84
}
85
85
$ class ->setProperties ($ props );
86
86
87
- $ methods = [];
87
+ $ methods = $ resolutions = [];
88
88
foreach ($ from ->getMethods () as $ method ) {
89
89
$ realMethod = Reflection::getMethodDeclaringMethod ($ method );
90
90
$ declaringClass = ($ materializeTraits ? $ method : $ realMethod )->getDeclaringClass ();
@@ -103,12 +103,21 @@ public function fromClassReflection(
103
103
}
104
104
}
105
105
}
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
+ }
106
114
}
107
115
$ class ->setMethods ($ methods );
108
116
109
117
if (!$ materializeTraits ) {
110
118
foreach ($ from ->getTraitNames () as $ trait ) {
111
- $ class ->addTrait ($ trait );
119
+ $ class ->addTrait ($ trait , $ resolutions );
120
+ $ resolutions = [];
112
121
}
113
122
}
114
123
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ class Class3 extends ParentClass
108
108
}
109
109
110
110
111
- public function aliased()
111
+ protected function aliased()
112
112
{
113
113
echo 'Trait1::f1';
114
114
}
@@ -144,7 +144,7 @@ class Class5
144
144
public $x1;
145
145
146
146
147
- public function f1()
147
+ private function f1()
148
148
{
149
149
echo 'Trait1b::f1';
150
150
}
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class Class3 extends ParentClass
97
97
}
98
98
99
99
100
- public function aliased()
100
+ protected function aliased()
101
101
{
102
102
}
103
103
}
@@ -129,7 +129,7 @@ class Class5
129
129
public $x1;
130
130
131
131
132
- public function f1()
132
+ private function f1()
133
133
{
134
134
}
135
135
}
Original file line number Diff line number Diff line change @@ -62,7 +62,9 @@ class Class2 extends ParentClass
62
62
63
63
class Class3 extends ParentClass
64
64
{
65
- use Trait2;
65
+ use Trait2 {
66
+ f1 as protected aliased;
67
+ }
66
68
67
69
/** info */
68
70
public $x1;
@@ -86,6 +88,8 @@ class Class4 extends ParentClass
86
88
87
89
class Class5
88
90
{
89
- use Trait1;
91
+ use Trait1 {
92
+ f1 as private;
93
+ }
90
94
use Trait1b;
91
95
}
Original file line number Diff line number Diff line change @@ -57,7 +57,9 @@ class Class2 extends ParentClass
57
57
58
58
class Class3 extends ParentClass
59
59
{
60
- use Trait2;
60
+ use Trait2 {
61
+ f1 as protected aliased;
62
+ }
61
63
62
64
/** info */
63
65
public $x1;
@@ -79,6 +81,8 @@ class Class4 extends ParentClass
79
81
80
82
class Class5
81
83
{
82
- use Trait1;
84
+ use Trait1 {
85
+ f1 as private;
86
+ }
83
87
use Trait1b;
84
88
}
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ public function f1()
67
67
class Class3 extends ParentClass
68
68
{
69
69
use Trait2 {
70
- Trait2::f1 as aliased;
70
+ f1 as protected aliased;
71
+ f1 as private ; // ignored because Class3::f1() exists
71
72
}
72
73
73
74
/** info */
@@ -84,7 +85,7 @@ public function f1()
84
85
class Class4 extends ParentClass
85
86
{
86
87
use Trait2 {
87
- Trait2:: f1 as aliased;
88
+ f1 as protected aliased; // ignored because Class4::aliased() exists
88
89
}
89
90
90
91
@@ -107,6 +108,7 @@ public function f1()
107
108
class Class5
108
109
{
109
110
use Trait1, Trait1b {
110
- Trait1b::f1 insteadof Trait1;
111
+ Trait1b::f1 insteadof Trait1; // not yet supported
112
+ Trait1b::f1 as private ;
111
113
}
112
114
}
You can’t perform that action at this time.
0 commit comments