@@ -116,14 +116,10 @@ public function __toString()
116
116
. "; \n" ;
117
117
}
118
118
119
- $ extends = (array ) $ this ->extends ;
120
- $ implements = $ this ->implements ;
121
- $ traits = $ this ->traits ;
122
- if ($ this ->namespace ) {
123
- $ extends = array_map (array ($ this ->namespace , 'unresolveName ' ), $ extends );
124
- $ implements = array_map (array ($ this ->namespace , 'unresolveName ' ), $ implements );
125
- $ traits = array_map (array ($ this ->namespace , 'unresolveName ' ), $ traits );
126
- }
119
+ $ namespace = $ this ->namespace ?: new PhpNamespace ;
120
+ $ mapper = function (array $ arr ) use ($ namespace ) {
121
+ return array_map (array ($ namespace , 'unresolveName ' ), $ arr );
122
+ };
127
123
128
124
foreach ($ this ->methods as $ method ) {
129
125
$ method ->setNamespace ($ this ->namespace );
@@ -135,11 +131,11 @@ public function __toString()
135
131
. ($ this ->final ? 'final ' : '' )
136
132
. $ this ->type . ' '
137
133
. $ this ->name . ' '
138
- . ($ extends ? 'extends ' . implode (', ' , $ extends ) . ' ' : '' )
139
- . ($ implements ? 'implements ' . implode (', ' , $ implements ) . ' ' : '' )
134
+ . ($ this -> extends ? 'extends ' . implode (', ' , $ mapper (( array ) $ this -> extends ) ) . ' ' : '' )
135
+ . ($ this -> implements ? 'implements ' . implode (', ' , $ mapper ( $ this -> implements ) ) . ' ' : '' )
140
136
. "\n{ \n"
141
137
. Strings::indent (
142
- ($ traits ? 'use ' . implode ("; \nuse " , $ traits ) . "; \n\n" : '' )
138
+ ($ this -> traits ? 'use ' . implode ("; \nuse " , $ mapper ( $ this -> traits ) ) . "; \n\n" : '' )
143
139
. ($ this ->consts ? implode ('' , $ consts ) . "\n" : '' )
144
140
. ($ this ->properties ? implode ("\n" , $ properties ) . "\n" : '' )
145
141
. ($ this ->methods ? "\n" . implode ("\n\n\n" , $ this ->methods ) . "\n\n" : '' ), 1 )
0 commit comments