12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- =============================
- Rule ``function_declaration``
- =============================
- Spaces should be properly placed in a function declaration.
- Configuration
- -------------
- ``closure_function_spacing``
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Spacing to use before open parenthesis for closures.
- Allowed values: ``'none'``, ``'one'``
- Default value: ``'one'``
- Examples
- --------
- Example #1
- ~~~~~~~~~~
- *Default* configuration.
- .. code-block:: diff
- --- Original
- +++ New
- @@ -2,13 +2,13 @@
- class Foo
- {
- - public static function bar ( $baz , $foo )
- + public static function bar($baz , $foo)
- {
- return false;
- }
- }
- -function foo ($bar, $baz)
- +function foo($bar, $baz)
- {
- return false;
- }
- Example #2
- ~~~~~~~~~~
- With configuration: ``['closure_function_spacing' => 'none']``.
- .. code-block:: diff
- --- Original
- +++ New
- @@ -1,2 +1,2 @@
- <?php
- -$f = function () {};
- +$f = function() {};
- Example #3
- ~~~~~~~~~~
- With configuration: ``['closure_function_spacing' => 'none']``.
- .. code-block:: diff
- --- Original
- +++ New
- @@ -1,2 +1,2 @@
- <?php
- -$f = fn () => null;
- +$f = fn() => null;
- Rule sets
- ---------
- The rule is part of the following rule sets:
- @PSR2
- Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``function_declaration`` rule with the default config.
- @PhpCsFixer
- Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``function_declaration`` rule with the default config.
- @Symfony
- Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``function_declaration`` rule with the default config.
|