nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.
https://doc.nette.org/php-generator
Other
2.11k stars 138 forks source link

Fix PSR namespaces #114

Closed Jeroeny closed 2 years ago

Jeroeny commented 2 years ago

The PSR standard(s) seem to indicate that they use a newline between use statements of different types (class, function and const). It would be nice if this could be supported

dg commented 2 years ago

Thanks!

dg commented 2 years ago

What is the $psrSort for?

Jeroeny commented 2 years ago

What is the $psrSort for?

It fixes the namespace sort:

before

namespace Example;

use Example\Foo\EmailAlias\Bar;
use Example\Foo\Email\Test;
use Example\Foo\MyClass;
use Example\Foo\Other;

after

namespace Example;

use Example\Foo\Email\Test;
use Example\Foo\EmailAlias\Bar;
use Example\Foo\MyClass;
use Example\Foo\Other;

Maybe it can be supported but not by default enabled in any printer?

dg commented 2 years ago

@Jeroeny okay, I'm gonna use that as the default sort.