123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- ====================================
- Rule ``trailing_comma_in_multiline``
- ====================================
- Multi-line arrays, arguments list, parameters list and ``match`` expressions
- must have a trailing comma.
- Configuration
- -------------
- ``after_heredoc``
- ~~~~~~~~~~~~~~~~~
- Whether a trailing comma should also be placed after heredoc end.
- Allowed types: ``bool``
- Default value: ``false``
- ``elements``
- ~~~~~~~~~~~~
- Where to fix multiline trailing comma (PHP >= 8.0 for ``parameters`` and
- ``match``).
- Allowed values: a subset of ``['arguments', 'arrays', 'match', 'parameters']``
- Default value: ``['arrays']``
- Examples
- --------
- Example #1
- ~~~~~~~~~~
- *Default* configuration.
- .. code-block:: diff
- --- Original
- +++ New
- <?php
- array(
- 1,
- - 2
- + 2,
- );
- Example #2
- ~~~~~~~~~~
- With configuration: ``['after_heredoc' => true]``.
- .. code-block:: diff
- --- Original
- +++ New
- <?php
- $x = [
- 'foo',
- <<<EOD
- bar
- - EOD
- + EOD,
- ];
- Example #3
- ~~~~~~~~~~
- With configuration: ``['elements' => ['arguments']]``.
- .. code-block:: diff
- --- Original
- +++ New
- <?php
- foo(
- 1,
- - 2
- + 2,
- );
- Example #4
- ~~~~~~~~~~
- With configuration: ``['elements' => ['parameters']]``.
- .. code-block:: diff
- --- Original
- +++ New
- <?php
- function foo(
- $x,
- - $y
- + $y,
- )
- {
- }
- Rule sets
- ---------
- The rule is part of the following rule sets:
- - `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_ with config:
- ``['after_heredoc' => true]``
- - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_ with config:
- ``['after_heredoc' => true]``
- - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_ with config:
- ``['after_heredoc' => true]``
- - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_ with config:
- ``['after_heredoc' => true]``
- - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_ with config:
- ``['after_heredoc' => true]``
- - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- - `@Symfony <./../../ruleSets/Symfony.rst>`_
|