Skip to content

Conversation

nunomaduro
Copy link
Member

Using Laravel Promps, Volt, and potentially upcoming projects, we might find ourselves utilizing functional APIs through namespaced functions. Today, with the usage of Pint, users will end up with imports like this:

<?php

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use function Laravel\Prompts\confirm;
use function Laravel\Prompts\multiselect;
use function Laravel\Prompts\select;
use RuntimeException;
use Symfony\Component\Console\Command;
use Symfony\Component\Console\Input\InputInterface;

class InstallCommand extends Command
{
    // ...
}

So, in order to get things a little bit more organized "visually", this pull request proposes organizing these imports by "type". In other words, classes come first, and then, after a new line, the namespaced functions. Here is an example:

<?php

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use RuntimeException;
use Symfony\Component\Console\Command;
use Symfony\Component\Console\Input\InputInterface;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\multiselect;
use function Laravel\Prompts\select;

class InstallCommand extends Command
{
    // ...
}

@nunomaduro nunomaduro marked this pull request as draft August 10, 2023 16:21
@nunomaduro nunomaduro marked this pull request as ready for review August 10, 2023 16:27
@taylorotwell taylorotwell merged commit 989ff6d into main Aug 11, 2023
@taylorotwell taylorotwell deleted the feat/improve-imports branch August 11, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants