Skip to content

Commit

Permalink
feat: @PhpCsFixer ruleset - enable no_whitespace_before_comma_in_ar…
Browse files Browse the repository at this point in the history
…ray.after_heredoc (PHP-CS-Fixer#7670)
  • Loading branch information
mvorisek authored Jan 4, 2024
1 parent cc59512 commit 75f1b53
Show file tree
Hide file tree
Showing 37 changed files with 836 additions and 1,257 deletions.
4 changes: 4 additions & 0 deletions doc/ruleSets/PhpCsFixer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ Rules

- `no_useless_else <./../rules/control_structure/no_useless_else.rst>`_
- `no_useless_return <./../rules/return_notation/no_useless_return.rst>`_
- `no_whitespace_before_comma_in_array <./../rules/array_notation/no_whitespace_before_comma_in_array.rst>`_ with config:

``['after_heredoc' => true]``

- `ordered_class_elements <./../rules/class_notation/ordered_class_elements.rst>`_
- `ordered_types <./../rules/class_notation/ordered_types.rst>`_
- `php_unit_internal_class <./../rules/php_unit/php_unit_internal_class.rst>`_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ The rule is part of the following rule sets:

``['after_heredoc' => true]``

- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ with config:

``['after_heredoc' => true]``

- `@Symfony <./../../ruleSets/Symfony.rst>`_

References
Expand Down
1 change: 1 addition & 0 deletions src/RuleSet/Sets/PhpCsFixerSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function getRules(): array
],
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
'nullable_type_declaration_for_default_null_value' => false,
'ordered_class_elements' => true,
'ordered_types' => true,
Expand Down
9 changes: 3 additions & 6 deletions tests/Fixer/Alias/BacktickToShellExecFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,23 @@ public static function provideFixCases(): iterable
<?php
`echo a\'b`;
`echo 'ab'`;
EOT
,
EOT,
];

yield 'with double quote' => [
<<<'EOT'
<?php
`echo a\"b`;
`echo 'a"b'`;
EOT
,
EOT,
];

yield 'with backtick' => [
<<<'EOT'
<?php
`echo 'a\`b'`;
`echo a\\\`b`;
EOT
,
EOT,
];
}
}
12 changes: 4 additions & 8 deletions tests/Fixer/Basic/BracesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5438,8 +5438,7 @@ public static function provideNowdocInTemplatesCases(): iterable
<?php
}

EOT
,
EOT,
<<<'EOT'
<?php
if (true) {
Expand All @@ -5449,8 +5448,7 @@ public static function provideNowdocInTemplatesCases(): iterable
<?php
}

EOT
,
EOT,
];

yield [
Expand All @@ -5463,8 +5461,7 @@ public static function provideNowdocInTemplatesCases(): iterable
<?php
}

EOT
,
EOT,
<<<'EOT'
<?php
if (true) {
Expand All @@ -5474,8 +5471,7 @@ public static function provideNowdocInTemplatesCases(): iterable
<?php
}

EOT
,
EOT,
];
}

Expand Down
27 changes: 9 additions & 18 deletions tests/Fixer/Basic/NonPrintableCharacterFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "Double \" quote \u{200b} inside";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo 'Double " quote %s inside';
Expand All @@ -249,8 +248,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "Single ' quote \u{200b} inside";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo 'Single \' quote %s inside';
Expand All @@ -267,8 +265,7 @@ function f(string $p)
Quotes ' and " to be handled \u{200b} properly \\' and \\"
STRING
;
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo <<<'STRING'
Expand All @@ -285,8 +282,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "\\\u{200b}\"";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo '\\%s"';
Expand All @@ -300,8 +296,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "\\\u{200b}'";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo '\\%s\'';
Expand All @@ -315,8 +310,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "Backslash 1 \\ \u{200b}";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo 'Backslash 1 \ %s';
Expand All @@ -330,8 +324,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "Backslash 2 \\ \u{200b}";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo 'Backslash 2 \\ %s';
Expand All @@ -345,8 +338,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "Backslash 3 \\\\ \u{200b}";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo 'Backslash 3 \\\ %s';
Expand All @@ -360,8 +352,7 @@ function f(string $p)
yield [
<<<'EXPECTED'
<?php echo "Backslash 4 \\\\ \u{200b}";
EXPECTED
,
EXPECTED,
sprintf(
<<<'INPUT'
<?php echo 'Backslash 4 \\\\ %s';
Expand Down
9 changes: 3 additions & 6 deletions tests/Fixer/ClassNotation/NoPhp4ConstructorFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public function __construct($bar)
var_dump(1);
}
}
EOF
,
EOF,
<<<'EOF'
<?php
Expand Down Expand Up @@ -102,8 +101,7 @@ function#
)#
{}
}
EOF
,
EOF,
<<<'EOF'
<?php
Expand Down Expand Up @@ -1029,8 +1027,7 @@ public function __construct($bar,)
var_dump(1);
}
}
EOF
,
EOF,
<<<'EOF'
<?php
Expand Down
Loading

0 comments on commit 75f1b53

Please sign in to comment.