Skip to content

Commit 1adb191

Browse files
authored
Merge pull request #1242 from PHPCSStandards/phpcs-4.x/feature/155-normalize-some-code-style-rules-4
CS: normalize code style rules [4]
2 parents 6f8fdc4 + 5d99e27 commit 1adb191

File tree

104 files changed

+347
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+347
-347
lines changed

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<rule ref="Squiz.Arrays.ArrayDeclaration"/>
4040
<rule ref="Squiz.Commenting.ClosingDeclarationComment"/>
4141
<rule ref="Squiz.ControlStructures.ControlSignature"/>
42-
<rule ref="Squiz.ControlStructures.ElseIfDeclaration"/>
42+
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
4343
<rule ref="Squiz.Commenting.BlockComment"/>
4444
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
4545
<rule ref="Squiz.Commenting.EmptyCatchComment"/>

src/Config.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function __set(string $name, $value)
303303

304304
if (is_int($value) === true) {
305305
$value = abs($value);
306-
} else if (is_string($value) === true && preg_match('`^\d+$`', $value) === 1) {
306+
} elseif (is_string($value) === true && preg_match('`^\d+$`', $value) === 1) {
307307
$value = (int) $value;
308308
} else {
309309
$value = self::DEFAULT_REPORT_WIDTH;
@@ -920,14 +920,14 @@ public function processLongArgument(string $arg, int $pos)
920920

921921
$this->sniffs = $this->parseSniffCodes(substr($arg, 7), 'sniffs');
922922
$this->overriddenDefaults['sniffs'] = true;
923-
} else if (substr($arg, 0, 8) === 'exclude=') {
923+
} elseif (substr($arg, 0, 8) === 'exclude=') {
924924
if (isset($this->overriddenDefaults['exclude']) === true) {
925925
break;
926926
}
927927

928928
$this->exclude = $this->parseSniffCodes(substr($arg, 8), 'exclude');
929929
$this->overriddenDefaults['exclude'] = true;
930-
} else if (substr($arg, 0, 6) === 'cache=') {
930+
} elseif (substr($arg, 0, 6) === 'cache=') {
931931
if ((isset($this->overriddenDefaults['cache']) === true
932932
&& $this->cache === false)
933933
|| isset($this->overriddenDefaults['cacheFile']) === true
@@ -977,7 +977,7 @@ public function processLongArgument(string $arg, int $pos)
977977
$error .= $this->printShortUsage(true);
978978
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
979979
}
980-
} else if (substr($arg, 0, 10) === 'bootstrap=') {
980+
} elseif (substr($arg, 0, 10) === 'bootstrap=') {
981981
$files = explode(',', substr($arg, 10));
982982
$bootstrap = [];
983983
foreach ($files as $file) {
@@ -993,7 +993,7 @@ public function processLongArgument(string $arg, int $pos)
993993

994994
$this->bootstrap = array_merge($this->bootstrap, $bootstrap);
995995
$this->overriddenDefaults['bootstrap'] = true;
996-
} else if (substr($arg, 0, 10) === 'file-list=') {
996+
} elseif (substr($arg, 0, 10) === 'file-list=') {
997997
$fileList = substr($arg, 10);
998998
$path = Common::realpath($fileList);
999999
if ($path === false) {
@@ -1013,7 +1013,7 @@ public function processLongArgument(string $arg, int $pos)
10131013

10141014
$this->processFilePath($inputFile);
10151015
}
1016-
} else if (substr($arg, 0, 11) === 'stdin-path=') {
1016+
} elseif (substr($arg, 0, 11) === 'stdin-path=') {
10171017
if (isset($this->overriddenDefaults['stdinPath']) === true) {
10181018
break;
10191019
}
@@ -1026,7 +1026,7 @@ public function processLongArgument(string $arg, int $pos)
10261026
}
10271027

10281028
$this->overriddenDefaults['stdinPath'] = true;
1029-
} else if (substr($arg, 0, 12) === 'report-file=') {
1029+
} elseif (substr($arg, 0, 12) === 'report-file=') {
10301030
if (PHP_CODESNIFFER_CBF === true || isset($this->overriddenDefaults['reportFile']) === true) {
10311031
break;
10321032
}
@@ -1054,14 +1054,14 @@ public function processLongArgument(string $arg, int $pos)
10541054
$error .= $this->printShortUsage(true);
10551055
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
10561056
}
1057-
} else if (substr($arg, 0, 13) === 'report-width=') {
1057+
} elseif (substr($arg, 0, 13) === 'report-width=') {
10581058
if (isset($this->overriddenDefaults['reportWidth']) === true) {
10591059
break;
10601060
}
10611061

10621062
$this->reportWidth = substr($arg, 13);
10631063
$this->overriddenDefaults['reportWidth'] = true;
1064-
} else if (substr($arg, 0, 9) === 'basepath=') {
1064+
} elseif (substr($arg, 0, 9) === 'basepath=') {
10651065
if (isset($this->overriddenDefaults['basepath']) === true) {
10661066
break;
10671067
}
@@ -1087,7 +1087,7 @@ public function processLongArgument(string $arg, int $pos)
10871087
$error .= $this->printShortUsage(true);
10881088
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
10891089
}
1090-
} else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) {
1090+
} elseif ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) {
10911091
$reports = [];
10921092

10931093
if ($arg[6] === '-') {
@@ -1140,21 +1140,21 @@ public function processLongArgument(string $arg, int $pos)
11401140
}
11411141

11421142
$this->overriddenDefaults['reports'] = true;
1143-
} else if (substr($arg, 0, 7) === 'filter=') {
1143+
} elseif (substr($arg, 0, 7) === 'filter=') {
11441144
if (isset($this->overriddenDefaults['filter']) === true) {
11451145
break;
11461146
}
11471147

11481148
$this->filter = substr($arg, 7);
11491149
$this->overriddenDefaults['filter'] = true;
1150-
} else if (substr($arg, 0, 9) === 'standard=') {
1150+
} elseif (substr($arg, 0, 9) === 'standard=') {
11511151
$standards = trim(substr($arg, 9));
11521152
if ($standards !== '') {
11531153
$this->standards = explode(',', $standards);
11541154
}
11551155

11561156
$this->overriddenDefaults['standards'] = true;
1157-
} else if (substr($arg, 0, 11) === 'extensions=') {
1157+
} elseif (substr($arg, 0, 11) === 'extensions=') {
11581158
if (isset($this->overriddenDefaults['extensions']) === true) {
11591159
break;
11601160
}
@@ -1182,21 +1182,21 @@ public function processLongArgument(string $arg, int $pos)
11821182

11831183
$this->extensions = $newExtensions;
11841184
$this->overriddenDefaults['extensions'] = true;
1185-
} else if (substr($arg, 0, 7) === 'suffix=') {
1185+
} elseif (substr($arg, 0, 7) === 'suffix=') {
11861186
if (isset($this->overriddenDefaults['suffix']) === true) {
11871187
break;
11881188
}
11891189

11901190
$this->suffix = substr($arg, 7);
11911191
$this->overriddenDefaults['suffix'] = true;
1192-
} else if (substr($arg, 0, 9) === 'parallel=') {
1192+
} elseif (substr($arg, 0, 9) === 'parallel=') {
11931193
if (isset($this->overriddenDefaults['parallel']) === true) {
11941194
break;
11951195
}
11961196

11971197
$this->parallel = max((int) substr($arg, 9), 1);
11981198
$this->overriddenDefaults['parallel'] = true;
1199-
} else if (substr($arg, 0, 9) === 'severity=') {
1199+
} elseif (substr($arg, 0, 9) === 'severity=') {
12001200
$this->errorSeverity = (int) substr($arg, 9);
12011201
$this->warningSeverity = $this->errorSeverity;
12021202
if (isset($this->overriddenDefaults['errorSeverity']) === false) {
@@ -1206,21 +1206,21 @@ public function processLongArgument(string $arg, int $pos)
12061206
if (isset($this->overriddenDefaults['warningSeverity']) === false) {
12071207
$this->overriddenDefaults['warningSeverity'] = true;
12081208
}
1209-
} else if (substr($arg, 0, 15) === 'error-severity=') {
1209+
} elseif (substr($arg, 0, 15) === 'error-severity=') {
12101210
if (isset($this->overriddenDefaults['errorSeverity']) === true) {
12111211
break;
12121212
}
12131213

12141214
$this->errorSeverity = (int) substr($arg, 15);
12151215
$this->overriddenDefaults['errorSeverity'] = true;
1216-
} else if (substr($arg, 0, 17) === 'warning-severity=') {
1216+
} elseif (substr($arg, 0, 17) === 'warning-severity=') {
12171217
if (isset($this->overriddenDefaults['warningSeverity']) === true) {
12181218
break;
12191219
}
12201220

12211221
$this->warningSeverity = (int) substr($arg, 17);
12221222
$this->overriddenDefaults['warningSeverity'] = true;
1223-
} else if (substr($arg, 0, 7) === 'ignore=') {
1223+
} elseif (substr($arg, 0, 7) === 'ignore=') {
12241224
if (isset($this->overriddenDefaults['ignored']) === true) {
12251225
break;
12261226
}
@@ -1244,7 +1244,7 @@ public function processLongArgument(string $arg, int $pos)
12441244

12451245
$this->ignored = $ignored;
12461246
$this->overriddenDefaults['ignored'] = true;
1247-
} else if (substr($arg, 0, 10) === 'generator='
1247+
} elseif (substr($arg, 0, 10) === 'generator='
12481248
&& PHP_CODESNIFFER_CBF === false
12491249
) {
12501250
if (isset($this->overriddenDefaults['generator']) === true) {
@@ -1268,14 +1268,14 @@ public function processLongArgument(string $arg, int $pos)
12681268

12691269
$this->generator = self::VALID_GENERATORS[$lowerCaseGeneratorName];
12701270
$this->overriddenDefaults['generator'] = true;
1271-
} else if (substr($arg, 0, 9) === 'encoding=') {
1271+
} elseif (substr($arg, 0, 9) === 'encoding=') {
12721272
if (isset($this->overriddenDefaults['encoding']) === true) {
12731273
break;
12741274
}
12751275

12761276
$this->encoding = strtolower(substr($arg, 9));
12771277
$this->overriddenDefaults['encoding'] = true;
1278-
} else if (substr($arg, 0, 10) === 'tab-width=') {
1278+
} elseif (substr($arg, 0, 10) === 'tab-width=') {
12791279
if (isset($this->overriddenDefaults['tabWidth']) === true) {
12801280
break;
12811281
}
@@ -1342,9 +1342,9 @@ private function parseSniffCodes(string $input, string $argument)
13421342

13431343
if ($partCount === 0) {
13441344
$errors[] = 'Standard codes are not supported: ' . $sniff;
1345-
} else if ($partCount === 1) {
1345+
} elseif ($partCount === 1) {
13461346
$errors[] = 'Category codes are not supported: ' . $sniff;
1347-
} else if ($partCount === 3) {
1347+
} elseif ($partCount === 3) {
13481348
$errors[] = 'Message codes are not supported: ' . $sniff;
13491349
} else {
13501350
$errors[] = 'Too many parts: ' . $sniff;

src/Files/File.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public function process()
398398
$this->fixableErrorCount = 0;
399399
$this->fixableWarningCount = 0;
400400
return;
401-
} else if (substr($commentTextLower, 0, 9) === 'phpcs:set'
401+
} elseif (substr($commentTextLower, 0, 9) === 'phpcs:set'
402402
|| substr($commentTextLower, 0, 10) === '@phpcs:set'
403403
) {
404404
if (isset($token['sniffCode']) === true) {
@@ -984,7 +984,7 @@ protected function addMessage(
984984
if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
985985
$patterns = $this->configCache['includePatterns'][$checkCode];
986986
$excluding = false;
987-
} else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
987+
} elseif (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
988988
$patterns = $this->configCache['ignorePatterns'][$checkCode];
989989
$excluding = true;
990990
}
@@ -1110,7 +1110,7 @@ public function recordMetric(int $stackPtr, string $metric, string $value)
11101110
if (isset($this->metrics[$metric]) === false) {
11111111
$this->metrics[$metric] = ['values' => [$value => 1]];
11121112
$this->metricTokens[$metric][$stackPtr] = true;
1113-
} else if (isset($this->metricTokens[$metric][$stackPtr]) === false) {
1113+
} elseif (isset($this->metricTokens[$metric][$stackPtr]) === false) {
11141114
$this->metricTokens[$metric][$stackPtr] = true;
11151115
if (isset($this->metrics[$metric]['values'][$value]) === false) {
11161116
$this->metrics[$metric]['values'][$value] = 1;
@@ -1336,7 +1336,7 @@ public function getDeclarationName(int $stackPtr)
13361336
if (isset($this->tokens[$stackPtr]['parenthesis_opener']) === true) {
13371337
// For functions, stop searching at the parenthesis opener.
13381338
$stopPoint = $this->tokens[$stackPtr]['parenthesis_opener'];
1339-
} else if (isset($this->tokens[$stackPtr]['scope_opener']) === true) {
1339+
} elseif (isset($this->tokens[$stackPtr]['scope_opener']) === true) {
13401340
// For OO tokens, stop searching at the open curly.
13411341
$stopPoint = $this->tokens[$stackPtr]['scope_opener'];
13421342
}
@@ -2347,7 +2347,7 @@ public function findPrevious(
23472347
if ($found === true) {
23482348
if ($value === null) {
23492349
return $i;
2350-
} else if ($this->tokens[$i]['content'] === $value) {
2350+
} elseif ($this->tokens[$i]['content'] === $value) {
23512351
return $i;
23522352
}
23532353
}
@@ -2357,15 +2357,15 @@ public function findPrevious(
23572357
&& $i === $this->tokens[$i]['scope_closer']
23582358
) {
23592359
$i = $this->tokens[$i]['scope_opener'];
2360-
} else if (isset($this->tokens[$i]['bracket_opener']) === true
2360+
} elseif (isset($this->tokens[$i]['bracket_opener']) === true
23612361
&& $i === $this->tokens[$i]['bracket_closer']
23622362
) {
23632363
$i = $this->tokens[$i]['bracket_opener'];
2364-
} else if (isset($this->tokens[$i]['parenthesis_opener']) === true
2364+
} elseif (isset($this->tokens[$i]['parenthesis_opener']) === true
23652365
&& $i === $this->tokens[$i]['parenthesis_closer']
23662366
) {
23672367
$i = $this->tokens[$i]['parenthesis_opener'];
2368-
} else if ($this->tokens[$i]['code'] === T_SEMICOLON) {
2368+
} elseif ($this->tokens[$i]['code'] === T_SEMICOLON) {
23692369
break;
23702370
}
23712371
}
@@ -2428,7 +2428,7 @@ public function findNext(
24282428
if ($found === true) {
24292429
if ($value === null) {
24302430
return $i;
2431-
} else if ($this->tokens[$i]['content'] === $value) {
2431+
} elseif ($this->tokens[$i]['content'] === $value) {
24322432
return $i;
24332433
}
24342434
}
@@ -2613,11 +2613,11 @@ public function findStartOfStatement(int $start, $ignore = null)
26132613
&& $i === $this->tokens[$i]['bracket_closer']
26142614
) {
26152615
$i = $this->tokens[$i]['bracket_opener'];
2616-
} else if (isset($this->tokens[$i]['parenthesis_opener']) === true
2616+
} elseif (isset($this->tokens[$i]['parenthesis_opener']) === true
26172617
&& $i === $this->tokens[$i]['parenthesis_closer']
26182618
) {
26192619
$i = $this->tokens[$i]['parenthesis_opener'];
2620-
} else if ($this->tokens[$i]['code'] === T_CLOSE_USE_GROUP) {
2620+
} elseif ($this->tokens[$i]['code'] === T_CLOSE_USE_GROUP) {
26212621
$start = $this->findPrevious(T_OPEN_USE_GROUP, ($i - 1));
26222622
if ($start !== false) {
26232623
$i = $start;
@@ -2724,15 +2724,15 @@ public function findEndOfStatement(int $start, $ignore = null)
27242724
}
27252725

27262726
$i = $this->tokens[$i]['scope_closer'];
2727-
} else if (isset($this->tokens[$i]['bracket_closer']) === true
2727+
} elseif (isset($this->tokens[$i]['bracket_closer']) === true
27282728
&& $i === $this->tokens[$i]['bracket_opener']
27292729
) {
27302730
$i = $this->tokens[$i]['bracket_closer'];
2731-
} else if (isset($this->tokens[$i]['parenthesis_closer']) === true
2731+
} elseif (isset($this->tokens[$i]['parenthesis_closer']) === true
27322732
&& $i === $this->tokens[$i]['parenthesis_opener']
27332733
) {
27342734
$i = $this->tokens[$i]['parenthesis_closer'];
2735-
} else if ($this->tokens[$i]['code'] === T_OPEN_USE_GROUP) {
2735+
} elseif ($this->tokens[$i]['code'] === T_OPEN_USE_GROUP) {
27362736
$end = $this->findNext(T_CLOSE_USE_GROUP, ($i + 1));
27372737
if ($end !== false) {
27382738
$i = $end;
@@ -2800,7 +2800,7 @@ public function findFirstOnLine($types, int $start, bool $exclude = false, ?stri
28002800
if ($found === true) {
28012801
if ($value === null) {
28022802
$foundToken = $i;
2803-
} else if ($this->tokens[$i]['content'] === $value) {
2803+
} elseif ($this->tokens[$i]['content'] === $value) {
28042804
$foundToken = $i;
28052805
}
28062806
}

src/Filters/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function accept()
127127
if ($this->config->local === true) {
128128
return false;
129129
}
130-
} else if ($this->shouldProcessFile($filePath) === false) {
130+
} elseif ($this->shouldProcessFile($filePath) === false) {
131131
return false;
132132
}
133133

src/Fixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function fixFile()
201201
if ($this->numFixes === 0 && $this->inConflict === false) {
202202
// Nothing left to do.
203203
break;
204-
} else if (PHP_CODESNIFFER_VERBOSITY > 1) {
204+
} elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
205205
StatusWriter::forceWrite("* fixed $this->numFixes violations, starting loop " . ($this->loops + 1) . ' *', 1);
206206
}
207207
}//end while
@@ -454,7 +454,7 @@ public function endChangeset()
454454
if (PHP_CODESNIFFER_VERBOSITY > 1) {
455455
StatusWriter::forceWrite('=> Changeset failed to apply', 1);
456456
}
457-
} else if (PHP_CODESNIFFER_VERBOSITY > 1) {
457+
} elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
458458
$fixes = count($this->changeset);
459459
StatusWriter::forceWrite("=> Changeset ended: $fixes changes applied", 1);
460460
}

src/Generators/HTML.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function processSniff(DOMElement $doc)
274274
foreach ($doc->childNodes as $node) {
275275
if ($node->nodeName === 'standard') {
276276
$content .= $this->getFormattedTextBlock($node);
277-
} else if ($node->nodeName === 'code_comparison') {
277+
} elseif ($node->nodeName === 'code_comparison') {
278278
$content .= $this->getFormattedCodeComparisonBlock($node);
279279
}
280280
}

src/Generators/Markdown.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function processSniff(DOMElement $doc)
112112
foreach ($doc->childNodes as $node) {
113113
if ($node->nodeName === 'standard') {
114114
$content .= $this->getFormattedTextBlock($node);
115-
} else if ($node->nodeName === 'code_comparison') {
115+
} elseif ($node->nodeName === 'code_comparison') {
116116
$content .= $this->getFormattedCodeComparisonBlock($node);
117117
}
118118
}

src/Generators/Text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function processSniff(DOMElement $doc)
3535
foreach ($doc->childNodes as $node) {
3636
if ($node->nodeName === 'standard') {
3737
$content .= $this->getFormattedTextBlock($node);
38-
} else if ($node->nodeName === 'code_comparison') {
38+
} elseif ($node->nodeName === 'code_comparison') {
3939
$content .= $this->getFormattedCodeComparisonBlock($node);
4040
}
4141
}

0 commit comments

Comments
 (0)