@@ -88,9 +88,11 @@ public function __construct(string $name = null, PhpNamespace $namespace = null)
88
88
89
89
public function __toString (): string
90
90
{
91
+ $ resolver = $ this ->namespace ? [$ this ->namespace , 'unresolveName ' ] : function ($ s ) { return $ s ; };
92
+
91
93
$ traits = [];
92
94
foreach ($ this ->traits as $ trait => $ resolutions ) {
93
- $ traits [] = 'use ' . ( $ this -> namespace ? $ this -> namespace -> unresolveName ( $ trait ) : $ trait )
95
+ $ traits [] = 'use ' . $ resolver ( $ trait )
94
96
. ($ resolutions ? " { \n\t" . implode ("; \n\t" , $ resolutions ) . "; \n} " : '; ' );
95
97
}
96
98
@@ -109,23 +111,19 @@ public function __toString(): string
109
111
. '; ' ;
110
112
}
111
113
112
- $ mapper = function (array $ arr ) {
113
- return $ this ->namespace ? array_map ([$ this ->namespace , 'unresolveName ' ], $ arr ) : $ arr ;
114
- };
115
-
116
114
return Strings::normalize (
117
115
Helpers::formatDocComment ($ this ->comment . "\n" )
118
116
. ($ this ->abstract ? 'abstract ' : '' )
119
117
. ($ this ->final ? 'final ' : '' )
120
118
. ($ this ->name ? "$ this ->type $ this ->name " : '' )
121
- . ($ this ->extends ? 'extends ' . implode (', ' , $ mapper ( (array ) $ this ->extends )) . ' ' : '' )
122
- . ($ this ->implements ? 'implements ' . implode (', ' , $ mapper ( $ this ->implements )) . ' ' : '' )
119
+ . ($ this ->extends ? 'extends ' . implode (', ' , array_map ( $ resolver , (array ) $ this ->extends )) . ' ' : '' )
120
+ . ($ this ->implements ? 'implements ' . implode (', ' , array_map ( $ resolver , $ this ->implements )) . ' ' : '' )
123
121
. ($ this ->name ? "\n" : '' ) . "{ \n"
124
122
. Strings::indent (
125
- ($ this -> traits ? implode ("\n" , $ traits ) . "\n\n" : '' )
126
- . ($ this -> consts ? implode ("\n" , $ consts ) . "\n\n" : '' )
127
- . ($ this -> properties ? implode ("\n\n" , $ properties ) . "\n\n\n" : '' )
128
- . ($ this ->methods ? implode ("\n\n\n" , $ this ->methods ) . "\n" : '' ), 1 )
123
+ ($ traits ? implode ("\n" , $ traits ) . "\n\n" : '' )
124
+ . ($ consts ? implode ("\n" , $ consts ) . "\n\n" : '' )
125
+ . ($ properties ? implode ("\n\n" , $ properties ) . "\n\n\n" : '' )
126
+ . ($ this ->methods ? implode ("\n\n\n" , $ this ->methods ) . "\n" : '' ))
129
127
. '} '
130
128
) . ($ this ->name ? "\n" : '' );
131
129
}
0 commit comments