@@ -97,6 +97,11 @@ public function printClass(ClassType $class, PhpNamespace $namespace = null): st
97
97
. '; ' ;
98
98
}
99
99
100
+ $ methods = [];
101
+ foreach ($ class ->getMethods () as $ method ) {
102
+ $ methods [] = $ this ->printMethod ($ method , $ namespace );
103
+ }
104
+
100
105
return Strings::normalize (
101
106
Helpers::formatDocComment ($ class ->getComment () . "\n" )
102
107
. ($ class ->isAbstract () ? 'abstract ' : '' )
@@ -109,7 +114,7 @@ public function printClass(ClassType $class, PhpNamespace $namespace = null): st
109
114
($ traits ? implode ("\n" , $ traits ) . "\n\n" : '' )
110
115
. ($ consts ? implode ("\n" , $ consts ) . "\n\n" : '' )
111
116
. ($ properties ? implode ("\n\n" , $ properties ) . "\n\n\n" : '' )
112
- . ($ class -> getMethods () ? implode ("\n\n\n" , $ class -> getMethods () ) . "\n" : '' ))
117
+ . ($ methods ? implode ("\n\n\n" , $ methods ) . "\n" : '' ))
113
118
. '} '
114
119
) . ($ class ->getName () ? "\n" : '' );
115
120
}
@@ -132,8 +137,13 @@ public function printNamespace(PhpNamespace $namespace): string
132
137
}
133
138
}
134
139
140
+ $ classes = [];
141
+ foreach ($ namespace ->getClasses () as $ class ) {
142
+ $ classes [] = $ this ->printClass ($ class , $ namespace );
143
+ }
144
+
135
145
$ body = ($ uses ? implode ("\n" , $ uses ) . "\n\n" : '' )
136
- . implode ("\n" , $ namespace -> getClasses () );
146
+ . implode ("\n" , $ classes );
137
147
138
148
if ($ namespace ->getBracketedSyntax ()) {
139
149
return 'namespace ' . ($ name ? " $ name " : '' ) . " { \n\n"
@@ -149,10 +159,15 @@ public function printNamespace(PhpNamespace $namespace): string
149
159
150
160
public function printFile (PhpFile $ file ): string
151
161
{
162
+ $ namespaces = [];
163
+ foreach ($ file ->getNamespaces () as $ namespace ) {
164
+ $ namespaces [] = $ this ->printNamespace ($ namespace );
165
+ }
166
+
152
167
return Strings::normalize (
153
168
"<?php \n"
154
169
. ($ file ->getComment () ? "\n" . Helpers::formatDocComment ($ file ->getComment () . "\n" ) . "\n" : '' )
155
- . implode ("\n\n" , $ file -> getNamespaces () )
170
+ . implode ("\n\n" , $ namespaces )
156
171
) . "\n" ;
157
172
}
158
173
0 commit comments