======================== Rule ``ordered_imports`` ======================== Ordering ``use`` statements. Configuration ------------- ``case_sensitive`` ~~~~~~~~~~~~~~~~~~ Whether the sorting should be case sensitive. Allowed types: ``bool`` Default value: ``false`` ``imports_order`` ~~~~~~~~~~~~~~~~~ Defines the order of import types. Allowed types: ``list`` and ``null`` Default value: ``null`` ``sort_algorithm`` ~~~~~~~~~~~~~~~~~~ Whether the statements should be sorted alphabetically or by length, or not sorted. Allowed values: ``'alpha'``, ``'length'`` and ``'none'`` Default value: ``'alpha'`` Examples -------- Example #1 ~~~~~~~~~~ *Default* configuration. .. code-block:: diff --- Original +++ New true]``. .. code-block:: diff --- Original +++ New 'length']``. .. code-block:: diff --- Original +++ New 'length', 'imports_order' => ['const', 'class', 'function']]``. .. code-block:: diff --- Original +++ New 'alpha', 'imports_order' => ['const', 'class', 'function']]``. .. code-block:: diff --- Original +++ New 'none', 'imports_order' => ['const', 'class', 'function']]``. .. code-block:: diff --- Original +++ New `_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none']`` - `@PER-CS <./../../ruleSets/PER-CS.rst>`_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none']`` - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none']`` - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none']`` - `@PSR12 <./../../ruleSets/PSR12.rst>`_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none']`` - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha']`` - `@Symfony <./../../ruleSets/Symfony.rst>`_ with config: ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha']`` References ---------- - Fixer class: `PhpCsFixer\\Fixer\\Import\\OrderedImportsFixer <./../../../src/Fixer/Import/OrderedImportsFixer.php>`_ - Test class: `PhpCsFixer\\Tests\\Fixer\\Import\\OrderedImportsFixerTest <./../../../tests/Fixer/Import/OrderedImportsFixerTest.php>`_ The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.