Skip to content

Conversation

@paulbalandan
Copy link
Member

Description

$ vendor/bin/php-cs-fixer describe types_spaces
Description of types_spaces rule.
A single space or none should be around union type and intersection type operators.

Fixer is configurable using following options:
* space ('none', 'single'): spacing to apply around union type and intersection type operators; defaults to 'none'
* space_multiple_catch ('none', 'single', null): spacing to apply around type operator when catching exceptions of multiple types, use `null` to follow the value configured for `space`; defaults to null

Fixing examples:
 * Example #1. Fixing with the default configuration.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,6 +1,6 @@
    <?php
    try
    {
        new Foo();
   -} catch (ErrorA | ErrorB $e) {
   +} catch (ErrorA|ErrorB $e) {
    echo'error';}

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

 * Example #2. Fixing with configuration: ['space' => 'single'].
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,6 +1,6 @@
    <?php
    try
    {
        new Foo();
   -} catch (ErrorA|ErrorB $e) {
   +} catch (ErrorA | ErrorB $e) {
    echo'error';}

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

 * Example #3. Fixing with the default configuration.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,4 +1,4 @@
    <?php
   -function foo(int | string $x)
   +function foo(int|string $x)
    {
    }

   ----------- 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 ef7d18b into codeigniter4:develop Sep 13, 2022
@paulbalandan paulbalandan deleted the types-spaces branch September 13, 2022 02:17
paulbalandan added a commit to CodeIgniter/coding-standard that referenced this pull request Sep 13, 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