Skip to content

Conversation

@paulbalandan
Copy link
Member

Description

$ vendor/bin/php-cs-fixer describe single_import_per_statement
Description of single_import_per_statement rule.
There MUST be one use keyword per declaration.

Fixer is configurable using following option:
* group_to_single_imports (bool): whether to change group imports into single imports; defaults to true

Fixing examples:
 * Example #1. Fixing with the default configuration.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,2 +1,4 @@
    <?php
   -use Foo, Sample, Sample\Sample as Sample2;
   +use Foo;
   +use Sample;
   +use Sample\Sample as Sample2;

   ----------- end diff -----------

 * Example #2. Fixing with configuration: ['group_to_single_imports' => true].
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,6 +1,4 @@
    <?php
   -use Space\Models\ {
   -    TestModelA,
   -    TestModelB,
   -    TestModel,
   -};
   +use Space\Models\TestModelA;
   +use Space\Models\TestModelB;
   +use Space\Models\TestModel;

   ----------- end diff -----------

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan merged commit 8ab5aeb into codeigniter4:develop Sep 11, 2022
@paulbalandan paulbalandan deleted the single-import-per-statement branch September 11, 2022 15:16
paulbalandan added a commit to CodeIgniter/coding-standard that referenced this pull request Sep 11, 2022
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.

3 participants