Skip to content

Commit acc672f

Browse files
minor #24123 [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction (SpacePossum)
This PR was squashed before being merged into the 2.7 branch (closes #24123). Discussion ---------- [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Hi all and congratulations on the 1 billion of downloads! awesome :D This is a courtesy call (or PR) from the PHP-CS-Fixer community. As always I don't expect this PR to be merged nor do I've any strong feelings about why not. The goal of this PR is to determine if the following new rules should be added to the Symfony ruleset by default. If so `fabbot.io` will (at some point) start reporting violations of these rules. Please be aware that if the rules are accepted but this PR is not, any new PR's might contain a part of the fixes as proposed in this PR as fabbot.io will suggest to the authors of the new PR's to update the CS, consequently this might create noise. Here are the rules: ``` 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, 'semicolon_after_instruction' => true, 'yoda_style' => true, ``` The first three are done in the first commit. The `yoda_style` in the last. I know the `yoda`-style fixing has a long history about it and some people have strong opinions on it. Please consider two things before commenting about Yoda - this PR is not meant to determine the Symfony code style, I'm sure Symfony has other channels for these kind of discussions - if you don't like Yoda style, please consider heading over to PHP-CS-Fixer/PHP-CS-Fixer#2446 and review my PR. If it gets merged you'll have a free tool to change all Yoda expressions in your code to non-Yoda (you can do it around as well as you can see in both PR's). Thank you for your time! Commits ------- 00174ce [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
2 parents 7faa3d4 + 00174ce commit acc672f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Adapter/GnuFindAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function buildFormatSorting(Command $command, $sort)
7272
*/
7373
protected function canBeUsed()
7474
{
75-
return $this->shell->getType() === Shell::TYPE_UNIX && parent::canBeUsed();
75+
return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
7676
}
7777

7878
/**

Expression/Regex.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public static function create($expr)
6767

6868
if (
6969
($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
70-
|| ($start === '{' && $end === '}')
71-
|| ($start === '(' && $end === ')')
70+
|| ('{' === $start && '}' === $end)
71+
|| ('(' === $start && ')' === $end)
7272
) {
7373
return new self(substr($m[1], 1, -1), $m[2], $end);
7474
}

Tests/Iterator/SortableIteratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public function testAccept($mode, $expected)
5858

5959
$iterator = new SortableIterator($inner, $mode);
6060

61-
if ($mode === SortableIterator::SORT_BY_ACCESSED_TIME
62-
|| $mode === SortableIterator::SORT_BY_CHANGED_TIME
63-
|| $mode === SortableIterator::SORT_BY_MODIFIED_TIME
61+
if (SortableIterator::SORT_BY_ACCESSED_TIME === $mode
62+
|| SortableIterator::SORT_BY_CHANGED_TIME === $mode
63+
|| SortableIterator::SORT_BY_MODIFIED_TIME === $mode
6464
) {
6565
if ('\\' === DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) {
6666
$this->markTestSkipped('Sorting by atime or ctime is not supported on Windows');

0 commit comments

Comments
 (0)