Skip to content

Commit c5e7f48

Browse files
authored
Merge pull request #1238 from PHPCSStandards/phpcs-4.x/feature/155-normalize-some-code-style-rules-1
CS: normalize code style rules [1]
2 parents cc9b7bb + fe53a33 commit c5e7f48

File tree

10 files changed

+21
-15
lines changed

10 files changed

+21
-15
lines changed

phpcs.xml.dist

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
<rule ref="Squiz.PHP.DisallowInlineIf"/>
5959
<rule ref="Squiz.Scope.MethodScope"/>
6060
<rule ref="Squiz.Strings.ConcatenationSpacing"/>
61+
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
62+
<rule ref="Generic.Strings.UnnecessaryHeredoc"/>
6163
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
6264
<rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
6365
<rule ref="Squiz.WhiteSpace.FunctionSpacing"/>
@@ -133,6 +135,7 @@
133135
<element key="print" value="echo"/>
134136
<element key="is_null" value="null"/>
135137
<element key="create_function" value="null"/>
138+
<element key="join" value="implode"/>
136139
</property>
137140
</properties>
138141
</rule>
@@ -150,7 +153,7 @@
150153

151154
<!-- This test file specifically *needs* Windows line endings for testing purposes. -->
152155
<rule ref="Generic.Files.LineEndings.InvalidEOLChar">
153-
<exclude-pattern>tests/Core/Tokenizers/PHP/StableCommentWhitespaceWinTest\.php</exclude-pattern>
156+
<exclude-pattern>tests/Core/Tokenizers/PHP/*WinTest\.php</exclude-pattern>
154157
</rule>
155158

156159
<!-- Avoid false positive with this sniff detecting itself -->
@@ -161,4 +164,7 @@
161164

162165
<!-- Require visibility for class constants. -->
163166
<rule ref="PSR12.Properties.ConstantVisibility"/>
167+
168+
<!-- Handle consistent formatting of return types. -->
169+
<rule ref="PSR12.Functions.ReturnTypeDeclaration"/>
164170
</ruleset>

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ public static function getExecutablePath(string $name)
15921592
return $data;
15931593
}
15941594

1595-
if ($name === "php") {
1595+
if ($name === 'php') {
15961596
// For php, we know the executable path. There's no need to look it up.
15971597
return PHP_BINARY;
15981598
}

src/Files/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ public function getFixedWarningCount()
12291229
*
12301230
* @return int
12311231
*/
1232-
public function getFirstRunCount(string $type):int
1232+
public function getFirstRunCount(string $type): int
12331233
{
12341234
return $this->firstRunCounts[$type];
12351235

src/Reports/Json.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
5757
$messagesObject->column = $column;
5858
$messagesObject->fixable = $fixable;
5959

60-
$messages .= json_encode($messagesObject).",";
60+
$messages .= json_encode($messagesObject).',';
6161
}
6262
}
6363
}//end foreach
@@ -99,7 +99,7 @@ public function generate(
9999
) {
100100
echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{';
101101
echo rtrim($cachedData, ',');
102-
echo "}}".PHP_EOL;
102+
echo '}}'.PHP_EOL;
103103

104104
}//end generate()
105105

tests/Core/Ruleset/ExplainTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function testExplainCustomRuleset()
179179
public function testExplainWithDeprecatedSniffs()
180180
{
181181
// Set up the ruleset.
182-
$standard = __DIR__."/ShowSniffDeprecationsTest.xml";
182+
$standard = __DIR__.'/ShowSniffDeprecationsTest.xml';
183183
$config = new ConfigDouble(["--standard=$standard", '-e']);
184184
$ruleset = new Ruleset($config);
185185

tests/Core/Ruleset/GetIgnorePatternsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class GetIgnorePatternsTest extends TestCase
3737
public static function setUpBeforeClass(): void
3838
{
3939
// Set up the ruleset.
40-
$standard = __DIR__."/GetIgnorePatternsTest.xml";
40+
$standard = __DIR__.'/GetIgnorePatternsTest.xml';
4141
$config = new ConfigDouble(["--standard=$standard"]);
4242
self::$ruleset = new Ruleset($config);
4343

tests/Core/Ruleset/GetIncludePatternsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class GetIncludePatternsTest extends TestCase
3737
public static function setUpBeforeClass(): void
3838
{
3939
// Set up the ruleset.
40-
$standard = __DIR__."/GetIncludePatternsTest.xml";
40+
$standard = __DIR__.'/GetIncludePatternsTest.xml';
4141
$config = new ConfigDouble(["--standard=$standard"]);
4242
self::$ruleset = new Ruleset($config);
4343

tests/Core/Tokenizers/PHP/AttributesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ public static function dataAttributeOnTextLookingLikeCloseTag()
540540
],
541541
[
542542
'T_WHITESPACE',
543-
" ",
543+
' ',
544544
],
545545
[
546546
'T_CONSTANT_ENCAPSED_STRING',

tests/Core/Tokenizers/Tokenizer/ReplaceTabsInTokenMiscTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testTabWidthNotSet()
3333
$config = new ConfigDouble();
3434
$ruleset = new Ruleset($config);
3535

36-
$content = <<<EOD
36+
$content = <<<'EOD'
3737
<?php
3838
echo 'foo';
3939
EOD;
@@ -71,7 +71,7 @@ public function testLengthSettingRespectsEncoding()
7171
$config->tabWidth = 4;
7272
$ruleset = new Ruleset($config);
7373

74-
$content = <<<EOD
74+
$content = <<<'EOD'
7575
<?php
7676
echo 'пасха пасха';
7777
EOD;

tests/Core/Util/Common/PrepareForOutputTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ public static function dataPrepareForOutput()
7979
'expectedWin' => "\\r\\n\\t",
8080
],
8181
'Spaces are replaced with a unique mark' => [
82-
'content' => " ",
82+
'content' => ' ',
8383
'exclude' => [],
8484
'expected' => "\033[30;1m·\033[0m\033[30;1m·\033[0m\033[30;1m·\033[0m\033[30;1m·\033[0m",
85-
'expectedWin' => " ",
85+
'expectedWin' => ' ',
8686
],
8787
'Other characters are unaffected' => [
88-
'content' => "{echo 1;}",
88+
'content' => '{echo 1;}',
8989
'exclude' => [],
9090
'expected' => "{echo\033[30;1m·\033[0m1;}",
91-
'expectedWin' => "{echo 1;}",
91+
'expectedWin' => '{echo 1;}',
9292
],
9393
'No replacements' => [
9494
'content' => 'nothing-should-be-replaced',

0 commit comments

Comments
 (0)