@@ -82,9 +82,11 @@ public function __construct(string $name = null, PhpNamespace $namespace = null)
82
82
83
83
public function __toString (): string
84
84
{
85
+ $ resolver = $ this ->namespace ? [$ this ->namespace , 'unresolveName ' ] : function ($ s ) { return $ s ; };
86
+
85
87
$ traits = [];
86
88
foreach ($ this ->traits as $ trait => $ resolutions ) {
87
- $ traits [] = 'use ' . ( $ this -> namespace ? $ this -> namespace -> unresolveName ( $ trait ) : $ trait )
89
+ $ traits [] = 'use ' . $ resolver ( $ trait )
88
90
. ($ resolutions ? " { \n\t" . implode ("; \n\t" , $ resolutions ) . "; \n} " : '; ' );
89
91
}
90
92
@@ -103,23 +105,19 @@ public function __toString(): string
103
105
. '; ' ;
104
106
}
105
107
106
- $ mapper = function (array $ arr ) {
107
- return $ this ->namespace ? array_map ([$ this ->namespace , 'unresolveName ' ], $ arr ) : $ arr ;
108
- };
109
-
110
108
return Strings::normalize (
111
109
Helpers::formatDocComment ($ this ->comment . "\n" )
112
110
. ($ this ->abstract ? 'abstract ' : '' )
113
111
. ($ this ->final ? 'final ' : '' )
114
112
. ($ this ->name ? "$ this ->type $ this ->name " : '' )
115
- . ($ this ->extends ? 'extends ' . implode (', ' , $ mapper ( (array ) $ this ->extends )) . ' ' : '' )
116
- . ($ this ->implements ? 'implements ' . implode (', ' , $ mapper ( $ this ->implements )) . ' ' : '' )
113
+ . ($ this ->extends ? 'extends ' . implode (', ' , array_map ( $ resolver , (array ) $ this ->extends )) . ' ' : '' )
114
+ . ($ this ->implements ? 'implements ' . implode (', ' , array_map ( $ resolver , $ this ->implements )) . ' ' : '' )
117
115
. ($ this ->name ? "\n" : '' ) . "{ \n"
118
116
. Strings::indent (
119
- ($ this -> traits ? implode ("\n" , $ traits ) . "\n\n" : '' )
120
- . ($ this -> consts ? implode ("\n" , $ consts ) . "\n\n" : '' )
121
- . ($ this -> properties ? implode ("\n\n" , $ properties ) . "\n\n\n" : '' )
122
- . ($ this ->methods ? implode ("\n\n\n" , $ this ->methods ) . "\n" : '' ), 1 )
117
+ ($ traits ? implode ("\n" , $ traits ) . "\n\n" : '' )
118
+ . ($ consts ? implode ("\n" , $ consts ) . "\n\n" : '' )
119
+ . ($ properties ? implode ("\n\n" , $ properties ) . "\n\n\n" : '' )
120
+ . ($ this ->methods ? implode ("\n\n\n" , $ this ->methods ) . "\n" : '' ))
123
121
. '} '
124
122
) . ($ this ->name ? "\n" : '' );
125
123
}
0 commit comments