=============================== Rule ``ordered_class_elements`` =============================== Orders the elements of classes/interfaces/traits/enums. Description ----------- Accepts a subset of pre-defined element types, special element groups, and custom patterns. Element types: ``['use_trait', 'public', 'protected', 'private', 'case', 'constant', 'constant_public', 'constant_protected', 'constant_private', 'property', 'property_static', 'property_public', 'property_protected', 'property_private', 'property_public_readonly', 'property_protected_readonly', 'property_private_readonly', 'property_public_static', 'property_protected_static', 'property_private_static', 'method', 'method_abstract', 'method_static', 'method_public', 'method_protected', 'method_private', 'method_public_abstract', 'method_protected_abstract', 'method_private_abstract', 'method_public_abstract_static', 'method_protected_abstract_static', 'method_private_abstract_static', 'method_public_static', 'method_protected_static', 'method_private_static']`` Special element types: ``['construct', 'destruct', 'magic', 'phpunit']`` Custom values: - ``method:*``: specify a single method name (e.g. ``method:__invoke``) to set the order of that specific method. Configuration ------------- ``order`` ~~~~~~~~~ List of strings defining order of elements. Allowed types: ``array`` Default value: ``['use_trait', 'case', 'constant_public', 'constant_protected', 'constant_private', 'property_public', 'property_protected', 'property_private', 'construct', 'destruct', 'magic', 'phpunit', 'method_public', 'method_protected', 'method_private']`` ``sort_algorithm`` ~~~~~~~~~~~~~~~~~~ How multiple occurrences of same type statements should be sorted. Allowed values: ``'alpha'`` and ``'none'`` Default value: ``'none'`` ``case_sensitive`` ~~~~~~~~~~~~~~~~~~ Whether the sorting should be case sensitive. Allowed types: ``bool`` Default value: ``false`` Examples -------- Example #1 ~~~~~~~~~~ *Default* configuration. .. code-block:: diff --- Original +++ New ['method_private', 'method_public']]``. .. code-block:: diff --- Original +++ New ['method_public'], 'sort_algorithm' => 'alpha']``. .. code-block:: diff --- Original +++ New ['method_public'], 'sort_algorithm' => 'alpha', 'case_sensitive' => true]``. .. code-block:: diff --- Original +++ New `_ with config: ``['order' => ['use_trait']]`` - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_ with config: ``['order' => ['use_trait']]`` - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_ with config: ``['order' => ['use_trait']]`` - `@PSR12 <./../../ruleSets/PSR12.rst>`_ with config: ``['order' => ['use_trait']]`` - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ - `@Symfony <./../../ruleSets/Symfony.rst>`_ with config: ``['order' => ['use_trait']]``