PHP Integrator adds extra lines between use statements including when using "Sort use statements"
Atom: 1.23.3 PHP: 7.1.6 PHP Integrator: 3.2.0
PHP Integrator adds extra lines between use statements including when using "Sort use statements" and doesn't sort them in any order anymore.
Starting use block:
use App\Models\Report;
use App\Http\Controllers\AbstractController;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Models\AbstractModel;
When typing a class PHP integrator suggests, confirming it will add the use case with an additional line between the existing use statements:
use App\Models\Report;
use App\Http\Controllers\AbstractController;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Models\AbstractModel;
use App\Services\Customer\CustomerService;
The change log indicates that:
Disabling additional newlines when inserting imports is no longer possible (the core does not support it) This will likely have little effect on most users. Colleagues using PhpStorm will likely not complain since PhpStorm usually (?) collapses use statements visually. Tip: you can also sort your current imports using the php-integrator-base:sort-use-statements command to make them consistent once.
When following the suggested "tip" using the sort use statements the result of running the command is:
use App\Models\Report;
use App\Models\AbstractModel;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Http\Controllers\AbstractController;
use App\Services\Customer\CustomerService;
This is the same even when I manually remove the addition lines added. Also note that the first two use statements do not have a break between them and this is the actual result.
The expected result should be:
use App\Http\Controllers\AbstractController;
use App\Models\AbstractModel;
use App\Models\Report;
use App\Services\Customer\CustomerService;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
Currently with all of the additional lines being added, a lot of commits are failing our lint and mess detection rules on our git hooks.
The sort indeed seems to have some strange behavior. That seems to be a bug.
Adding imports or sorting them without newlines wasn't implemented in the core's autocompletion, but it could be added. Not adding the newlines is not such a big change, but getting project settings from Atom to the core requires a way to pass settings. The ideal way to do that would be how the language server protocol describes it, via an initialize request, which is already being tracked here.
Could you create issues in the core for both of these things - incorrect sort order as well as disabling automatic adding of newlines?
The sort command itself is still part of the Atom side, but the same logic is now present in the core, so at the moment this bug needs to be fixed on two sides - until the core has a command to sort imports, so I'll leave this open as well as bug.