@@ -24,6 +24,8 @@ class Printer
24
24
public string $ indentation = "\t" ;
25
25
public int $ linesBetweenProperties = 0 ;
26
26
public int $ linesBetweenMethods = 2 ;
27
+ public int $ linesBetweenNamespaceTypes = 0 ;
28
+ public bool $ psrSortNamespaces = false ;
27
29
public string $ returnTypeColon = ': ' ;
28
30
public bool $ bracesOnNextLine = true ;
29
31
protected ?PhpNamespace $ namespace = null ;
@@ -256,7 +258,9 @@ public function printNamespace(PhpNamespace $namespace): string
256
258
$ this ->namespace = $ this ->resolveTypes ? $ namespace : null ;
257
259
$ name = $ namespace ->getName ();
258
260
$ uses = $ this ->printUses ($ namespace )
261
+ . str_repeat ("\n" , $ this ->linesBetweenNamespaceTypes )
259
262
. $ this ->printUses ($ namespace , PhpNamespace::NameFunction)
263
+ . str_repeat ("\n" , $ this ->linesBetweenNamespaceTypes )
260
264
. $ this ->printUses ($ namespace , PhpNamespace::NameConstant);
261
265
262
266
$ items = [];
@@ -305,9 +309,8 @@ protected function printUses(PhpNamespace $namespace, string $of = PhpNamespace:
305
309
PhpNamespace::NameFunction => 'function ' ,
306
310
PhpNamespace::NameConstant => 'const ' ,
307
311
][$ of ];
308
- $ name = $ namespace ->getName ();
309
312
$ uses = [];
310
- foreach ($ namespace ->getUses ($ of ) as $ alias => $ original ) {
313
+ foreach ($ namespace ->getUses ($ of, $ this -> psrSortNamespaces ) as $ alias => $ original ) {
311
314
$ uses [] = Helpers::extractShortName ($ original ) === $ alias
312
315
? "use $ prefix$ original; \n"
313
316
: "use $ prefix$ original as $ alias; \n" ;
0 commit comments