diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 55cb2265fb..ea5d632a1e 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -39,7 +39,7 @@
-
+
diff --git a/src/Config.php b/src/Config.php
index 28b777714e..0594770f01 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -303,7 +303,7 @@ public function __set(string $name, $value)
if (is_int($value) === true) {
$value = abs($value);
- } else if (is_string($value) === true && preg_match('`^\d+$`', $value) === 1) {
+ } elseif (is_string($value) === true && preg_match('`^\d+$`', $value) === 1) {
$value = (int) $value;
} else {
$value = self::DEFAULT_REPORT_WIDTH;
@@ -920,14 +920,14 @@ public function processLongArgument(string $arg, int $pos)
$this->sniffs = $this->parseSniffCodes(substr($arg, 7), 'sniffs');
$this->overriddenDefaults['sniffs'] = true;
- } else if (substr($arg, 0, 8) === 'exclude=') {
+ } elseif (substr($arg, 0, 8) === 'exclude=') {
if (isset($this->overriddenDefaults['exclude']) === true) {
break;
}
$this->exclude = $this->parseSniffCodes(substr($arg, 8), 'exclude');
$this->overriddenDefaults['exclude'] = true;
- } else if (substr($arg, 0, 6) === 'cache=') {
+ } elseif (substr($arg, 0, 6) === 'cache=') {
if ((isset($this->overriddenDefaults['cache']) === true
&& $this->cache === false)
|| isset($this->overriddenDefaults['cacheFile']) === true
@@ -977,7 +977,7 @@ public function processLongArgument(string $arg, int $pos)
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- } else if (substr($arg, 0, 10) === 'bootstrap=') {
+ } elseif (substr($arg, 0, 10) === 'bootstrap=') {
$files = explode(',', substr($arg, 10));
$bootstrap = [];
foreach ($files as $file) {
@@ -993,7 +993,7 @@ public function processLongArgument(string $arg, int $pos)
$this->bootstrap = array_merge($this->bootstrap, $bootstrap);
$this->overriddenDefaults['bootstrap'] = true;
- } else if (substr($arg, 0, 10) === 'file-list=') {
+ } elseif (substr($arg, 0, 10) === 'file-list=') {
$fileList = substr($arg, 10);
$path = Common::realpath($fileList);
if ($path === false) {
@@ -1013,7 +1013,7 @@ public function processLongArgument(string $arg, int $pos)
$this->processFilePath($inputFile);
}
- } else if (substr($arg, 0, 11) === 'stdin-path=') {
+ } elseif (substr($arg, 0, 11) === 'stdin-path=') {
if (isset($this->overriddenDefaults['stdinPath']) === true) {
break;
}
@@ -1026,7 +1026,7 @@ public function processLongArgument(string $arg, int $pos)
}
$this->overriddenDefaults['stdinPath'] = true;
- } else if (substr($arg, 0, 12) === 'report-file=') {
+ } elseif (substr($arg, 0, 12) === 'report-file=') {
if (PHP_CODESNIFFER_CBF === true || isset($this->overriddenDefaults['reportFile']) === true) {
break;
}
@@ -1054,14 +1054,14 @@ public function processLongArgument(string $arg, int $pos)
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- } else if (substr($arg, 0, 13) === 'report-width=') {
+ } elseif (substr($arg, 0, 13) === 'report-width=') {
if (isset($this->overriddenDefaults['reportWidth']) === true) {
break;
}
$this->reportWidth = substr($arg, 13);
$this->overriddenDefaults['reportWidth'] = true;
- } else if (substr($arg, 0, 9) === 'basepath=') {
+ } elseif (substr($arg, 0, 9) === 'basepath=') {
if (isset($this->overriddenDefaults['basepath']) === true) {
break;
}
@@ -1087,7 +1087,7 @@ public function processLongArgument(string $arg, int $pos)
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- } else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) {
+ } elseif ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) {
$reports = [];
if ($arg[6] === '-') {
@@ -1140,21 +1140,21 @@ public function processLongArgument(string $arg, int $pos)
}
$this->overriddenDefaults['reports'] = true;
- } else if (substr($arg, 0, 7) === 'filter=') {
+ } elseif (substr($arg, 0, 7) === 'filter=') {
if (isset($this->overriddenDefaults['filter']) === true) {
break;
}
$this->filter = substr($arg, 7);
$this->overriddenDefaults['filter'] = true;
- } else if (substr($arg, 0, 9) === 'standard=') {
+ } elseif (substr($arg, 0, 9) === 'standard=') {
$standards = trim(substr($arg, 9));
if ($standards !== '') {
$this->standards = explode(',', $standards);
}
$this->overriddenDefaults['standards'] = true;
- } else if (substr($arg, 0, 11) === 'extensions=') {
+ } elseif (substr($arg, 0, 11) === 'extensions=') {
if (isset($this->overriddenDefaults['extensions']) === true) {
break;
}
@@ -1182,21 +1182,21 @@ public function processLongArgument(string $arg, int $pos)
$this->extensions = $newExtensions;
$this->overriddenDefaults['extensions'] = true;
- } else if (substr($arg, 0, 7) === 'suffix=') {
+ } elseif (substr($arg, 0, 7) === 'suffix=') {
if (isset($this->overriddenDefaults['suffix']) === true) {
break;
}
$this->suffix = substr($arg, 7);
$this->overriddenDefaults['suffix'] = true;
- } else if (substr($arg, 0, 9) === 'parallel=') {
+ } elseif (substr($arg, 0, 9) === 'parallel=') {
if (isset($this->overriddenDefaults['parallel']) === true) {
break;
}
$this->parallel = max((int) substr($arg, 9), 1);
$this->overriddenDefaults['parallel'] = true;
- } else if (substr($arg, 0, 9) === 'severity=') {
+ } elseif (substr($arg, 0, 9) === 'severity=') {
$this->errorSeverity = (int) substr($arg, 9);
$this->warningSeverity = $this->errorSeverity;
if (isset($this->overriddenDefaults['errorSeverity']) === false) {
@@ -1206,21 +1206,21 @@ public function processLongArgument(string $arg, int $pos)
if (isset($this->overriddenDefaults['warningSeverity']) === false) {
$this->overriddenDefaults['warningSeverity'] = true;
}
- } else if (substr($arg, 0, 15) === 'error-severity=') {
+ } elseif (substr($arg, 0, 15) === 'error-severity=') {
if (isset($this->overriddenDefaults['errorSeverity']) === true) {
break;
}
$this->errorSeverity = (int) substr($arg, 15);
$this->overriddenDefaults['errorSeverity'] = true;
- } else if (substr($arg, 0, 17) === 'warning-severity=') {
+ } elseif (substr($arg, 0, 17) === 'warning-severity=') {
if (isset($this->overriddenDefaults['warningSeverity']) === true) {
break;
}
$this->warningSeverity = (int) substr($arg, 17);
$this->overriddenDefaults['warningSeverity'] = true;
- } else if (substr($arg, 0, 7) === 'ignore=') {
+ } elseif (substr($arg, 0, 7) === 'ignore=') {
if (isset($this->overriddenDefaults['ignored']) === true) {
break;
}
@@ -1244,7 +1244,7 @@ public function processLongArgument(string $arg, int $pos)
$this->ignored = $ignored;
$this->overriddenDefaults['ignored'] = true;
- } else if (substr($arg, 0, 10) === 'generator='
+ } elseif (substr($arg, 0, 10) === 'generator='
&& PHP_CODESNIFFER_CBF === false
) {
if (isset($this->overriddenDefaults['generator']) === true) {
@@ -1268,14 +1268,14 @@ public function processLongArgument(string $arg, int $pos)
$this->generator = self::VALID_GENERATORS[$lowerCaseGeneratorName];
$this->overriddenDefaults['generator'] = true;
- } else if (substr($arg, 0, 9) === 'encoding=') {
+ } elseif (substr($arg, 0, 9) === 'encoding=') {
if (isset($this->overriddenDefaults['encoding']) === true) {
break;
}
$this->encoding = strtolower(substr($arg, 9));
$this->overriddenDefaults['encoding'] = true;
- } else if (substr($arg, 0, 10) === 'tab-width=') {
+ } elseif (substr($arg, 0, 10) === 'tab-width=') {
if (isset($this->overriddenDefaults['tabWidth']) === true) {
break;
}
@@ -1342,9 +1342,9 @@ private function parseSniffCodes(string $input, string $argument)
if ($partCount === 0) {
$errors[] = 'Standard codes are not supported: ' . $sniff;
- } else if ($partCount === 1) {
+ } elseif ($partCount === 1) {
$errors[] = 'Category codes are not supported: ' . $sniff;
- } else if ($partCount === 3) {
+ } elseif ($partCount === 3) {
$errors[] = 'Message codes are not supported: ' . $sniff;
} else {
$errors[] = 'Too many parts: ' . $sniff;
diff --git a/src/Files/File.php b/src/Files/File.php
index f2be65e770..180ee4f3aa 100644
--- a/src/Files/File.php
+++ b/src/Files/File.php
@@ -398,7 +398,7 @@ public function process()
$this->fixableErrorCount = 0;
$this->fixableWarningCount = 0;
return;
- } else if (substr($commentTextLower, 0, 9) === 'phpcs:set'
+ } elseif (substr($commentTextLower, 0, 9) === 'phpcs:set'
|| substr($commentTextLower, 0, 10) === '@phpcs:set'
) {
if (isset($token['sniffCode']) === true) {
@@ -984,7 +984,7 @@ protected function addMessage(
if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
$patterns = $this->configCache['includePatterns'][$checkCode];
$excluding = false;
- } else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
+ } elseif (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
$patterns = $this->configCache['ignorePatterns'][$checkCode];
$excluding = true;
}
@@ -1110,7 +1110,7 @@ public function recordMetric(int $stackPtr, string $metric, string $value)
if (isset($this->metrics[$metric]) === false) {
$this->metrics[$metric] = ['values' => [$value => 1]];
$this->metricTokens[$metric][$stackPtr] = true;
- } else if (isset($this->metricTokens[$metric][$stackPtr]) === false) {
+ } elseif (isset($this->metricTokens[$metric][$stackPtr]) === false) {
$this->metricTokens[$metric][$stackPtr] = true;
if (isset($this->metrics[$metric]['values'][$value]) === false) {
$this->metrics[$metric]['values'][$value] = 1;
@@ -1336,7 +1336,7 @@ public function getDeclarationName(int $stackPtr)
if (isset($this->tokens[$stackPtr]['parenthesis_opener']) === true) {
// For functions, stop searching at the parenthesis opener.
$stopPoint = $this->tokens[$stackPtr]['parenthesis_opener'];
- } else if (isset($this->tokens[$stackPtr]['scope_opener']) === true) {
+ } elseif (isset($this->tokens[$stackPtr]['scope_opener']) === true) {
// For OO tokens, stop searching at the open curly.
$stopPoint = $this->tokens[$stackPtr]['scope_opener'];
}
@@ -2347,7 +2347,7 @@ public function findPrevious(
if ($found === true) {
if ($value === null) {
return $i;
- } else if ($this->tokens[$i]['content'] === $value) {
+ } elseif ($this->tokens[$i]['content'] === $value) {
return $i;
}
}
@@ -2357,15 +2357,15 @@ public function findPrevious(
&& $i === $this->tokens[$i]['scope_closer']
) {
$i = $this->tokens[$i]['scope_opener'];
- } else if (isset($this->tokens[$i]['bracket_opener']) === true
+ } elseif (isset($this->tokens[$i]['bracket_opener']) === true
&& $i === $this->tokens[$i]['bracket_closer']
) {
$i = $this->tokens[$i]['bracket_opener'];
- } else if (isset($this->tokens[$i]['parenthesis_opener']) === true
+ } elseif (isset($this->tokens[$i]['parenthesis_opener']) === true
&& $i === $this->tokens[$i]['parenthesis_closer']
) {
$i = $this->tokens[$i]['parenthesis_opener'];
- } else if ($this->tokens[$i]['code'] === T_SEMICOLON) {
+ } elseif ($this->tokens[$i]['code'] === T_SEMICOLON) {
break;
}
}
@@ -2428,7 +2428,7 @@ public function findNext(
if ($found === true) {
if ($value === null) {
return $i;
- } else if ($this->tokens[$i]['content'] === $value) {
+ } elseif ($this->tokens[$i]['content'] === $value) {
return $i;
}
}
@@ -2613,11 +2613,11 @@ public function findStartOfStatement(int $start, $ignore = null)
&& $i === $this->tokens[$i]['bracket_closer']
) {
$i = $this->tokens[$i]['bracket_opener'];
- } else if (isset($this->tokens[$i]['parenthesis_opener']) === true
+ } elseif (isset($this->tokens[$i]['parenthesis_opener']) === true
&& $i === $this->tokens[$i]['parenthesis_closer']
) {
$i = $this->tokens[$i]['parenthesis_opener'];
- } else if ($this->tokens[$i]['code'] === T_CLOSE_USE_GROUP) {
+ } elseif ($this->tokens[$i]['code'] === T_CLOSE_USE_GROUP) {
$start = $this->findPrevious(T_OPEN_USE_GROUP, ($i - 1));
if ($start !== false) {
$i = $start;
@@ -2724,15 +2724,15 @@ public function findEndOfStatement(int $start, $ignore = null)
}
$i = $this->tokens[$i]['scope_closer'];
- } else if (isset($this->tokens[$i]['bracket_closer']) === true
+ } elseif (isset($this->tokens[$i]['bracket_closer']) === true
&& $i === $this->tokens[$i]['bracket_opener']
) {
$i = $this->tokens[$i]['bracket_closer'];
- } else if (isset($this->tokens[$i]['parenthesis_closer']) === true
+ } elseif (isset($this->tokens[$i]['parenthesis_closer']) === true
&& $i === $this->tokens[$i]['parenthesis_opener']
) {
$i = $this->tokens[$i]['parenthesis_closer'];
- } else if ($this->tokens[$i]['code'] === T_OPEN_USE_GROUP) {
+ } elseif ($this->tokens[$i]['code'] === T_OPEN_USE_GROUP) {
$end = $this->findNext(T_CLOSE_USE_GROUP, ($i + 1));
if ($end !== false) {
$i = $end;
@@ -2800,7 +2800,7 @@ public function findFirstOnLine($types, int $start, bool $exclude = false, ?stri
if ($found === true) {
if ($value === null) {
$foundToken = $i;
- } else if ($this->tokens[$i]['content'] === $value) {
+ } elseif ($this->tokens[$i]['content'] === $value) {
$foundToken = $i;
}
}
diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php
index cf9ea478da..4795a9e06a 100644
--- a/src/Filters/Filter.php
+++ b/src/Filters/Filter.php
@@ -127,7 +127,7 @@ public function accept()
if ($this->config->local === true) {
return false;
}
- } else if ($this->shouldProcessFile($filePath) === false) {
+ } elseif ($this->shouldProcessFile($filePath) === false) {
return false;
}
diff --git a/src/Fixer.php b/src/Fixer.php
index 59e0e7acc8..7b73c8a33c 100644
--- a/src/Fixer.php
+++ b/src/Fixer.php
@@ -201,7 +201,7 @@ public function fixFile()
if ($this->numFixes === 0 && $this->inConflict === false) {
// Nothing left to do.
break;
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::forceWrite("* fixed $this->numFixes violations, starting loop " . ($this->loops + 1) . ' *', 1);
}
}//end while
@@ -454,7 +454,7 @@ public function endChangeset()
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::forceWrite('=> Changeset failed to apply', 1);
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
$fixes = count($this->changeset);
StatusWriter::forceWrite("=> Changeset ended: $fixes changes applied", 1);
}
diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php
index 35d8c6f403..e91b92f7f3 100644
--- a/src/Generators/HTML.php
+++ b/src/Generators/HTML.php
@@ -274,7 +274,7 @@ public function processSniff(DOMElement $doc)
foreach ($doc->childNodes as $node) {
if ($node->nodeName === 'standard') {
$content .= $this->getFormattedTextBlock($node);
- } else if ($node->nodeName === 'code_comparison') {
+ } elseif ($node->nodeName === 'code_comparison') {
$content .= $this->getFormattedCodeComparisonBlock($node);
}
}
diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php
index 7f4ecaeaf4..71fe0b85b8 100644
--- a/src/Generators/Markdown.php
+++ b/src/Generators/Markdown.php
@@ -112,7 +112,7 @@ protected function processSniff(DOMElement $doc)
foreach ($doc->childNodes as $node) {
if ($node->nodeName === 'standard') {
$content .= $this->getFormattedTextBlock($node);
- } else if ($node->nodeName === 'code_comparison') {
+ } elseif ($node->nodeName === 'code_comparison') {
$content .= $this->getFormattedCodeComparisonBlock($node);
}
}
diff --git a/src/Generators/Text.php b/src/Generators/Text.php
index 81d5b362ba..412995f9b8 100644
--- a/src/Generators/Text.php
+++ b/src/Generators/Text.php
@@ -35,7 +35,7 @@ public function processSniff(DOMElement $doc)
foreach ($doc->childNodes as $node) {
if ($node->nodeName === 'standard') {
$content .= $this->getFormattedTextBlock($node);
- } else if ($node->nodeName === 'code_comparison') {
+ } elseif ($node->nodeName === 'code_comparison') {
$content .= $this->getFormattedCodeComparisonBlock($node);
}
}
diff --git a/src/Reporter.php b/src/Reporter.php
index fdf2258806..fe995605f2 100644
--- a/src/Reporter.php
+++ b/src/Reporter.php
@@ -128,10 +128,10 @@ public function __construct(Config $config)
}
$reportClassName = Autoload::loadFile($filename);
- } else if (class_exists('PHP_CodeSniffer\Reports\\' . ucfirst($type)) === true) {
+ } elseif (class_exists('PHP_CodeSniffer\Reports\\' . ucfirst($type)) === true) {
// PHPCS native report.
$reportClassName = 'PHP_CodeSniffer\Reports\\' . ucfirst($type);
- } else if (class_exists($type) === true) {
+ } elseif (class_exists($type) === true) {
// FQN of a custom report.
$reportClassName = $type;
} else {
diff --git a/src/Reports/Code.php b/src/Reports/Code.php
index 15e86ae16f..e825f6f1df 100644
--- a/src/Reports/Code.php
+++ b/src/Reports/Code.php
@@ -50,7 +50,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
if (PHP_CODESNIFFER_VERBOSITY === 1) {
$startTime = microtime(true);
StatusWriter::forceWrite('CODE report is parsing ' . basename($file) . ' ', 0, 0);
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::forceWrite("CODE report is forcing parse of $file");
}
diff --git a/src/Reports/Diff.php b/src/Reports/Diff.php
index 3f354ec9be..4d6d75a095 100644
--- a/src/Reports/Diff.php
+++ b/src/Reports/Diff.php
@@ -45,7 +45,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
if (PHP_CODESNIFFER_VERBOSITY === 1) {
$startTime = microtime(true);
StatusWriter::write('DIFF report is parsing ' . basename($report['filename']) . ' ', 0, 0);
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('DIFF report is forcing parse of ' . $report['filename']);
}
diff --git a/src/Reports/Performance.php b/src/Reports/Performance.php
index 2c24d2db5f..00aae4cf4e 100644
--- a/src/Reports/Performance.php
+++ b/src/Reports/Performance.php
@@ -134,7 +134,7 @@ public function generate(
if ($time > $tripleAvgSniffTime) {
printf($formatError, $sniff, $time, $percent);
- } else if ($time > $doubleAvgSniffTime) {
+ } elseif ($time > $doubleAvgSniffTime) {
printf($formatWarning, $sniff, $time, $percent);
} else {
printf($format, $sniff, $time, $percent);
diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php
index 45551a4b81..90bb5f988c 100644
--- a/src/Reports/Summary.php
+++ b/src/Reports/Summary.php
@@ -108,7 +108,7 @@ static function ($keyA, $keyB) {
if (empty($pathPartsA) === false && empty($pathPartsB) === true) {
return 1;
- } else if (empty($pathPartsA) === true && empty($pathPartsB) === false) {
+ } elseif (empty($pathPartsA) === true && empty($pathPartsB) === false) {
return -1;
} else {
return strcasecmp($partA, $partB);
diff --git a/src/Reports/Xml.php b/src/Reports/Xml.php
index e119a5f55f..a606a8a283 100644
--- a/src/Reports/Xml.php
+++ b/src/Reports/Xml.php
@@ -79,7 +79,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$content = $out->flush();
if (strpos($content, PHP_EOL) !== false) {
$content = substr($content, (strpos($content, PHP_EOL) + strlen(PHP_EOL)));
- } else if (strpos($content, "\n") !== false) {
+ } elseif (strpos($content, "\n") !== false) {
$content = substr($content, (strpos($content, "\n") + 1));
}
diff --git a/src/Ruleset.php b/src/Ruleset.php
index b6e9faa0df..4585e6d3e8 100644
--- a/src/Ruleset.php
+++ b/src/Ruleset.php
@@ -581,7 +581,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
if ($relativePath !== false && is_file($relativePath) === true) {
$autoloadPath = $relativePath;
- } else if (is_file($autoloadPath) === false) {
+ } elseif (is_file($autoloadPath) === false) {
throw new RuntimeException('ERROR: The specified autoload file "' . $autoload . '" does not exist');
}
@@ -737,7 +737,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
StatusWriter::write('* disabling sniff exclusion for specific message code *', ($depth + 2));
StatusWriter::write('=> severity set to 5', ($depth + 2));
}
- } else if (empty($newSniffs) === false) {
+ } elseif (empty($newSniffs) === false) {
$newSniff = $newSniffs[0];
if (in_array($newSniff, $ownSniffs, true) === false) {
// Including a sniff that hasn't been included higher up, but
@@ -1028,7 +1028,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('=> ' . Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
}
- } else if (is_dir($ref) === false) {
+ } elseif (is_dir($ref) === false) {
// Work out the sniff path.
$sepPos = strpos($ref, DIRECTORY_SEPARATOR);
if ($sepPos !== false) {
@@ -1040,7 +1040,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
if (count($parts) === 1) {
// A whole standard?
$path = '';
- } else if (count($parts) === 2) {
+ } elseif (count($parts) === 2) {
// A directory of sniffs?
$path = DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR . $parts[1];
} else {
@@ -1249,7 +1249,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
$this->ruleset[$code] = [
'properties' => [],
];
- } else if (isset($this->ruleset[$code]['properties']) === false) {
+ } elseif (isset($this->ruleset[$code]['properties']) === false) {
$this->ruleset[$code]['properties'] = [];
}
diff --git a/src/Runner.php b/src/Runner.php
index 016674305a..f6d6574837 100644
--- a/src/Runner.php
+++ b/src/Runner.php
@@ -390,7 +390,7 @@ private function run()
}
$this->processFile($file);
- } else if (PHP_CODESNIFFER_VERBOSITY > 0) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 0) {
StatusWriter::write('Skipping ' . basename($file->path));
}
@@ -417,7 +417,7 @@ private function run()
$pid = pcntl_fork();
if ($pid === -1) {
throw new RuntimeException('Failed to create child process');
- } else if ($pid !== 0) {
+ } elseif ($pid !== 0) {
$childProcs[$pid] = $childOutFilename;
} else {
// Move forward to the start of the batch.
@@ -804,7 +804,7 @@ public function printProgress(File $file, int $numFiles, int $numProcessed)
$colorOpen = "\033[31m";
$colorClose = "\033[0m";
}
- } else if ($fixed > 0) {
+ } elseif ($fixed > 0) {
$progressDot = 'F';
if ($showColors === true) {
@@ -830,7 +830,7 @@ public function printProgress(File $file, int $numFiles, int $numProcessed)
$colorClose = "\033[0m";
}
- } else if ($warnings > 0) {
+ } elseif ($warnings > 0) {
$progressDot = 'W';
if ($showColors === true) {
diff --git a/src/Sniffs/AbstractArraySniff.php b/src/Sniffs/AbstractArraySniff.php
index 3908dafe04..9d051f38a0 100644
--- a/src/Sniffs/AbstractArraySniff.php
+++ b/src/Sniffs/AbstractArraySniff.php
@@ -117,9 +117,9 @@ private function getNext(File $phpcsFile, int $ptr, int $arrayEnd)
while ($ptr < $arrayEnd) {
if (isset($tokens[$ptr]['scope_closer']) === true) {
$ptr = $tokens[$ptr]['scope_closer'];
- } else if (isset($tokens[$ptr]['parenthesis_closer']) === true) {
+ } elseif (isset($tokens[$ptr]['parenthesis_closer']) === true) {
$ptr = $tokens[$ptr]['parenthesis_closer'];
- } else if (isset($tokens[$ptr]['bracket_closer']) === true) {
+ } elseif (isset($tokens[$ptr]['bracket_closer']) === true) {
$ptr = $tokens[$ptr]['bracket_closer'];
}
diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php
index 14ce4297ea..8869dc623d 100644
--- a/src/Sniffs/AbstractPatternSniff.php
+++ b/src/Sniffs/AbstractPatternSniff.php
@@ -212,7 +212,7 @@ final public function process(File $phpcsFile, int $stackPtr)
if ($errors === false) {
// The pattern didn't match.
continue;
- } else if (empty($errors) === true) {
+ } elseif (empty($errors) === true) {
// The pattern matched, but there were no errors.
break;
}
@@ -314,7 +314,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
$stackPtr = ($prev - 1);
}
}//end if
- } else if ($pattern[$i]['type'] === 'skip') {
+ } elseif ($pattern[$i]['type'] === 'skip') {
// Skip to next piece of relevant code.
if ($pattern[$i]['to'] === 'parenthesis_closer') {
$to = 'parenthesis_opener';
@@ -346,9 +346,9 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
// Skip to the opening token.
$stackPtr = ($tokens[$next][$to] - 1);
- } else if ($pattern[$i]['type'] === 'string') {
+ } elseif ($pattern[$i]['type'] === 'string') {
$found = 'abc';
- } else if ($pattern[$i]['type'] === 'newline') {
+ } elseif ($pattern[$i]['type'] === 'newline') {
if ($this->ignoreComments === true
&& isset(Tokens::COMMENT_TOKENS[$tokens[$stackPtr]['code']]) === true
) {
@@ -572,7 +572,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
$stackPtr = ($next + 1);
}
}//end if
- } else if ($pattern[$i]['type'] === 'skip') {
+ } elseif ($pattern[$i]['type'] === 'skip') {
if ($pattern[$i]['to'] === 'unknown') {
$next = $phpcsFile->findNext(
$pattern[($i + 1)]['token'],
@@ -612,7 +612,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
// Skip to the closing token.
$stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1);
}//end if
- } else if ($pattern[$i]['type'] === 'string') {
+ } elseif ($pattern[$i]['type'] === 'string') {
if ($tokens[$stackPtr]['code'] !== T_STRING) {
$hasError = true;
}
@@ -623,7 +623,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
}
$stackPtr++;
- } else if ($pattern[$i]['type'] === 'newline') {
+ } elseif ($pattern[$i]['type'] === 'newline') {
// Find the next token that contains a newline character.
$newline = 0;
for ($j = $stackPtr; $j < $phpcsFile->numTokens; $j++) {
@@ -788,12 +788,12 @@ private function parse(string $pattern)
if ($specialPattern['to'] !== 'unknown') {
$firstToken++;
}
- } else if (substr($pattern, $i, 3) === 'abc') {
+ } elseif (substr($pattern, $i, 3) === 'abc') {
$specialPattern = ['type' => 'string'];
$lastToken = ($i - $firstToken);
$firstToken = ($i + 3);
$i += 2;
- } else if (substr($pattern, $i, 3) === 'EOL') {
+ } elseif (substr($pattern, $i, 3) === 'EOL') {
$specialPattern = ['type' => 'newline'];
$lastToken = ($i - $firstToken);
$firstToken = ($i + 3);
diff --git a/src/Sniffs/AbstractVariableSniff.php b/src/Sniffs/AbstractVariableSniff.php
index a1e3c96896..3e99f2cfa7 100644
--- a/src/Sniffs/AbstractVariableSniff.php
+++ b/src/Sniffs/AbstractVariableSniff.php
@@ -168,7 +168,7 @@ final protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr
// These variables are not member vars.
if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
return $this->processVariable($phpcsFile, $stackPtr);
- } else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING
+ } elseif ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING
|| $tokens[$stackPtr]['code'] === T_HEREDOC
) {
// Check to see if this string has a variable in it.
diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php
index 11d7761744..dd67962fe3 100644
--- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php
+++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php
@@ -68,7 +68,7 @@ public function process(File $phpcsFile, int $stackPtr)
|| $tokens[$nextNonEmpty]['code'] === T_NAME_QUALIFIED
) {
$namespace = $tokens[$nextNonEmpty]['content'];
- } else if ($tokens[$nextNonEmpty]['code'] === T_OPEN_CURLY_BRACKET) {
+ } elseif ($tokens[$nextNonEmpty]['code'] === T_OPEN_CURLY_BRACKET) {
$namespace = '';
}
diff --git a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php
index bb5e879467..a003273cbf 100644
--- a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php
+++ b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php
@@ -98,7 +98,7 @@ public function process(File $phpcsFile, int $stackPtr)
// Is there precisely one space before the opening brace ?
if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) {
$length = 0;
- } else if ($tokens[($openingBrace - 1)]['content'] === "\t") {
+ } elseif ($tokens[($openingBrace - 1)]['content'] === "\t") {
$length = '\t';
} else {
$length = $tokens[($openingBrace - 1)]['length'];
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php
index 7fa17a73e2..de415aff5f 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php
@@ -100,7 +100,7 @@ public function process(File $phpcsFile, int $stackPtr)
$closer = $semicolon;
unset($semicolon);
- } else if ($token['code'] === T_CASE) {
+ } elseif ($token['code'] === T_CASE) {
if (isset($token['scope_opener']) === false) {
return;
}
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php
index 0b5c1e7753..95b5a9d4a0 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php
@@ -75,7 +75,7 @@ public function process(File $phpcsFile, int $stackPtr)
$code = $tokens[$next]['code'];
if ($code === T_SEMICOLON) {
++$index;
- } else if (isset(Tokens::EMPTY_TOKENS[$code]) === false) {
+ } elseif (isset(Tokens::EMPTY_TOKENS[$code]) === false) {
++$parts[$index];
}
}
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php
index 4731fdc4b4..d68269af9f 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php
@@ -78,9 +78,9 @@ public function process(File $phpcsFile, int $stackPtr)
if ($position < 1) {
continue;
- } else if ($position > 1) {
+ } elseif ($position > 1) {
break;
- } else if ($code !== T_VARIABLE && isset(Tokens::NAME_TOKENS[$code]) === false) {
+ } elseif ($code !== T_VARIABLE && isset(Tokens::NAME_TOKENS[$code]) === false) {
continue;
}
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php
index 786bafb656..28eb7c0157 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php
@@ -121,7 +121,7 @@ protected function findIncrementers(array $tokens, array $token)
$code = $tokens[$next]['code'];
if ($code === T_SEMICOLON) {
++$semicolons;
- } else if ($semicolons === 2 && $code === T_VARIABLE) {
+ } elseif ($semicolons === 2 && $code === T_VARIABLE) {
$incrementers[] = $tokens[$next]['content'];
}
}
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php
index 6916514d0b..9f8a61891c 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php
@@ -77,7 +77,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (isset(Tokens::EMPTY_TOKENS[$code]) === true) {
continue;
- } else if ($code !== T_TRUE && $code !== T_FALSE) {
+ } elseif ($code !== T_TRUE && $code !== T_FALSE) {
$goodCondition = true;
}
}
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
index f60cb15c34..6c0fc7731c 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
@@ -110,7 +110,7 @@ public function process(File $phpcsFile, int $stackPtr)
$extends = $phpcsFile->findExtendedClassName($classPtr);
if ($extends !== false) {
$errorCode .= 'InExtendedClass';
- } else if ($implements !== false) {
+ } elseif ($implements !== false) {
$errorCode .= 'InImplementedInterface';
}
}
@@ -197,7 +197,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($code === T_VARIABLE && isset($params[$token['content']]) === true) {
unset($params[$token['content']]);
- } else if ($code === T_DOLLAR) {
+ } elseif ($code === T_DOLLAR) {
$nextToken = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) {
$nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
@@ -208,7 +208,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
}
}
- } else if ($code === T_DOUBLE_QUOTED_STRING
+ } elseif ($code === T_DOUBLE_QUOTED_STRING
|| $code === T_START_HEREDOC
|| $code === T_START_NOWDOC
) {
@@ -233,7 +233,7 @@ public function process(File $phpcsFile, int $stackPtr)
$varContent = '';
if ($stringToken[0] === T_DOLLAR_OPEN_CURLY_BRACES) {
$varContent = '$' . $stringTokens[($stringPtr + 1)][1];
- } else if ($stringToken[0] === T_VARIABLE) {
+ } elseif ($stringToken[0] === T_VARIABLE) {
$varContent = $stringToken[1];
}
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php
index 0dcc971251..8aca01a338 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php
@@ -96,7 +96,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (isset(Tokens::EMPTY_TOKENS[$code]) === true) {
continue;
- } else if ($code === T_RETURN) {
+ } elseif ($code === T_RETURN) {
continue;
}
@@ -139,11 +139,11 @@ public function process(File $phpcsFile, int $stackPtr)
if ($code === T_OPEN_PARENTHESIS) {
++$parenthesisCount;
- } else if ($code === T_CLOSE_PARENTHESIS) {
+ } elseif ($code === T_CLOSE_PARENTHESIS) {
--$parenthesisCount;
- } else if ($parenthesisCount === 1 && $code === T_COMMA) {
+ } elseif ($parenthesisCount === 1 && $code === T_COMMA) {
$parameters[] = '';
- } else if (isset(Tokens::EMPTY_TOKENS[$code]) === false) {
+ } elseif (isset(Tokens::EMPTY_TOKENS[$code]) === false) {
$parameters[(count($parameters) - 1)] .= $tokens[$next]['content'];
}
diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php
index 6a96c26d9f..f430863cba 100644
--- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php
+++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php
@@ -120,7 +120,7 @@ public function process(File $phpcsFile, int $stackPtr)
for ($i = $stackPtr; $i < $short; $i++) {
if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
continue;
- } else if ($tokens[$i]['line'] === $tokens[$short]['line']) {
+ } elseif ($tokens[$i]['line'] === $tokens[$short]['line']) {
break;
}
@@ -161,7 +161,7 @@ public function process(File $phpcsFile, int $stackPtr)
for ($i = ($shortEnd + 1); $i < $long; $i++) {
if ($tokens[$i]['line'] === $tokens[$shortEnd]['line']) {
continue;
- } else if ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) {
+ } elseif ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) {
break;
}
diff --git a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php
index acf73d4b79..4ba92d0444 100644
--- a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php
+++ b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php
@@ -110,7 +110,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($prev === false) {
return;
}
- } else if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_ARRAY
+ } elseif ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_ARRAY
&& $this->isArrayStatic($phpcsFile, $beforeOpeningParenthesisIndex) === false
) {
return;
@@ -141,7 +141,7 @@ public function isArrayStatic(File $phpcsFile, int $arrayToken)
if ($tokens[$arrayToken]['code'] === T_OPEN_SHORT_ARRAY) {
$start = $arrayToken;
$end = $tokens[$arrayToken]['bracket_closer'];
- } else if ($tokens[$arrayToken]['code'] === T_ARRAY) {
+ } elseif ($tokens[$arrayToken]['code'] === T_ARRAY) {
$start = $tokens[$arrayToken]['parenthesis_opener'];
$end = $tokens[$arrayToken]['parenthesis_closer'];
} else {
diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
index 3683956e21..aad0c68d6b 100644
--- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
+++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
@@ -72,7 +72,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
$nextTokenIndex = ($tokens[$stackPtr]['parenthesis_closer'] + 1);
- } else if (in_array($tokens[$stackPtr]['code'], [T_ELSE, T_DO], true) === true) {
+ } elseif (in_array($tokens[$stackPtr]['code'], [T_ELSE, T_DO], true) === true) {
$nextTokenIndex = ($stackPtr + 1);
}
@@ -220,7 +220,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($type === T_DO && $nextType === T_WHILE) {
$end = $phpcsFile->findNext(T_SEMICOLON, ($next + 1));
}
- } else if ($type === T_CLOSURE) {
+ } elseif ($type === T_CLOSURE) {
// There should be a semicolon after the closing brace.
$next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($end + 1), null, true);
if ($next !== false && $tokens[$next]['code'] === T_SEMICOLON) {
@@ -302,7 +302,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[$first]['code'] === T_WHITESPACE) {
$indent = $tokens[$first]['content'];
- } else if ($tokens[$first]['code'] === T_INLINE_HTML
+ } elseif ($tokens[$first]['code'] === T_INLINE_HTML
|| $tokens[$first]['code'] === T_OPEN_TAG
) {
$addedContent = '';
diff --git a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php
index 9f0d59da21..f74eb030ad 100644
--- a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php
+++ b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php
@@ -144,9 +144,9 @@ protected function checkLineLength(File $phpcsFile, array $tokens, int $stackPtr
// Record metrics for common line length groupings.
if ($lineLength <= 80) {
$phpcsFile->recordMetric($stackPtr, 'Line length', '80 or less');
- } else if ($lineLength <= 120) {
+ } elseif ($lineLength <= 120) {
$phpcsFile->recordMetric($stackPtr, 'Line length', '81-120');
- } else if ($lineLength <= 150) {
+ } elseif ($lineLength <= 150) {
$phpcsFile->recordMetric($stackPtr, 'Line length', '121-150');
} else {
$phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
@@ -185,7 +185,7 @@ protected function checkLineLength(File $phpcsFile, array $tokens, int $stackPtr
$error = 'Line exceeds maximum limit of %s characters; contains %s characters';
$phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
- } else if ($lineLength > $this->lineLimit) {
+ } elseif ($lineLength > $this->lineLimit) {
$data = [
$this->lineLimit,
$lineLength,
diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
index 8f2ce181e6..46e8d582fe 100644
--- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
+++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
@@ -191,7 +191,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null)
} else {
$lastSemi = $assign;
}
- } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
+ } elseif ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
// Statement is in a different context, so the block is over.
break;
}
@@ -199,7 +199,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null)
}//end if
continue;
- } else if ($assign !== $stackPtr && $tokens[$assign]['line'] === $lastLine) {
+ } elseif ($assign !== $stackPtr && $tokens[$assign]['line'] === $lastLine) {
// Skip multiple assignments on the same line. We only need to
// try and align the first assignment.
continue;
@@ -212,10 +212,10 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null)
$assign = $this->checkAlignment($phpcsFile, $assign);
$lastCode = $assign;
continue;
- } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
+ } elseif ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
// We've gone one level up, so the block we are processing is done.
break;
- } else if ($arrayEnd !== null) {
+ } elseif ($arrayEnd !== null) {
// Assignments inside arrays are not part of
// the original block, so process this new block.
$assign = ($this->checkAlignment($phpcsFile, $assign, $arrayEnd) - 1);
@@ -301,7 +301,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null)
$padding = 1;
$assignColumn = ($varEnd + 1);
}
- } else if ($padding > $assignments[$maxPadding]['expected']) {
+ } elseif ($padding > $assignments[$maxPadding]['expected']) {
$maxPadding = $assign;
}//end if
} else {
diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php
index a35a5042c7..9bd3218629 100644
--- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php
+++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php
@@ -106,7 +106,7 @@ public function process(File $phpcsFile, int $stackPtr)
$found = 0;
if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
$found = 'newline';
- } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
$found = $tokens[($stackPtr + 1)]['length'];
}
@@ -127,7 +127,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($this->spacing !== 0) {
if ($found === 0) {
$errorCode = 'NoSpace';
- } else if ($found !== 'newline' && $found < $this->spacing) {
+ } elseif ($found !== 'newline' && $found < $this->spacing) {
$errorCode = 'TooLittleSpace';
}
}
diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php
index f1c60b700f..901680f56f 100644
--- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php
+++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php
@@ -90,7 +90,7 @@ public function process(File $phpcsFile, int $stackPtr)
$found = 0;
if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
$found = 'newline';
- } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
$found = $tokens[($stackPtr + 1)]['length'];
}
diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php
index a1e13a5a44..8a425621ac 100644
--- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php
+++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php
@@ -123,12 +123,12 @@ public function checkSpacing(File $phpcsFile, int $stackPtr, int $openBracket)
// Skip closures, anon class declarations and match control structures.
$nextSeparator = $tokens[$nextSeparator]['scope_closer'];
continue;
- } else if ($tokens[$nextSeparator]['code'] === T_FN) {
+ } elseif ($tokens[$nextSeparator]['code'] === T_FN) {
// Skip arrow functions, but don't skip the arrow function closer as it is likely to
// be the comma separating it from the next function call argument (or the parenthesis closer).
$nextSeparator = ($tokens[$nextSeparator]['scope_closer'] - 1);
continue;
- } else if ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) {
+ } elseif ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) {
// Skips arrays using short notation.
$nextSeparator = $tokens[$nextSeparator]['bracket_closer'];
continue;
diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php
index e6f0f08373..1b9d0accf0 100644
--- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php
+++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php
@@ -135,7 +135,7 @@ public function process(File $phpcsFile, int $stackPtr)
}//end if
$phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line');
- } else if ($lineDifference > 1) {
+ } elseif ($lineDifference > 1) {
$error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
$data = [($lineDifference - 1)];
diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php
index 45a847f67b..3f018d5945 100644
--- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php
+++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php
@@ -142,7 +142,7 @@ public function process(File $phpcsFile, int $stackPtr)
$spacing = $tokens[($openingBrace - 1)]['content'];
if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) {
$length = 0;
- } else if ($spacing === "\t") {
+ } elseif ($spacing === "\t") {
// Tab without tab-width set, so no tab replacement has taken place.
$length = '\t';
} else {
diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php
index 085a4b404f..457e06835a 100644
--- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php
+++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php
@@ -106,7 +106,7 @@ public function process(File $phpcsFile, int $stackPtr)
$this->absoluteComplexity,
];
$phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
- } else if ($complexity > $this->complexity) {
+ } elseif ($complexity > $this->complexity) {
$warning = 'Function\'s cyclomatic complexity (%s) exceeds %s; consider refactoring the function';
$data = [
$complexity,
diff --git a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php
index 4fc9e7d352..871f5ead85 100644
--- a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php
+++ b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php
@@ -85,7 +85,7 @@ public function process(File $phpcsFile, int $stackPtr)
$this->absoluteNestingLevel,
];
$phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
- } else if ($nestingLevel > $this->nestingLevel) {
+ } elseif ($nestingLevel > $this->nestingLevel) {
$warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
$data = [
$nestingLevel,
diff --git a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php
index 92039f1bfe..b04532d806 100644
--- a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php
+++ b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php
@@ -89,7 +89,7 @@ protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $
$error = 'PHP4 style constructors are not allowed; use "__construct()" instead';
$phpcsFile->addError($error, $stackPtr, 'OldStyle');
}
- } else if ($methodName !== '__construct') {
+ } elseif ($methodName !== '__construct') {
// Not a constructor.
return;
}
diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php
index 061f9bc21e..06a05829ac 100644
--- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php
+++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php
@@ -66,7 +66,7 @@ public function process(File $phpcsFile, int $stackPtr)
$data = ['<%=' . $snippet];
$phpcsFile->addWarning($error, $stackPtr, 'MaybeASPShortOpenTagFound', $data);
- } else if (strpos($content, '<%') !== false) {
+ } elseif (strpos($content, '<%') !== false) {
$error = 'Possible use of ASP style opening tags detected; found: %s';
$snippet = $this->getSnippet($content, '<%');
$data = ['<%' . $snippet];
diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php
index cda3308a69..809b1f401d 100644
--- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php
+++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php
@@ -112,7 +112,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($closerFound !== false) {
if ($i !== $stackPtr) {
break;
- } else if ($closerFound > $openerFound) {
+ } elseif ($closerFound > $openerFound) {
break;
} else {
$closerFound = false;
diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php
index 31836e7f02..3c9bef6ede 100644
--- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php
+++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php
@@ -182,7 +182,7 @@ public function process(File $phpcsFile, int $stackPtr)
$error,
$errorCode
);
- } else if (isset(self::PHP_TYPES[strtolower($type)]) === true) {
+ } elseif (isset(self::PHP_TYPES[strtolower($type)]) === true) {
$this->processType($phpcsFile, $props['type_token'], $type, $error, $errorCode);
}
}
@@ -213,7 +213,7 @@ public function process(File $phpcsFile, int $stackPtr)
$error,
$errorCode
);
- } else if (isset(self::PHP_TYPES[strtolower($returnType)]) === true) {
+ } elseif (isset(self::PHP_TYPES[strtolower($returnType)]) === true) {
$this->processType($phpcsFile, $props['return_type_token'], $returnType, $error, $errorCode);
}
}
@@ -244,7 +244,7 @@ public function process(File $phpcsFile, int $stackPtr)
$error,
$errorCode
);
- } else if (isset(self::PHP_TYPES[strtolower($typeHint)]) === true) {
+ } elseif (isset(self::PHP_TYPES[strtolower($typeHint)]) === true) {
$this->processType($phpcsFile, $param['type_hint_token'], $typeHint, $error, $errorCode);
}
}
diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php
index 120b8810c3..210c77a481 100644
--- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php
+++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php
@@ -101,7 +101,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (substr($tokens[$i]['content'], 0, 12) === '<<<<<<< HEAD') {
$phpcsFile->addError($error, $i, 'OpenerFound', ['opener']);
break;
- } else if (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') {
+ } elseif (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') {
$phpcsFile->addError($error, $i, 'CloserFound', ['closer']);
break;
}
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php
index 2b852d2394..77e5b7d6e0 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php
@@ -156,7 +156,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($expected !== '') {
$phpcsFile->fixer->addContent($stackPtr, $expected);
}
- } else if ($inside === 'newline') {
+ } elseif ($inside === 'newline') {
$phpcsFile->fixer->beginChangeset();
for ($i = ($stackPtr + 2); $i < $phpcsFile->numTokens; $i++) {
if ($tokens[$i]['code'] !== T_WHITESPACE) {
@@ -210,7 +210,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($expected !== '') {
$phpcsFile->fixer->addContentBefore($stackPtr, $expected);
}
- } else if ($inside === 'newline') {
+ } elseif ($inside === 'newline') {
$phpcsFile->fixer->beginChangeset();
for ($i = ($stackPtr - 2); $i > 0; $i--) {
if ($tokens[$i]['code'] !== T_WHITESPACE) {
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php
index 3afd7653c0..5be75cf911 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php
@@ -122,7 +122,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (isset($matches[2]) === true) {
$nonWhitespace = $matches[2];
}
- } else if (isset($tokens[($i + 1)]) === true
+ } elseif (isset($tokens[($i + 1)]) === true
&& $tokens[$i]['line'] < $tokens[($i + 1)]['line']
) {
// There is no content after this whitespace except for a newline.
@@ -193,7 +193,7 @@ public function process(File $phpcsFile, int $stackPtr)
// end of the whitespace.
continue;
}
- } else if ($recordMetrics === true) {
+ } elseif ($recordMetrics === true) {
$phpcsFile->recordMetric($i, 'Line indent', 'mixed');
}
}//end if
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php
index 74bdcb8dd5..99474c990f 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php
@@ -133,9 +133,9 @@ public function process(File $phpcsFile, int $stackPtr)
if ($foundIndentTabs > 0 && $foundIndentSpaces === 0) {
$phpcsFile->recordMetric($i, 'Line indent', 'tabs');
- } else if ($foundIndentTabs === 0 && $foundIndentSpaces > 0) {
+ } elseif ($foundIndentTabs === 0 && $foundIndentSpaces > 0) {
$phpcsFile->recordMetric($i, 'Line indent', 'spaces');
- } else if ($foundIndentTabs > 0 && $foundIndentSpaces > 0) {
+ } elseif ($foundIndentTabs > 0 && $foundIndentSpaces > 0) {
$spacePosition = strpos($indentation, ' ');
$tabAfterSpaces = strpos($indentation, "\t", $spacePosition);
if ($tabAfterSpaces !== false) {
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php
index 18f1c7aa3a..1545c1767a 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php
@@ -51,9 +51,9 @@ public function process(File $phpcsFile, int $stackPtr)
if ($nextNonWhiteSpace !== $nextNonEmpty) {
$found = 'comment';
- } else if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonWhiteSpace]['line']) {
+ } elseif ($tokens[$stackPtr]['line'] !== $tokens[$nextNonWhiteSpace]['line']) {
$found = 'newline';
- } else if ($tokens[($stackPtr + 1)]['length'] === 1) {
+ } elseif ($tokens[($stackPtr + 1)]['length'] === 1) {
$found = '1 space';
} else {
$found = $tokens[($stackPtr + 1)]['length'] . ' spaces';
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php
index 3afc151f5c..1d18b2493f 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php
@@ -146,7 +146,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
}
}
- } else if ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) {
+ } elseif ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) {
$error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"';
$data = [
$tokens[$stackPtr]['content'] . ' ' . $tokens[($stackPtr + 1)]['content'],
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
index dcb3adc3b4..e4833c5ac5 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
@@ -187,7 +187,7 @@ public function process(File $phpcsFile, int $stackPtr)
$value = $tokens[$i]['sniffPropertyValue'];
if ($value === 'true') {
$value = true;
- } else if ($value === 'false') {
+ } elseif ($value === 'false') {
$value = false;
} else {
$value = (bool) $value;
@@ -308,7 +308,7 @@ public function process(File $phpcsFile, int $stackPtr)
$parenOpener = $parens;
$condition = 0;
- } else if ($condition > 0) {
+ } elseif ($condition > 0) {
if ($this->debug === true) {
StatusWriter::write('* using condition *', 1);
}
@@ -345,7 +345,7 @@ public function process(File $phpcsFile, int $stackPtr)
$type = $tokens[$lastOpenTag]['type'];
StatusWriter::write("=> checking indent of $checkIndent; main indent set to $currentIndent by token $lastOpenTag ($type)", 1);
}
- } else if ($condition > 0
+ } elseif ($condition > 0
&& isset($tokens[$condition]['scope_opener']) === true
&& isset($setIndents[$tokens[$condition]['scope_opener']]) === true
) {
@@ -456,7 +456,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
}//end if
}//end if
- } else if ($this->debug === true) {
+ } elseif ($this->debug === true) {
StatusWriter::write(' * ignoring single-line definition *', 1);
}//end if
}//end if
@@ -512,7 +512,7 @@ public function process(File $phpcsFile, int $stackPtr)
$type = $tokens[$first]['type'];
StatusWriter::write("* amended first token is $first ($type) on line $line *", 1);
}
- } else if ($tokens[$first]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[$first]['code'] === T_WHITESPACE) {
$first = $phpcsFile->findNext(T_WHITESPACE, ($first + 1), null, true);
}
@@ -552,7 +552,7 @@ public function process(File $phpcsFile, int $stackPtr)
StatusWriter::write("=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)", 1);
}
}//end if
- } else if ($this->debug === true) {
+ } elseif ($this->debug === true) {
StatusWriter::write(' * ignoring single-line definition *', 1);
}//end if
}//end if
@@ -1226,7 +1226,7 @@ public function process(File $phpcsFile, int $stackPtr)
$prev = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($parens - 1), null, true);
$condition = 0;
- } else if ($condition > 0) {
+ } elseif ($condition > 0) {
if ($this->debug === true) {
StatusWriter::write('* using condition *', 1);
}
@@ -1289,7 +1289,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($condition === 0 || $tokens[$condition]['scope_opener'] < $first) {
$currentIndent = $setIndents[$first];
- } else if ($this->debug === true) {
+ } elseif ($this->debug === true) {
StatusWriter::write('* ignoring scope closer *', 1);
}
}
diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php
index ae9c5aeb6f..16cc739021 100644
--- a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php
+++ b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php
@@ -104,7 +104,7 @@ public function process(File $phpcsFile, int $stackPtr)
$found = 0;
if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
$found = 'newline';
- } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
$found = $tokens[($stackPtr + 1)]['length'];
}
@@ -125,7 +125,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($this->spacing !== 0) {
if ($found === 0) {
$errorCode = 'NoSpace';
- } else if ($found !== 'newline' && $found < $this->spacing) {
+ } elseif ($found !== 'newline' && $found < $this->spacing) {
$errorCode = 'TooLittleSpace';
}
}
diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php
index 5a71f4d4f4..bf8b52bf90 100644
--- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php
+++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php
@@ -132,12 +132,12 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) {
// We are only interested if this is the first open tag.
return $phpcsFile->numTokens;
- } else if ($tokens[$commentStart]['code'] === T_COMMENT) {
+ } elseif ($tokens[$commentStart]['code'] === T_COMMENT) {
$error = 'You must use "/**" style comments for a file comment';
$phpcsFile->addError($error, $errorToken, 'WrongStyle');
$phpcsFile->recordMetric($stackPtr, 'File has doc comment', 'yes');
return $phpcsFile->numTokens;
- } else if ($commentStart === false
+ } elseif ($commentStart === false
|| $tokens[$commentStart]['code'] !== T_DOC_COMMENT_OPEN_TAG
) {
$phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing');
@@ -196,7 +196,7 @@ public function process(File $phpcsFile, int $stackPtr)
for ($i = ($commentStart + 1); $i < $commentEnd; $i++) {
if ($tokens[$i]['code'] === T_DOC_COMMENT_TAG) {
break;
- } else if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING
+ } elseif ($tokens[$i]['code'] === T_DOC_COMMENT_STRING
&& strstr(strtolower($tokens[$i]['content']), 'php version') !== false
) {
$found = true;
diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php
index f39eaa263b..b49d159f32 100644
--- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php
@@ -437,7 +437,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta
$phpcsFile->addError($error, $param['tag'], $code, $data);
}
- } else if (substr($param['var'], -4) !== ',...') {
+ } elseif (substr($param['var'], -4) !== ',...') {
// We must have an extra parameter comment.
$error = 'Superfluous parameter comment';
$phpcsFile->addError($error, $param['tag'], 'ExtraParamComment');
diff --git a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php
index ba19760ac9..20101018c7 100644
--- a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php
+++ b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php
@@ -52,11 +52,11 @@ public function process(File $phpcsFile, int $stackPtr)
$newComment = '// ' . $newComment;
$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
}
- } else if ($tokens[$stackPtr]['content'][0] === '/'
+ } elseif ($tokens[$stackPtr]['content'][0] === '/'
&& $tokens[$stackPtr]['content'][1] === '/'
) {
$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '// ...');
- } else if ($tokens[$stackPtr]['content'][0] === '/'
+ } elseif ($tokens[$stackPtr]['content'][0] === '/'
&& $tokens[$stackPtr]['content'][1] === '*'
) {
$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '/* ... */');
diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php
index 0b58d081cc..f46a86a3df 100644
--- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php
+++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php
@@ -232,9 +232,9 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[$openBrace]['line'] > $tokens[$closeBracket]['line']) {
$length = -1;
- } else if ($openBrace === ($closeBracket + 1)) {
+ } elseif ($openBrace === ($closeBracket + 1)) {
$length = 0;
- } else if ($openBrace === ($closeBracket + 2)
+ } elseif ($openBrace === ($closeBracket + 2)
&& $tokens[($closeBracket + 1)]['code'] === T_WHITESPACE
) {
$length = $tokens[($closeBracket + 1)]['length'];
diff --git a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php
index 93a03fa533..3c8d8a1f4f 100644
--- a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php
+++ b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php
@@ -103,7 +103,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->replaceToken($stackPtr, 'include_once');
}
- } else if ($tokenCode === T_REQUIRE) {
+ } elseif ($tokenCode === T_REQUIRE) {
$error = 'File is being conditionally included; ';
$error .= 'use "include" instead';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseInclude');
@@ -120,7 +120,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->replaceToken($stackPtr, 'require_once');
}
- } else if ($tokenCode === T_INCLUDE) {
+ } elseif ($tokenCode === T_INCLUDE) {
$error = 'File is being unconditionally included; ';
$error .= 'use "require" instead';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseRequire');
diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php
index 05be0e20d5..eaabb1be4e 100644
--- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php
+++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php
@@ -220,7 +220,7 @@ public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openB
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($openBracket + 1), '');
}
- } else if ($requiredSpacesAfterOpen > 0) {
+ } elseif ($requiredSpacesAfterOpen > 0) {
$spaceAfterOpen = 0;
if ($tokens[($openBracket + 1)]['code'] === T_WHITESPACE) {
$spaceAfterOpen = $tokens[($openBracket + 1)]['length'];
@@ -254,7 +254,7 @@ public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openB
if ($tokens[$prev]['line'] !== $tokens[$closer]['line']) {
$spaceBeforeClose = 'newline';
- } else if ($tokens[($closer - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($closer - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($closer - 1)]['length'];
}
@@ -270,7 +270,7 @@ public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openB
if ($spaceBeforeClose === 0) {
$phpcsFile->fixer->addContentBefore($closer, $padding);
- } else if ($spaceBeforeClose === 'newline') {
+ } elseif ($spaceBeforeClose === 'newline') {
$phpcsFile->fixer->beginChangeset();
$closingContent = ')';
@@ -385,7 +385,7 @@ public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBr
$padding = str_repeat(' ', $functionIndent);
if ($foundFunctionIndent === 0) {
$phpcsFile->fixer->addContentBefore($first, $padding);
- } else if ($tokens[$first]['code'] === T_INLINE_HTML) {
+ } elseif ($tokens[$first]['code'] === T_INLINE_HTML) {
$newContent = $padding . ltrim($tokens[$first]['content']);
$phpcsFile->fixer->replaceToken($first, $newContent);
} else {
diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
index ac041cfd0c..fd2c05b97b 100644
--- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
+++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
@@ -69,7 +69,7 @@ public function process(File $phpcsFile, int $stackPtr)
// Must be one space after the FUNCTION keyword.
if ($tokens[($stackPtr + 1)]['content'] === $phpcsFile->eolChar) {
$spaces = 'newline';
- } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
$spaces = $tokens[($stackPtr + 1)]['length'];
} else {
$spaces = 0;
@@ -100,7 +100,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($methodName !== '') {
if ($tokens[($openBracket - 1)]['content'] === $phpcsFile->eolChar) {
$spaces = 'newline';
- } else if ($tokens[($openBracket - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($openBracket - 1)]['code'] === T_WHITESPACE) {
$spaces = $tokens[($openBracket - 1)]['length'];
} else {
$spaces = 0;
@@ -121,7 +121,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($end !== false) {
if ($tokens[($end - 1)]['content'] === $phpcsFile->eolChar) {
$spaces = 'newline';
- } else if ($tokens[($end - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($end - 1)]['code'] === T_WHITESPACE) {
$spaces = $tokens[($end - 1)]['length'];
} else {
$spaces = 0;
@@ -146,7 +146,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($use !== false) {
if ($tokens[($use + 1)]['code'] !== T_WHITESPACE) {
$length = 0;
- } else if ($tokens[($use + 1)]['content'] === "\t") {
+ } elseif ($tokens[($use + 1)]['content'] === "\t") {
$length = '\t';
} else {
$length = $tokens[($use + 1)]['length'];
@@ -167,7 +167,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[($use - 1)]['code'] !== T_WHITESPACE) {
$length = 0;
- } else if ($tokens[($use - 1)]['content'] === "\t") {
+ } elseif ($tokens[($use - 1)]['content'] === "\t") {
$length = '\t';
} else {
$length = $tokens[($use - 1)]['length'];
@@ -469,9 +469,9 @@ public function processArgumentList(File $phpcsFile, int $stackPtr, int $indent,
// This is an empty line, so don't check the indent.
continue;
- } else if ($tokens[$i]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[$i]['code'] === T_WHITESPACE) {
$foundIndent = $tokens[$i]['length'];
- } else if ($tokens[$i]['code'] === T_DOC_COMMENT_WHITESPACE) {
+ } elseif ($tokens[$i]['code'] === T_DOC_COMMENT_WHITESPACE) {
$foundIndent = $tokens[$i]['length'];
++$expectedIndent;
}
diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
index f304dff1ef..808b83da4b 100644
--- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
+++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
@@ -83,7 +83,7 @@ public function process(File $phpcsFile, int $stackPtr)
$startColumn = 1;
if ($tokens[$lineStart]['code'] === T_WHITESPACE) {
$startColumn = $tokens[($lineStart + 1)]['column'];
- } else if ($tokens[$lineStart]['code'] === T_INLINE_HTML) {
+ } elseif ($tokens[$lineStart]['code'] === T_INLINE_HTML) {
$trimmed = ltrim($tokens[$lineStart]['content']);
if ($trimmed === '') {
$startColumn = $tokens[($lineStart + 1)]['column'];
@@ -130,7 +130,7 @@ public function process(File $phpcsFile, int $stackPtr)
$braceIndent = 0;
if ($tokens[$lineStart]['code'] === T_WHITESPACE) {
$braceIndent = ($tokens[($lineStart + 1)]['column'] - 1);
- } else if ($tokens[$lineStart]['code'] === T_INLINE_HTML) {
+ } elseif ($tokens[$lineStart]['code'] === T_INLINE_HTML) {
$trimmed = ltrim($tokens[$lineStart]['content']);
if ($trimmed === '') {
$braceIndent = ($tokens[($lineStart + 1)]['column'] - 1);
diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php
index 7804495bf6..5feb5a5bee 100644
--- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php
+++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php
@@ -211,7 +211,7 @@ private function searchForConflict(File $phpcsFile, int $start, int $end, array
$i = $tokens[$i]['scope_closer'];
continue;
- } else if (($tokens[$i]['code'] === T_STRING
+ } elseif (($tokens[$i]['code'] === T_STRING
|| $tokens[$i]['code'] === T_NAME_FULLY_QUALIFIED)
&& strtolower(ltrim($tokens[$i]['content'], '\\')) === 'define'
) {
diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php
index 31508b61af..b825475248 100644
--- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php
+++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php
@@ -171,7 +171,7 @@ public function processSingleLineArgumentList(File $phpcsFile, int $stackPtr)
if ($tokens[$prev]['line'] !== $tokens[$closeBracket]['line']) {
$spaceBeforeClose = 'newline';
- } else if ($tokens[($closeBracket - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($closeBracket - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($closeBracket - 1)]['length'];
}
diff --git a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php
index 86027d0617..15ed5d37c0 100644
--- a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php
+++ b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php
@@ -159,13 +159,13 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[$token]['type'] === 'T_OPEN_CURLY_BRACKET') {
// Block declaration.
$curlyBracket = $token;
- } else if ($tokens[$token]['type'] === 'T_SEMICOLON') {
+ } elseif ($tokens[$token]['type'] === 'T_SEMICOLON') {
$error = 'Expected no space between the closing parenthesis and the semicolon in a declare statement';
$fix = $phpcsFile->addFixableError($error, $parenthesis, 'SpaceFoundBeforeSemicolon');
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($parenthesis + 1), '');
}
- } else if ($tokens[$token]['type'] === 'T_CLOSE_TAG') {
+ } elseif ($tokens[$token]['type'] === 'T_CLOSE_TAG') {
if ($tokens[($parenthesis)]['line'] !== $tokens[$token]['line']) {
// Close tag must be on the same line..
$error = 'The close tag must be on the same line as the declare statement';
@@ -193,7 +193,7 @@ public function process(File $phpcsFile, int $stackPtr)
// The opening curly bracket must on the same line with a single space between closing bracket.
if ($tokens[$prevToken]['type'] !== 'T_CLOSE_PARENTHESIS') {
$phpcsFile->addError($error, $curlyBracket, 'ExtraSpaceFoundAfterBracket');
- } else if ($phpcsFile->getTokensAsString(($prevToken + 1), ($curlyBracket - $prevToken - 1)) !== ' ') {
+ } elseif ($phpcsFile->getTokensAsString(($prevToken + 1), ($curlyBracket - $prevToken - 1)) !== ' ') {
$fix = $phpcsFile->addFixableError($error, $curlyBracket, 'ExtraSpaceFoundAfterBracket');
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
diff --git a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php
index ac902b1b1a..33ad1b715c 100644
--- a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php
+++ b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php
@@ -88,7 +88,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
$openTag = $stackPtr;
- } else if (count($possibleHeaders) > 1) {
+ } elseif (count($possibleHeaders) > 1) {
// There are other PHP blocks before the file header.
$error = 'The file header must be the first content in the file';
$phpcsFile->addError($error, $openTag, 'HeaderPosition');
@@ -307,7 +307,7 @@ public function processHeaderLines(File $phpcsFile, array $headerLines)
if ($fix === true) {
if ($tokens[$next]['line'] === $tokens[$line['end']]['line']) {
$phpcsFile->fixer->addContentBefore($next, $phpcsFile->eolChar . $phpcsFile->eolChar);
- } else if ($tokens[$next]['line'] === ($tokens[$line['end']]['line'] + 1)) {
+ } elseif ($tokens[$next]['line'] === ($tokens[$line['end']]['line'] + 1)) {
$phpcsFile->fixer->addNewline($line['end']);
} else {
$phpcsFile->fixer->beginChangeset();
@@ -336,7 +336,7 @@ public function processHeaderLines(File $phpcsFile, array $headerLines)
];
$phpcsFile->addError($error, $headerLines[($i + 1)]['start'], 'IncorrectGrouping', $data);
}
- } else if ($headerLines[($i + 1)]['type'] === $line['type']) {
+ } elseif ($headerLines[($i + 1)]['type'] === $line['type']) {
// Still in the same block, so make sure there is no
// blank line after this statement.
$next = $phpcsFile->findNext(T_WHITESPACE, ($line['end'] + 1), null, true);
diff --git a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php
index 654b6d240c..b0c0bf9e05 100644
--- a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php
+++ b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php
@@ -75,7 +75,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($returnType - 1), ' ');
}
- } else if ($tokens[($returnType - 1)]['code'] === T_COLON) {
+ } elseif ($tokens[($returnType - 1)]['code'] === T_COLON) {
$fix = $phpcsFile->addFixableError($error, $returnType, 'SpaceBeforeReturnType');
if ($fix === true) {
$phpcsFile->fixer->addContentBefore($returnType, ' ');
diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php
index 84b37f0037..385c0078bb 100644
--- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php
+++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php
@@ -184,7 +184,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($useToken, ' ');
}
- } else if ($tokens[($useToken + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($useToken + 1)]['content'] !== ' ') {
$next = $phpcsFile->findNext(T_WHITESPACE, ($useToken + 1), null, true);
if ($tokens[$next]['line'] !== $tokens[$useToken]['line']) {
$found = 'newline';
@@ -253,7 +253,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->endChangeset();
}
}//end if
- } else if ($tokens[$next]['code'] !== T_USE) {
+ } elseif ($tokens[$next]['code'] !== T_USE) {
// Comments are allowed on the same line as the use statement, so make sure
// we don't error for those.
for ($next = ($end + 1); $next < $tokens[$ooToken]['scope_closer']; $next++) {
@@ -357,7 +357,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContentBefore($opener, ' ');
}
- } else if ($tokens[($opener - 1)]['content'] !== ' ') {
+ } elseif ($tokens[($opener - 1)]['content'] !== ' ') {
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($opener - 1), null, true);
if ($tokens[$prev]['line'] !== $tokens[$opener]['line']) {
$found = 'newline';
@@ -428,7 +428,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($i, ' ');
}
- } else if ($tokens[($i + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($i + 1)]['content'] !== ' ') {
$next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), $opener, true);
if ($tokens[$next]['line'] !== $tokens[$i]['line']) {
$found = 'newline';
@@ -463,7 +463,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContentBefore($i, ' ');
}
- } else if ($tokens[($i - 1)]['content'] !== ' ') {
+ } elseif ($tokens[($i - 1)]['content'] !== ' ') {
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), $opener, true);
if ($tokens[$prev]['line'] !== $tokens[$i]['line']) {
$found = 'newline';
@@ -501,7 +501,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($i, ' ');
}
- } else if ($tokens[($i + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($i + 1)]['content'] !== ' ') {
$next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), $closer, true);
if ($tokens[$next]['line'] !== $tokens[$i]['line']) {
$found = 'newline';
@@ -541,7 +541,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContentBefore($i, ' ');
}
- } else if ($tokens[($i - 1)]['content'] !== ' ') {
+ } elseif ($tokens[($i - 1)]['content'] !== ' ') {
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), $opener, true);
if ($tokens[$prev]['line'] !== $tokens[$i]['line']) {
$found = 'newline';
@@ -579,7 +579,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($i, ' ');
}
- } else if ($tokens[($i + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($i + 1)]['content'] !== ' ') {
$next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), $closer, true);
if ($tokens[$next]['line'] !== $tokens[$i]['line']) {
$found = 'newline';
diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php
index 67b641a10c..cc7ee685a5 100644
--- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php
+++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php
@@ -85,7 +85,7 @@ public function processOpen(File $phpcsFile, int $stackPtr)
if ($tokens[$prevNonEmpty]['line'] !== $tokens[$stackPtr]['line']) {
$spaces = 'newline';
$errorCode = 'NewlineBeforeKeyword';
- } else if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
$spaces = $tokens[($stackPtr - 1)]['length'];
}
@@ -153,7 +153,7 @@ public function processOpen(File $phpcsFile, int $stackPtr)
// Spacing of the keyword.
if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
$gap = 0;
- } else if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
+ } elseif ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
$gap = 'newline';
} else {
$gap = $tokens[($stackPtr + 1)]['length'];
@@ -290,7 +290,7 @@ public function processOpen(File $phpcsFile, int $stackPtr)
if ($className !== null) {
$start = $className;
- } else if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
+ } elseif (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
$start = $tokens[$stackPtr]['parenthesis_closer'];
} else {
$start = $stackPtr;
@@ -344,7 +344,7 @@ public function processOpen(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->addNewline($prev);
$phpcsFile->fixer->endChangeset();
}
- } else if ((isset(Tokens::COMMENT_TOKENS[$tokens[$prev]['code']]) === false
+ } elseif ((isset(Tokens::COMMENT_TOKENS[$tokens[$prev]['code']]) === false
&& $tokens[$prev]['line'] !== ($tokens[$className]['line'] - 1))
|| $tokens[$prev]['line'] === $tokens[$className]['line']
) {
diff --git a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php
index 1fd1bb5aca..9168fe4fce 100644
--- a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php
+++ b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php
@@ -91,7 +91,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($typeToken, ' ');
}
- } else if ($tokens[($typeToken + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($typeToken + 1)]['content'] !== ' ') {
$next = $phpcsFile->findNext(T_WHITESPACE, ($typeToken + 1), null, true);
if ($tokens[$next]['line'] !== $tokens[$typeToken]['line']) {
$found = 'newline';
diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php
index 06d218a74e..45c5a75858 100644
--- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php
+++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php
@@ -99,7 +99,7 @@ public function process(File $phpcsFile, int $stackPtr)
$padding = str_repeat(' ', $this->requiredSpacesAfterOpen);
if ($spaceAfterOpen === 0) {
$phpcsFile->fixer->addContent($parenOpener, $padding);
- } else if ($spaceAfterOpen === 'newline') {
+ } elseif ($spaceAfterOpen === 'newline') {
$phpcsFile->fixer->replaceToken(($parenOpener + 1), '');
} else {
$phpcsFile->fixer->replaceToken(($parenOpener + 1), $padding);
diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
index 364d3be6ed..03dd188ecb 100644
--- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
+++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
@@ -307,7 +307,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end)
}
return $this->findNestedTerminator($phpcsFile, ($scopeOpener + 1), $scopeCloser);
- } else if ($tokens[$prevToken]['code'] === T_ELSEIF
+ } elseif ($tokens[$prevToken]['code'] === T_ELSEIF
|| $tokens[$prevToken]['code'] === T_ELSE
) {
// If we find a terminating statement within this block,
@@ -321,7 +321,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end)
if ($tokens[$prevToken]['code'] === T_ELSE) {
$hasElseBlock = true;
}
- } else if ($tokens[$prevToken]['code'] === T_FINALLY) {
+ } elseif ($tokens[$prevToken]['code'] === T_FINALLY) {
// If we find a terminating statement within this block,
// the whole try/catch/finally statement is covered.
$hasTerminator = $this->findNestedTerminator($phpcsFile, ($scopeOpener + 1), $scopeCloser);
@@ -331,7 +331,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end)
// Otherwise, we continue with the previous TRY or CATCH clause.
$currentCloser = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($prevToken - 1), $stackPtr, true);
- } else if ($tokens[$prevToken]['code'] === T_TRY) {
+ } elseif ($tokens[$prevToken]['code'] === T_TRY) {
// If we've seen CATCH blocks without terminator statement and
// have not seen a FINALLY *with* a terminator statement, we
// don't even need to bother checking the TRY.
@@ -340,7 +340,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end)
}
return $this->findNestedTerminator($phpcsFile, ($scopeOpener + 1), $scopeCloser);
- } else if ($tokens[$prevToken]['code'] === T_CATCH) {
+ } elseif ($tokens[$prevToken]['code'] === T_CATCH) {
// Keep track of seen catch statements without terminating statement,
// but don't bow out yet as there may still be a FINALLY clause
// with a terminating statement before the CATCH.
@@ -350,7 +350,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end)
}
$currentCloser = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($prevToken - 1), $stackPtr, true);
- } else if ($tokens[$prevToken]['code'] === T_SWITCH) {
+ } elseif ($tokens[$prevToken]['code'] === T_SWITCH) {
$hasDefaultBlock = false;
$endOfSwitch = $tokens[$prevToken]['scope_closer'];
$nextCase = $prevToken;
@@ -393,7 +393,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end)
} while ($currentCloser !== false && $tokens[$currentCloser]['code'] === T_CLOSE_CURLY_BRACKET);
return true;
- } else if ($tokens[$lastToken]['code'] === T_SEMICOLON) {
+ } elseif ($tokens[$lastToken]['code'] === T_SEMICOLON) {
// We found the last statement of the CASE. Now we want to
// check whether it is a terminating one.
$terminator = $phpcsFile->findStartOfStatement(($lastToken - 1));
diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php
index cd684ff53a..fe8d988a25 100644
--- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php
+++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php
@@ -348,7 +348,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array
if ($fix === true) {
$phpcsFile->fixer->addNewlineBefore($arrayEnd);
}
- } else if ($tokens[$arrayEnd]['column'] !== $keywordStart) {
+ } elseif ($tokens[$arrayEnd]['column'] !== $keywordStart) {
// Check the closing bracket is lined up under the "a" in array.
$expected = ($keywordStart - 1);
$found = ($tokens[$arrayEnd]['column'] - 1);
@@ -410,7 +410,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array
if ($tokens[$nextToken]['code'] === T_ARRAY) {
$nextToken = $tokens[$tokens[$nextToken]['parenthesis_opener']]['parenthesis_closer'];
- } else if ($tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY) {
+ } elseif ($tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY) {
$nextToken = $tokens[$nextToken]['bracket_closer'];
} else {
// T_CLOSURE.
@@ -568,7 +568,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array
if (empty($indices) === true) {
$singleValue = true;
- } else if (count($indices) === 1 && $tokens[$lastToken]['code'] === T_COMMA) {
+ } elseif (count($indices) === 1 && $tokens[$lastToken]['code'] === T_COMMA) {
// There may be another array value without a comma.
$exclude = Tokens::EMPTY_TOKENS;
$exclude[] = T_COMMA;
@@ -701,7 +701,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array
$phpcsFile->fixer->addNewlineBefore($valuePointer);
}
}
- } else if ($previousIsWhitespace === true) {
+ } elseif ($previousIsWhitespace === true) {
$expected = $keywordStart;
$first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $valuePointer, true);
@@ -882,7 +882,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array
$phpcsFile->fixer->replaceToken(($valuePointer - 1), str_repeat(' ', $expected));
$phpcsFile->fixer->endChangeset();
- } else if ($found === 0) {
+ } elseif ($found === 0) {
$phpcsFile->fixer->addContent(($valuePointer - 1), str_repeat(' ', $expected));
} else {
$phpcsFile->fixer->replaceToken(($valuePointer - 1), str_repeat(' ', $expected));
@@ -897,7 +897,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array
$end = $phpcsFile->findEndOfStatement($valueStart);
if ($end === false) {
$valueEnd = $valueStart;
- } else if ($tokens[$end]['code'] === T_COMMA) {
+ } elseif ($tokens[$end]['code'] === T_COMMA) {
$valueEnd = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($end - 1), $valueStart, true);
$nextComma = $end;
} else {
diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php
index 8a0e0b987c..0a44fd4188 100644
--- a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php
+++ b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php
@@ -145,7 +145,7 @@ public function processClose(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->addNewlineBefore($closeBrace);
}
}
- } else if ($tokens[($closeBrace - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($closeBrace - 1)]['code'] === T_WHITESPACE) {
$prevContent = $tokens[($closeBrace - 1)]['content'];
if ($prevContent !== $phpcsFile->eolChar) {
$blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar));
@@ -206,7 +206,7 @@ public function processClose(File $phpcsFile, int $stackPtr)
for ($i = ($closeBrace + 1); $i < $nextContent; $i++) {
if ($tokens[$i]['line'] <= ($tokens[$closeBrace]['line'] + 1)) {
continue;
- } else if ($tokens[$i]['line'] === $tokens[$nextContent]['line']) {
+ } elseif ($tokens[$i]['line'] === $tokens[$nextContent]['line']) {
break;
}
diff --git a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php
index 5ada4cf0c2..817b576048 100644
--- a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php
+++ b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php
@@ -75,7 +75,7 @@ protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $
return;
}
- } else if (isset(Tokens::NAME_TOKENS[$tokens[$calledClassName]['code']]) === true) {
+ } elseif (isset(Tokens::NAME_TOKENS[$tokens[$calledClassName]['code']]) === true) {
// Work out the fully qualified name for both the class declaration
// as well as the class usage to see if they match.
$namespaceName = $this->getNamespaceName($phpcsFile, $currScope);
diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php
index cbb2192e68..3845c035f9 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php
@@ -73,11 +73,11 @@ public function process(File $phpcsFile, int $stackPtr)
}
$comment = '//end ' . $decName . '()';
- } else if ($tokens[$stackPtr]['code'] === T_CLASS) {
+ } elseif ($tokens[$stackPtr]['code'] === T_CLASS) {
$comment = '//end class';
- } else if ($tokens[$stackPtr]['code'] === T_INTERFACE) {
+ } elseif ($tokens[$stackPtr]['code'] === T_INTERFACE) {
$comment = '//end interface';
- } else if ($tokens[$stackPtr]['code'] === T_TRAIT) {
+ } elseif ($tokens[$stackPtr]['code'] === T_TRAIT) {
$comment = '//end trait';
} else {
$comment = '//end enum';
diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php
index 5811dbe77d..e3ee875344 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php
@@ -129,7 +129,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($i, ' ');
}
- } else if ($tokens[($i + 2)]['code'] === T_DOC_COMMENT_TAG
+ } elseif ($tokens[($i + 2)]['code'] === T_DOC_COMMENT_TAG
&& $tokens[($i + 1)]['content'] !== ' '
) {
$error = 'Expected 1 space after asterisk; %s found';
diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php
index 933c04aaad..bc678866b2 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php
@@ -58,7 +58,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->addError('You must use "/**" style comments for a file comment', $commentStart, 'WrongStyle');
$phpcsFile->recordMetric($stackPtr, 'File has doc comment', 'yes');
return $phpcsFile->numTokens;
- } else if ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT_OPEN_TAG) {
+ } elseif ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT_OPEN_TAG) {
$phpcsFile->addError('Missing file doc comment', $stackPtr, 'Missing');
$phpcsFile->recordMetric($stackPtr, 'File has doc comment', 'no');
return $phpcsFile->numTokens;
@@ -169,7 +169,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->replaceToken($string, $expected);
}
}
- } else if ($name === '@copyright') {
+ } elseif ($name === '@copyright') {
if (preg_match('/^([0-9]{4})(-[0-9]{4})? (Squiz Pty Ltd \(ABN 77 084 670 600\))$/', $tokens[$string]['content']) === 0) {
$error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration';
$fix = $phpcsFile->addFixableError($error, $tag, 'IncorrectCopyright');
diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
index 124e9b8f3b..c00e60ebae 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
@@ -143,7 +143,7 @@ protected function processReturn(File $phpcsFile, int $stackPtr, int $commentSta
}
}
}//end if
- } else if ($returnType !== 'mixed'
+ } elseif ($returnType !== 'mixed'
&& $returnType !== 'never'
&& in_array('void', $typeNames, true) === false
) {
@@ -231,7 +231,7 @@ protected function processThrows(File $phpcsFile, int $stackPtr, int $commentSta
if ($exception === null) {
$error = 'Exception type and comment missing for @throws tag in function comment';
$phpcsFile->addError($error, $tag, 'InvalidThrows');
- } else if ($comment === null) {
+ } elseif ($comment === null) {
$error = 'Comment missing for @throws tag in function comment';
$phpcsFile->addError($error, $tag, 'EmptyThrows');
} else {
@@ -326,7 +326,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta
if ($tokens[($tag + 2)]['content'][0] === '$') {
$error = 'Missing parameter type';
$phpcsFile->addError($error, $tag, 'MissingParamType');
- } else if (isset($matches[2]) === true) {
+ } elseif (isset($matches[2]) === true) {
$var = $matches[2];
$varLen = strlen($var);
if ($varLen > $maxVar) {
@@ -431,22 +431,22 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta
$suggestedTypeHint = '';
if (strpos($suggestedName, 'array') !== false || substr($suggestedName, -2) === '[]') {
$suggestedTypeHint = 'array';
- } else if (strpos($suggestedName, 'callable') !== false) {
+ } elseif (strpos($suggestedName, 'callable') !== false) {
$suggestedTypeHint = 'callable';
- } else if (strpos($suggestedName, 'callback') !== false) {
+ } elseif (strpos($suggestedName, 'callback') !== false) {
$suggestedTypeHint = 'callable';
- } else if (isset(Common::ALLOWED_TYPES[$suggestedName]) === false) {
+ } elseif (isset(Common::ALLOWED_TYPES[$suggestedName]) === false) {
$suggestedTypeHint = $suggestedName;
}
if ($this->phpVersion >= 70000) {
if ($suggestedName === 'string') {
$suggestedTypeHint = 'string';
- } else if ($suggestedName === 'int' || $suggestedName === 'integer') {
+ } elseif ($suggestedName === 'int' || $suggestedName === 'integer') {
$suggestedTypeHint = 'int';
- } else if ($suggestedName === 'float') {
+ } elseif ($suggestedName === 'float') {
$suggestedTypeHint = 'float';
- } else if ($suggestedName === 'bool' || $suggestedName === 'boolean') {
+ } elseif ($suggestedName === 'bool' || $suggestedName === 'boolean') {
$suggestedTypeHint = 'bool';
}
}
@@ -486,7 +486,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta
}
$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
- } else if ($typeHint !== $compareTypeHint && $typeHint !== '?' . $compareTypeHint) {
+ } elseif ($typeHint !== $compareTypeHint && $typeHint !== '?' . $compareTypeHint) {
$error = 'Expected type hint "%s"; found "%s" for %s';
$data = [
$suggestedTypeHint,
@@ -495,7 +495,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta
];
$phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data);
}//end if
- } else if ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) {
+ } elseif ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) {
$typeHint = $realParams[$pos]['type_hint'];
if ($typeHint !== '') {
$error = 'Unknown type hint "%s" found for %s';
@@ -601,7 +601,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta
$phpcsFile->addError($error, $param['tag'], $code, $data);
}//end if
- } else if (substr($param['var'], -4) !== ',...') {
+ } elseif (substr($param['var'], -4) !== ',...') {
// We must have an extra parameter comment.
$error = 'Superfluous parameter comment';
$phpcsFile->addError($error, $param['tag'], 'ExtraParamComment');
diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php
index 10fb86200f..d934631b23 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php
@@ -130,7 +130,7 @@ public function process(File $phpcsFile, int $stackPtr)
$thrownExceptions[] = $tokens[$currException]['content'];
}
}
- } else if ($tokens[$nextToken]['code'] === T_VARIABLE) {
+ } elseif ($tokens[$nextToken]['code'] === T_VARIABLE) {
// Find the nearest catch block in this scope and, if the caught var
// matches our re-thrown var, use the exception types being caught as
// exception types that are being thrown as well.
@@ -191,7 +191,7 @@ public function process(File $phpcsFile, int $stackPtr)
$error = 'Missing @throws tag in function comment';
$phpcsFile->addError($error, $commentEnd, 'Missing');
return;
- } else if (empty($thrownExceptions) === true) {
+ } elseif (empty($thrownExceptions) === true) {
// If token count is zero, it means that only variables are being
// thrown, so we need at least one @throws tag (checked above).
// Nothing more to do.
diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php
index ddad4cc72d..2438646ce5 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php
@@ -195,14 +195,14 @@ public function process(File $phpcsFile, int $stackPtr)
$comment,
];
$fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'TabBefore', $data);
- } else if ($spaceCount === 0) {
+ } elseif ($spaceCount === 0) {
$error = 'No space found before comment text; expected "// %s" but found "%s"';
$data = [
substr($comment, 2),
$comment,
];
$fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'NoSpaceBefore', $data);
- } else if ($spaceCount > 1) {
+ } elseif ($spaceCount > 1) {
$error = 'Expected 1 space before comment text but found %s; use block comment if you need indentation';
$data = [
$spaceCount,
@@ -287,7 +287,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[$i]['code'] !== T_WHITESPACE) {
return ($lastCommentToken + 1);
}
- } else if ($tokens[$i]['line'] > ($tokens[$lastCommentToken]['line'] + 1)) {
+ } elseif ($tokens[$i]['line'] > ($tokens[$lastCommentToken]['line'] + 1)) {
break;
}
}
diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php
index 5066e09e0a..047e9d582e 100644
--- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php
+++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php
@@ -102,7 +102,7 @@ public function processMemberVar(File $phpcsFile, int $stackPtr)
} else {
$foundVar = $tag;
}
- } else if ($tokens[$tag]['content'] === '@see') {
+ } elseif ($tokens[$tag]['content'] === '@see') {
// Make sure the tag isn't empty.
$string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php
index 41df9361d5..bfa1d1952a 100644
--- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php
+++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php
@@ -86,7 +86,7 @@ public function process(File $phpcsFile, int $stackPtr)
$found = 1;
if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
$found = 0;
- } else if ($tokens[($stackPtr + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($stackPtr + 1)]['content'] !== ' ') {
if (strpos($tokens[($stackPtr + 1)]['content'], $phpcsFile->eolChar) !== false) {
$found = 'newline';
} else {
@@ -232,7 +232,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->endChangeset();
}
}//end if
- } else if ($tokens[$stackPtr]['code'] === T_WHILE) {
+ } elseif ($tokens[$stackPtr]['code'] === T_WHILE) {
// Zero spaces after parenthesis closer, but only if followed by a semicolon.
$closer = $tokens[$stackPtr]['parenthesis_closer'];
$nextNonEmpty = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($closer + 1), null, true);
@@ -270,7 +270,7 @@ public function process(File $phpcsFile, int $stackPtr)
) {
return;
}
- } else if ($tokens[$stackPtr]['code'] === T_ELSE
+ } elseif ($tokens[$stackPtr]['code'] === T_ELSE
|| $tokens[$stackPtr]['code'] === T_ELSEIF
|| $tokens[$stackPtr]['code'] === T_CATCH
|| $tokens[$stackPtr]['code'] === T_FINALLY
@@ -295,9 +295,9 @@ public function process(File $phpcsFile, int $stackPtr)
$found = 1;
if ($tokens[($closer + 1)]['code'] !== T_WHITESPACE) {
$found = 0;
- } else if ($tokens[$closer]['line'] !== $tokens[$stackPtr]['line']) {
+ } elseif ($tokens[$closer]['line'] !== $tokens[$stackPtr]['line']) {
$found = 'newline';
- } else if ($tokens[($closer + 1)]['content'] !== ' ') {
+ } elseif ($tokens[($closer + 1)]['content'] !== ' ') {
$found = $tokens[($closer + 1)]['length'];
}
diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php
index 49328ca064..07fbba7ef9 100644
--- a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php
+++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php
@@ -76,7 +76,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($openingBracket + 1), '');
}
- } else if ($this->requiredSpacesAfterOpen > 0) {
+ } elseif ($this->requiredSpacesAfterOpen > 0) {
$spaceAfterOpen = 0;
if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) {
$spaceAfterOpen = $tokens[($openingBracket + 1)]['length'];
@@ -106,7 +106,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($closingBracket - 1), '');
}
- } else if ($this->requiredSpacesBeforeClose > 0) {
+ } elseif ($this->requiredSpacesBeforeClose > 0) {
$spaceBeforeClose = 0;
if ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($closingBracket - 1)]['length'];
diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php
index 16fc0053e2..e287d6bd3c 100644
--- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php
+++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php
@@ -95,12 +95,12 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->endChangeset();
}
}
- } else if ($this->requiredSpacesAfterOpen > 0) {
+ } elseif ($this->requiredSpacesAfterOpen > 0) {
$nextNonWhiteSpace = $phpcsFile->findNext(T_WHITESPACE, ($openingBracket + 1), $closingBracket, true);
$spaceAfterOpen = 0;
if ($tokens[$openingBracket]['line'] !== $tokens[$nextNonWhiteSpace]['line']) {
$spaceAfterOpen = 'newline';
- } else if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) {
$spaceAfterOpen = $tokens[($openingBracket + 1)]['length'];
}
@@ -163,11 +163,11 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->endChangeset();
}
}
- } else if ($this->requiredSpacesBeforeClose > 0) {
+ } elseif ($this->requiredSpacesBeforeClose > 0) {
$spaceBeforeClose = 0;
if ($tokens[$closingBracket]['line'] !== $tokens[$prevNonWhiteSpace]['line']) {
$spaceBeforeClose = 'newline';
- } else if ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($closingBracket - 1)]['length'];
}
@@ -269,7 +269,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addContent($semicolon, ' ');
}
- } else if ($tokens[($semicolon + 1)]['code'] === T_WHITESPACE
+ } elseif ($tokens[($semicolon + 1)]['code'] === T_WHITESPACE
&& $tokens[$nextNonWhiteSpace]['code'] !== T_SEMICOLON
) {
$spaces = $tokens[($semicolon + 1)]['length'];
diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
index 8bcdf50bcf..eeac81c14f 100644
--- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
+++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
@@ -267,7 +267,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
}//end if
}//end if
- } else if ($type === 'Default') {
+ } elseif ($type === 'Default') {
$error = 'DEFAULT case must have a breaking statement';
$phpcsFile->addError($error, $nextCase, 'DefaultNoBreak');
}//end if
diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php
index 9f0fe171a9..ece0d5b823 100644
--- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php
+++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php
@@ -212,7 +212,7 @@ public function process(File $phpcsFile, int $stackPtr)
// It is not in a bracketed statement at all.
$this->addMissingBracketsError($phpcsFile, $stackPtr);
return;
- } else if ($tokens[$lastBracket]['parenthesis_closer'] < $stackPtr) {
+ } elseif ($tokens[$lastBracket]['parenthesis_closer'] < $stackPtr) {
// There are a set of brackets in front of it that don't include it.
$this->addMissingBracketsError($phpcsFile, $stackPtr);
return;
diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php
index 7d3444baff..ba1fa6875b 100644
--- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php
+++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php
@@ -198,7 +198,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
$spacesBefore = 0;
if ($tokens[$param['token']]['line'] !== $tokens[$equalToken]['line']) {
$spacesBefore = 'newline';
- } else if ($tokens[($param['token'] + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($param['token'] + 1)]['code'] === T_WHITESPACE) {
$spacesBefore = $tokens[($param['token'] + 1)]['length'];
}
@@ -232,7 +232,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
$spacesAfter = 0;
if ($tokens[$equalToken]['line'] !== $tokens[$param['default_token']]['line']) {
$spacesAfter = 'newline';
- } else if ($tokens[($equalToken + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($equalToken + 1)]['code'] === T_WHITESPACE) {
$spacesAfter = $tokens[($equalToken + 1)]['length'];
}
@@ -309,7 +309,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
&& $tokens[$visibilityToken]['line'] !== $tokens[$afterVisibilityToken]['line']
) {
$spacesAfter = 'newline';
- } else if ($tokens[($visibilityToken + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($visibilityToken + 1)]['code'] === T_WHITESPACE) {
$spacesAfter = $tokens[($visibilityToken + 1)]['length'];
}
@@ -343,7 +343,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
&& $tokens[$visibilityToken]['line'] !== $tokens[$afterVisibilityToken]['line']
) {
$spacesAfter = 'newline';
- } else if ($tokens[($visibilityToken + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($visibilityToken + 1)]['code'] === T_WHITESPACE) {
$spacesAfter = $tokens[($visibilityToken + 1)]['length'];
}
@@ -377,7 +377,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
&& $tokens[$readonlyToken]['line'] !== $tokens[$afterReadonlyToken]['line']
) {
$spacesAfter = 'newline';
- } else if ($tokens[($readonlyToken + 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($readonlyToken + 1)]['code'] === T_WHITESPACE) {
$spacesAfter = $tokens[($readonlyToken + 1)]['length'];
}
@@ -410,7 +410,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
$spaceBeforeComma = 0;
if ($tokens[$endOfPreviousParam]['line'] !== $tokens[$commaToken]['line']) {
$spaceBeforeComma = 'newline';
- } else if ($tokens[($commaToken - 1)]['code'] === T_WHITESPACE) {
+ } elseif ($tokens[($commaToken - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeComma = $tokens[($commaToken - 1)]['length'];
}
@@ -472,7 +472,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
$typeOfNextShort = 'PropertyModifier';
$modifier = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($commaToken + 1), $param['token'], true);
$contentOfNext = $tokens[$modifier]['content'];
- } else if ($param['type_hint_token'] !== false) {
+ } elseif ($param['type_hint_token'] !== false) {
$typeOfNext = 'type hint';
$typeOfNextShort = 'Hint';
$contentOfNext = $param['type_hint'];
@@ -495,7 +495,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
if ($fix === true) {
$phpcsFile->fixer->addContent($commaToken, ' ');
}
- } else if ($spacesAfter !== 1) {
+ } elseif ($spacesAfter !== 1) {
$error = 'Expected 1 space between comma and %s "%s"; %s found';
$errorCode = 'SpacingBefore' . $typeOfNextShort;
$data = [
diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php
index 1539f1f143..21d2c41a77 100644
--- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php
+++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php
@@ -84,22 +84,22 @@ public function process(File $phpcsFile, int $stackPtr)
// Stop here as we assume it is the end
// of the previous statement.
break;
- } else if ($tokens[$i]['code'] === T_OPEN_TAG) {
+ } elseif ($tokens[$i]['code'] === T_OPEN_TAG) {
// Stop here as this is the start of the file.
break;
- } else if ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET) {
+ } elseif ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET) {
// Stop if this is the closing brace of
// a code block.
if (isset($tokens[$i]['scope_opener']) === true) {
break;
}
- } else if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) {
+ } elseif ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) {
// Stop if this is the opening brace of
// a code block.
if (isset($tokens[$i]['scope_closer']) === true) {
break;
}
- } else if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
+ } elseif ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
// Stop if this is the start of a pair of
// parentheses that surrounds the inline
// IF statement.
@@ -119,7 +119,7 @@ public function process(File $phpcsFile, int $stackPtr)
$start = $tokens[$end]['parenthesis_opener'];
}//end if
- } else if ($tokens[$stackPtr]['code'] === T_FOR) {
+ } elseif ($tokens[$stackPtr]['code'] === T_FOR) {
if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
return;
}
@@ -157,7 +157,7 @@ public function process(File $phpcsFile, int $stackPtr)
];
$phpcsFile->addError($error, $i, 'NotAllowed', $data);
$foundOps++;
- } else if (isset(self::VALID_OPERATIONS[$type]) === true) {
+ } elseif (isset(self::VALID_OPERATIONS[$type]) === true) {
$foundOps++;
}
diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
index 39a14d8d6d..ce220a09cc 100644
--- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
+++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
@@ -196,7 +196,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c
for ($first = ($lastContentBeforeBlock - 1); $first > 0; $first--) {
if ($tokens[$first]['line'] === $tokens[$stackPtr]['line']) {
continue;
- } else if (trim($tokens[$first]['content']) !== '') {
+ } elseif (trim($tokens[$first]['content']) !== '') {
$first = $phpcsFile->findFirstOnLine([], $first, true);
break;
}
@@ -251,7 +251,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c
$phpcsFile->fixer->addNewlineBefore($closingTag);
$phpcsFile->fixer->endChangeset();
}//end if
- } else if ($firstContentAfterBlock !== false
+ } elseif ($firstContentAfterBlock !== false
&& $tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']
) {
$error = 'Closing PHP tag must be on a line by itself';
@@ -385,7 +385,7 @@ private function validateInlineEmbeddedPhp(File $phpcsFile, int $stackPtr, int $
if ($fix === true) {
$phpcsFile->fixer->addContent($prev, ';');
}
- } else if ($tokens[$prev]['code'] === T_SEMICOLON) {
+ } elseif ($tokens[$prev]['code'] === T_SEMICOLON) {
$statementCount = 1;
for ($i = ($stackPtr + 1); $i < $prev; $i++) {
if ($tokens[$i]['code'] === T_SEMICOLON) {
@@ -404,7 +404,7 @@ private function validateInlineEmbeddedPhp(File $phpcsFile, int $stackPtr, int $
$trailingSpace = 0;
if ($tokens[($closeTag - 1)]['code'] === T_WHITESPACE) {
$trailingSpace = $tokens[($closeTag - 1)]['length'];
- } else if (($tokens[($closeTag - 1)]['code'] === T_COMMENT
+ } elseif (($tokens[($closeTag - 1)]['code'] === T_COMMENT
|| isset(Tokens::PHPCS_ANNOTATION_TOKENS[$tokens[($closeTag - 1)]['code']]) === true)
&& substr($tokens[($closeTag - 1)]['content'], -1) === ' '
) {
@@ -418,7 +418,7 @@ private function validateInlineEmbeddedPhp(File $phpcsFile, int $stackPtr, int $
if ($fix === true) {
if ($trailingSpace === 0) {
$phpcsFile->fixer->addContentBefore($closeTag, ' ');
- } else if ($tokens[($closeTag - 1)]['code'] === T_COMMENT
+ } elseif ($tokens[($closeTag - 1)]['code'] === T_COMMENT
|| isset(Tokens::PHPCS_ANNOTATION_TOKENS[$tokens[($closeTag - 1)]['code']]) === true
) {
$phpcsFile->fixer->replaceToken(($closeTag - 1), rtrim($tokens[($closeTag - 1)]['content']) . ' ');
@@ -496,12 +496,12 @@ private function calculateLineIndent(File $phpcsFile, int $stackPtr)
$indent = 0;
if ($tokens[$firstOnLine]['code'] === T_WHITESPACE) {
$indent = ($tokens[($firstOnLine + 1)]['column'] - 1);
- } else if ($tokens[$firstOnLine]['code'] === T_INLINE_HTML
+ } elseif ($tokens[$firstOnLine]['code'] === T_INLINE_HTML
|| $tokens[$firstOnLine]['code'] === T_END_HEREDOC
|| $tokens[$firstOnLine]['code'] === T_END_NOWDOC
) {
$indent = (strlen($tokens[$firstOnLine]['content']) - strlen(ltrim($tokens[$firstOnLine]['content'])));
- } else if ($tokens[$firstOnLine]['code'] === T_DOC_COMMENT_WHITESPACE) {
+ } elseif ($tokens[$firstOnLine]['code'] === T_DOC_COMMENT_WHITESPACE) {
$indent = (strlen($tokens[$firstOnLine]['content']) - strlen(ltrim($tokens[$firstOnLine]['content'])) - 1);
}
diff --git a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php
index 2aeb687940..e4b65eb920 100644
--- a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php
+++ b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php
@@ -135,7 +135,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
$phpcsFile->fixer->endChangeset();
- } else if ($this->spacing > 0) {
+ } elseif ($this->spacing > 0) {
$phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
}
}
@@ -152,7 +152,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
$phpcsFile->fixer->endChangeset();
- } else if ($this->spacing > 0) {
+ } elseif ($this->spacing > 0) {
$phpcsFile->fixer->addContent($stackPtr, $padding);
}
}
diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
index 1eaf278f27..c7e7fdec12 100644
--- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
+++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
@@ -316,7 +316,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->endChangeset();
}
}
- } else if ($tokens[$trailingContent]['code'] !== T_ELSE
+ } elseif ($tokens[$trailingContent]['code'] !== T_ELSE
&& $tokens[$trailingContent]['code'] !== T_ELSEIF
&& $tokens[$trailingContent]['code'] !== T_CATCH
&& $tokens[$trailingContent]['code'] !== T_FINALLY
diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php
index 4cca5e03c2..6f851c988c 100644
--- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php
+++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php
@@ -70,7 +70,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($fix === true) {
$phpcsFile->fixer->addNewlineBefore($closeBrace);
}
- } else if ($found > 0) {
+ } elseif ($found > 0) {
$error = 'Expected 0 blank lines before closing brace of nested function; %s found';
$data = [$found];
$fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeNestedClose', $data);
diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
index 6aebe71a73..3fbb8a5911 100644
--- a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
+++ b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
@@ -98,7 +98,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr)
if ($tokens[$prev]['code'] === T_DOC_COMMENT_CLOSE_TAG) {
$start = $prev;
- } else if (isset(Tokens::COMMENT_TOKENS[$tokens[$prev]['code']]) === true) {
+ } elseif (isset(Tokens::COMMENT_TOKENS[$tokens[$prev]['code']]) === true) {
// Assume the comment belongs to the member var if it is on a line by itself.
$prevContent = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($prev - 1), null, true);
if ($tokens[$prevContent]['line'] !== $tokens[$prev]['line']) {
@@ -154,7 +154,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr)
if ($first === false) {
$first = $start;
}
- } else if ($tokens[$start]['code'] === T_DOC_COMMENT_CLOSE_TAG) {
+ } elseif ($tokens[$start]['code'] === T_DOC_COMMENT_CLOSE_TAG) {
$first = $tokens[$start]['comment_opener'];
} else {
$first = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($start - 1), null, true);
diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
index 8abe1b98f0..374cc36f1d 100644
--- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
+++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
@@ -223,7 +223,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
$phpcsFile->recordMetric($stackPtr, 'Space before operator', 0);
- } else if (isset(Tokens::ASSIGNMENT_TOKENS[$tokens[$stackPtr]['code']]) === false
+ } elseif (isset(Tokens::ASSIGNMENT_TOKENS[$tokens[$stackPtr]['code']]) === false
|| $this->ignoreSpacingBeforeAssignments === false
) {
// Throw an error for assignments only if enabled using the sniff property
diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
index 76582095e5..89dadac873 100644
--- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
+++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
@@ -97,7 +97,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->endChangeset();
}
- } else if ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) {
+ } elseif ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) {
/*
Check for end of file whitespace.
*/
@@ -161,7 +161,7 @@ public function process(File $phpcsFile, int $stackPtr)
$phpcsFile->fixer->replaceToken($stackPtr, rtrim($tokenContent) . $phpcsFile->eolChar);
}
}
- } else if ($tokens[($stackPtr - 1)]['content'] !== rtrim($tokens[($stackPtr - 1)]['content'])
+ } elseif ($tokens[($stackPtr - 1)]['content'] !== rtrim($tokens[($stackPtr - 1)]['content'])
&& $tokens[($stackPtr - 1)]['line'] === $tokens[$stackPtr]['line']
) {
$fix = $phpcsFile->addFixableError('Whitespace found at end of line', ($stackPtr - 1), 'EndLine');
diff --git a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php
index 2bd4d40eec..9d49504102 100644
--- a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php
+++ b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php
@@ -63,7 +63,7 @@ protected function processVariable(File $phpcsFile, int $stackPtr)
$error = 'Variable "%s" is not in valid camel caps format';
$data = [$originalVarName];
$phpcsFile->addError($error, $var, 'NotCamelCaps', $data);
- } else if (preg_match('|\d|', $objVarName) === 1) {
+ } elseif (preg_match('|\d|', $objVarName) === 1) {
$warning = 'Variable "%s" contains numbers but this is discouraged';
$data = [$originalVarName];
$phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data);
@@ -95,7 +95,7 @@ protected function processVariable(File $phpcsFile, int $stackPtr)
$error = 'Variable "%s" is not in valid camel caps format';
$data = [$originalVarName];
$phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data);
- } else if (preg_match('|\d|', $varName) === 1) {
+ } elseif (preg_match('|\d|', $varName) === 1) {
$warning = 'Variable "%s" contains numbers but this is discouraged';
$data = [$originalVarName];
$phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data);
@@ -151,7 +151,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr)
$error = 'Member variable "%s" is not in valid camel caps format';
$data = [$varName];
$phpcsFile->addError($error, $stackPtr, 'MemberVarNotCamelCaps', $data);
- } else if (preg_match('|\d|', $varName) === 1) {
+ } elseif (preg_match('|\d|', $varName) === 1) {
$warning = 'Member variable "%s" contains numbers but this is discouraged';
$data = [$varName];
$phpcsFile->addWarning($warning, $stackPtr, 'MemberVarContainsNumbers', $data);
@@ -184,7 +184,7 @@ protected function processVariableInString(File $phpcsFile, int $stackPtr)
$error = 'Variable "%s" is not in valid camel caps format';
$data = [$varName];
$phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data);
- } else if (preg_match('|\d|', $varName) === 1) {
+ } elseif (preg_match('|\d|', $varName) === 1) {
$warning = 'Variable "%s" contains numbers but this is discouraged';
$data = [$varName];
$phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data);
diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php
index e3587c8b71..cf0ac9c996 100644
--- a/src/Tokenizers/PHP.php
+++ b/src/Tokenizers/PHP.php
@@ -938,10 +938,10 @@ protected function tokenize(string $code)
if (strpos($nextToken[1], "\r\n") === 0) {
$token[1] .= "\r\n";
$tokens[($stackPtr + 1)][1] = substr($nextToken[1], 2);
- } else if (strpos($nextToken[1], "\n\r") === 0) {
+ } elseif (strpos($nextToken[1], "\n\r") === 0) {
$token[1] .= "\n\r";
$tokens[($stackPtr + 1)][1] = substr($nextToken[1], 2);
- } else if (strpos($nextToken[1], "\n") === 0) {
+ } elseif (strpos($nextToken[1], "\n") === 0) {
$token[1] .= "\n";
$tokens[($stackPtr + 1)][1] = substr($nextToken[1], 1);
}
@@ -1334,7 +1334,7 @@ protected function tokenize(string $code)
$oldCode = 'T_PUBLIC';
$newToken['code'] = T_PUBLIC_SET;
$newToken['type'] = 'T_PUBLIC_SET';
- } else if ($token[0] === T_PROTECTED) {
+ } elseif ($token[0] === T_PROTECTED) {
$oldCode = 'T_PROTECTED';
$newToken['code'] = T_PROTECTED_SET;
$newToken['type'] = 'T_PROTECTED_SET';
@@ -1372,11 +1372,11 @@ protected function tokenize(string $code)
$contentLc = strtolower($token[1]);
if ($contentLc === '\exit' || $contentLc === '\die') {
$specialCasedType = 'T_EXIT';
- } else if ($contentLc === '\true') {
+ } elseif ($contentLc === '\true') {
$specialCasedType = 'T_TRUE';
- } else if ($contentLc === '\false') {
+ } elseif ($contentLc === '\false') {
$specialCasedType = 'T_FALSE';
- } else if ($contentLc === '\null') {
+ } elseif ($contentLc === '\null') {
$specialCasedType = 'T_NULL';
}
@@ -1474,13 +1474,13 @@ protected function tokenize(string $code)
if ($newContentLc === '\exit' || $newContentLc === '\die') {
$newToken['code'] = T_EXIT;
$newToken['type'] = 'T_EXIT';
- } else if ($newContentLc === '\true') {
+ } elseif ($newContentLc === '\true') {
$newToken['code'] = T_TRUE;
$newToken['type'] = 'T_TRUE';
- } else if ($newContentLc === '\false') {
+ } elseif ($newContentLc === '\false') {
$newToken['code'] = T_FALSE;
$newToken['type'] = 'T_FALSE';
- } else if ($newContentLc === '\null') {
+ } elseif ($newContentLc === '\null') {
$newToken['code'] = T_NULL;
$newToken['type'] = 'T_NULL';
}
@@ -1627,7 +1627,7 @@ protected function tokenize(string $code)
|| $tokens[$i] !== '('
) {
$isReadonlyKeyword = true;
- } else if ($tokens[$i] === '(') {
+ } elseif ($tokens[$i] === '(') {
/*
* Skip over tokens which can be used in type declarations.
* At this point, the only token types which need to be taken into consideration
@@ -1756,7 +1756,7 @@ protected function tokenize(string $code)
}
continue;
- } else if ($tokenIsArray === true
+ } elseif ($tokenIsArray === true
&& $token[0] === T_YIELD_FROM
&& strpos($token[1], $this->eolChar) !== false
&& preg_match('`^yield\s+from$`i', $token[1]) === 1
@@ -1808,7 +1808,7 @@ protected function tokenize(string $code)
}
continue;
- } else if (PHP_VERSION_ID >= 80300
+ } elseif (PHP_VERSION_ID >= 80300
&& $tokenIsArray === true
&& $token[0] === T_YIELD_FROM
&& preg_match('`^yield[ \t]+from$`i', $token[1]) !== 1
@@ -2019,7 +2019,7 @@ protected function tokenize(string $code)
$finalTokens[$newStackPtr] = $newToken;
$newStackPtr++;
continue;
- } else if ($isMatch === false && $token[0] === T_MATCH) {
+ } elseif ($isMatch === false && $token[0] === T_MATCH) {
// PHP 8.0, match keyword, but not a match expression.
$newToken = [];
$newToken['code'] = T_STRING;
@@ -2143,11 +2143,11 @@ protected function tokenize(string $code)
if (isset($lastRelevantNonEmpty) === false && $tokenType !== T_CALLABLE) {
// Can be anything, but is definitely not a type declaration.
$isInlineThen = true;
- } else if (isset($lastRelevantNonEmpty) === true) {
+ } elseif (isset($lastRelevantNonEmpty) === true) {
if ($lastRelevantNonEmpty === T_ARRAY && $tokenType === '(') {
// Array declaration in ternary then.
$isInlineThen = true;
- } else if (isset(Tokens::NAME_TOKENS[$lastRelevantNonEmpty]) === true
+ } elseif (isset(Tokens::NAME_TOKENS[$lastRelevantNonEmpty]) === true
&& ($tokenType === T_DOUBLE_COLON
|| $tokenType === '('
|| $tokenType === ':')
@@ -2230,7 +2230,7 @@ protected function tokenize(string $code)
$newToken['code'] = T_NULLABLE;
$newToken['type'] = 'T_NULLABLE';
break;
- } else if (in_array($tokenType, [T_DOUBLE_ARROW, T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
+ } elseif (in_array($tokenType, [T_DOUBLE_ARROW, T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("* token $stackPtr changed from ? to T_INLINE_THEN", 2);
}
@@ -2315,7 +2315,7 @@ function return types. We want to keep the parenthesis map clean,
for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
if (is_array($tokens[$x]) === false && $tokens[$x] === '(') {
$parenthesisStack[] = $x;
- } else if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
+ } elseif (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
array_pop($parenthesisStack);
if (empty($parenthesisStack) === true) {
$parenthesisCloser = $x;
@@ -2510,7 +2510,7 @@ function return types. We want to keep the parenthesis map clean,
$preserveTstring = true;
$insideConstDeclaration = false;
}
- } else if (isset(static::T_STRING_CONTEXTS[$finalTokens[$lastNotEmptyToken]['code']]) === true
+ } elseif (isset(static::T_STRING_CONTEXTS[$finalTokens[$lastNotEmptyToken]['code']]) === true
&& $finalTokens[$lastNotEmptyToken]['code'] !== T_CONST
) {
$preserveTstring = true;
@@ -2523,7 +2523,7 @@ function return types. We want to keep the parenthesis map clean,
) {
$preserveTstring = false;
}
- } else if ($finalTokens[$lastNotEmptyToken]['content'] === '&') {
+ } elseif ($finalTokens[$lastNotEmptyToken]['content'] === '&') {
// Function names for functions declared to return by reference.
for ($i = ($lastNotEmptyToken - 1); $i >= 0; $i--) {
if (isset(Tokens::EMPTY_TOKENS[$finalTokens[$i]['code']]) === true) {
@@ -2574,7 +2574,7 @@ function return types. We want to keep the parenthesis map clean,
$cacheKey = null;
if ($token[0] === T_STRING) {
$cacheKey = strtolower($token[1]);
- } else if ($token[0] !== T_CURLY_OPEN) {
+ } elseif ($token[0] !== T_CURLY_OPEN) {
$cacheKey = $token[0];
}
@@ -2630,7 +2630,7 @@ function return types. We want to keep the parenthesis map clean,
if ($parenCount === 0) {
break;
}
- } else if ($tokens[$i] === ')') {
+ } elseif ($tokens[$i] === ')') {
$parenCount++;
}
}
@@ -2828,7 +2828,7 @@ protected function processAdditional()
}//end if
continue;
- } else if ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
+ } elseif ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
/*
Detect anonymous classes and assign them a different token.
*/
@@ -2882,7 +2882,7 @@ protected function processAdditional()
}//end if
continue;
- } else if ($this->tokens[$i]['code'] === T_FN && isset($this->tokens[($i + 1)]) === true) {
+ } elseif ($this->tokens[$i]['code'] === T_FN && isset($this->tokens[($i + 1)]) === true) {
// Possible arrow function.
for ($x = ($i + 1); $x < $numTokens; $x++) {
if (isset(Tokens::EMPTY_TOKENS[$this->tokens[$x]['code']]) === false
@@ -3083,7 +3083,7 @@ protected function processAdditional()
$this->tokens[$i]['code'] = T_STRING;
$this->tokens[$i]['type'] = 'T_STRING';
}
- } else if ($this->tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
+ } elseif ($this->tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
if (isset($this->tokens[$i]['bracket_closer']) === false) {
continue;
}
@@ -3166,7 +3166,7 @@ protected function processAdditional()
}
continue;
- } else if ($this->tokens[$i]['code'] === T_MATCH) {
+ } elseif ($this->tokens[$i]['code'] === T_MATCH) {
if (isset($this->tokens[$i]['scope_opener'], $this->tokens[$i]['scope_closer']) === false) {
// Not a match expression after all.
$this->tokens[$i]['code'] = T_STRING;
@@ -3237,7 +3237,7 @@ protected function processAdditional()
}//end if
continue;
- } else if ($this->tokens[$i]['code'] === T_BITWISE_OR
+ } elseif ($this->tokens[$i]['code'] === T_BITWISE_OR
|| $this->tokens[$i]['code'] === T_BITWISE_AND
|| $this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS
) {
@@ -3546,7 +3546,7 @@ protected function processAdditional()
$line = $this->tokens[$x]['line'];
StatusWriter::write("* token $x on line $line changed from T_BITWISE_OR to T_TYPE_UNION", 1);
}
- } else if ($this->tokens[$x]['code'] === T_BITWISE_AND) {
+ } elseif ($this->tokens[$x]['code'] === T_BITWISE_AND) {
$this->tokens[$x]['code'] = T_TYPE_INTERSECTION;
$this->tokens[$x]['type'] = 'T_TYPE_INTERSECTION';
@@ -3554,7 +3554,7 @@ protected function processAdditional()
$line = $this->tokens[$x]['line'];
StatusWriter::write("* token $x on line $line changed from T_BITWISE_AND to T_TYPE_INTERSECTION", 1);
}
- } else if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) {
+ } elseif ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) {
$this->tokens[$x]['code'] = T_TYPE_OPEN_PARENTHESIS;
$this->tokens[$x]['type'] = 'T_TYPE_OPEN_PARENTHESIS';
@@ -3562,7 +3562,7 @@ protected function processAdditional()
$line = $this->tokens[$x]['line'];
StatusWriter::write("* token $x on line $line changed from T_OPEN_PARENTHESIS to T_TYPE_OPEN_PARENTHESIS", 1);
}
- } else if ($this->tokens[$x]['code'] === T_CLOSE_PARENTHESIS) {
+ } elseif ($this->tokens[$x]['code'] === T_CLOSE_PARENTHESIS) {
$this->tokens[$x]['code'] = T_TYPE_CLOSE_PARENTHESIS;
$this->tokens[$x]['type'] = 'T_TYPE_CLOSE_PARENTHESIS';
@@ -3584,7 +3584,7 @@ protected function processAdditional()
}
continue;
- } else if ($this->tokens[$i]['code'] === T_TRUE
+ } elseif ($this->tokens[$i]['code'] === T_TRUE
|| $this->tokens[$i]['code'] === T_FALSE
|| $this->tokens[$i]['code'] === T_NULL
) {
@@ -3776,7 +3776,7 @@ public static function standardiseToken($token)
$cacheKey = null;
if ($token[0] === T_STRING) {
$cacheKey = strtolower($token[1]);
- } else if ($token[0] !== T_CURLY_OPEN) {
+ } elseif ($token[0] !== T_CURLY_OPEN) {
$cacheKey = $token[0];
}
@@ -3816,7 +3816,7 @@ public static function standardiseToken($token)
$newToken['code'] = constant($newToken['type']);
self::$resolveTokenCache[$cacheKey] = $newToken;
- } else if ($token[0] === T_CURLY_OPEN) {
+ } elseif ($token[0] === T_CURLY_OPEN) {
$newToken = [
'code' => T_OPEN_CURLY_BRACKET,
'type' => 'T_OPEN_CURLY_BRACKET',
@@ -3967,7 +3967,7 @@ private function findCloser(array &$tokens, int $start, $openerTokens, string $c
|| (is_array($tokens[$x]) === true && in_array($tokens[$x][1], $openerTokens, true) === true)
) {
$stack[] = $x;
- } else if ($tokens[$x] === $closerChar) {
+ } elseif ($tokens[$x] === $closerChar) {
array_pop($stack);
if (empty($stack) === true) {
$closer = $x;
@@ -4064,7 +4064,7 @@ private function createAttributesNestingMap()
$map[$this->tokens[$i]['attribute_opener']]
= $this->tokens[$i]['attribute_closer'];
}
- } else if (isset($this->tokens[$i]['attribute_closer']) === true
+ } elseif (isset($this->tokens[$i]['attribute_closer']) === true
&& $i === $this->tokens[$i]['attribute_closer']
) {
array_pop($map);
diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php
index 8c72d35b28..eb19950e14 100644
--- a/src/Tokenizers/Tokenizer.php
+++ b/src/Tokenizers/Tokenizer.php
@@ -221,7 +221,7 @@ private function createPositionMap()
// There are no tabs in the tokens we know the length of.
$length = $this->knownLengths[$this->tokens[$i]['code']];
$currColumn += $length;
- } else if ($tabWidth === 0
+ } elseif ($tabWidth === 0
|| isset(self::TOKENS_WITH_TABS[$this->tokens[$i]['code']]) === false
|| strpos($this->tokens[$i]['content'], "\t") === false
) {
@@ -373,11 +373,11 @@ private function createPositionMap()
$this->tokens[$i]['code'] = T_PHPCS_SET;
$this->tokens[$i]['type'] = 'T_PHPCS_SET';
- } else if (substr($commentTextLower, 0, 16) === 'phpcs:ignorefile') {
+ } elseif (substr($commentTextLower, 0, 16) === 'phpcs:ignorefile') {
// The whole file will be ignored, but at least set the correct token.
$this->tokens[$i]['code'] = T_PHPCS_IGNORE_FILE;
$this->tokens[$i]['type'] = 'T_PHPCS_IGNORE_FILE';
- } else if (substr($commentTextLower, 0, 13) === 'phpcs:disable') {
+ } elseif (substr($commentTextLower, 0, 13) === 'phpcs:disable') {
if ($lineHasOtherContent === false) {
// Completely ignore the comment line.
$this->ignoredLines[$this->tokens[$i]['line']] = $ignoreAll;
@@ -402,7 +402,7 @@ private function createPositionMap()
$this->tokens[$i]['code'] = T_PHPCS_DISABLE;
$this->tokens[$i]['type'] = 'T_PHPCS_DISABLE';
$this->tokens[$i]['sniffCodes'] = $disabledSniffs;
- } else if (substr($commentTextLower, 0, 12) === 'phpcs:enable') {
+ } elseif (substr($commentTextLower, 0, 12) === 'phpcs:enable') {
if ($ignoring !== null) {
$enabledSniffs = [];
@@ -437,7 +437,7 @@ private function createPositionMap()
$this->tokens[$i]['code'] = T_PHPCS_ENABLE;
$this->tokens[$i]['type'] = 'T_PHPCS_ENABLE';
- } else if (substr($commentTextLower, 0, 12) === 'phpcs:ignore') {
+ } elseif (substr($commentTextLower, 0, 12) === 'phpcs:ignore') {
$ignoreRules = [];
$additionalText = substr($commentText, 13);
@@ -623,14 +623,14 @@ private function createTokenMap()
$i = $j;
}
- } else if ($this->tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
+ } elseif ($this->tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
$openers[] = $i;
$this->tokens[$i]['parenthesis_opener'] = $i;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> Found unowned parenthesis opener at $i", count($openers));
}
- } else if ($this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
+ } elseif ($this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
// Did we set an owner for this set of parenthesis?
$numOpeners = count($openers);
if ($numOpeners !== 0) {
@@ -644,7 +644,7 @@ private function createTokenMap()
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> Found parenthesis closer at $i for $owner", (count($openers) + 1));
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> Found unowned parenthesis closer at $i for $opener", (count($openers) + 1));
}
@@ -652,7 +652,7 @@ private function createTokenMap()
$this->tokens[$i]['parenthesis_closer'] = $i;
$this->tokens[$opener]['parenthesis_closer'] = $i;
}//end if
- } else if ($this->tokens[$i]['code'] === T_ATTRIBUTE) {
+ } elseif ($this->tokens[$i]['code'] === T_ATTRIBUTE) {
$openers[] = $i;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> Found attribute opener at $i", count($openers));
@@ -660,7 +660,7 @@ private function createTokenMap()
$this->tokens[$i]['attribute_opener'] = $i;
$this->tokens[$i]['attribute_closer'] = null;
- } else if ($this->tokens[$i]['code'] === T_ATTRIBUTE_END) {
+ } elseif ($this->tokens[$i]['code'] === T_ATTRIBUTE_END) {
$numOpeners = count($openers);
if ($numOpeners !== 0) {
$opener = array_pop($openers);
@@ -679,7 +679,7 @@ private function createTokenMap()
$this->tokens[$x]['attribute_opener'] = $opener;
$this->tokens[$x]['attribute_closer'] = $i;
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> Found unowned attribute closer at $i for $opener", (count($openers) + 1));
}
}//end if
@@ -773,7 +773,7 @@ private function createParenthesisNestingMap()
$map[$this->tokens[$i]['parenthesis_opener']]
= $this->tokens[$i]['parenthesis_closer'];
}
- } else if (isset($this->tokens[$i]['parenthesis_closer']) === true
+ } elseif (isset($this->tokens[$i]['parenthesis_closer']) === true
&& $i === $this->tokens[$i]['parenthesis_closer']
) {
array_pop($map);
@@ -939,7 +939,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
$ignore--;
continue;
- } else if ($this->tokens[$opener]['code'] === T_OPEN_CURLY_BRACKET
+ } elseif ($this->tokens[$opener]['code'] === T_OPEN_CURLY_BRACKET
&& $tokenType !== T_CLOSE_CURLY_BRACKET
) {
// The opener is a curly bracket so the closer must be a curly bracket as well.
@@ -978,14 +978,14 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('* closer is not valid (no opener found) *', $depth);
}
- } else if ($this->tokens[$this->tokens[$scopeCloser]['scope_opener']]['code'] !== $this->tokens[$opener]['code']) {
+ } elseif ($this->tokens[$this->tokens[$scopeCloser]['scope_opener']]['code'] !== $this->tokens[$opener]['code']) {
$validCloser = false;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
$type = $this->tokens[$this->tokens[$scopeCloser]['scope_opener']]['type'];
$openerType = $this->tokens[$opener]['type'];
StatusWriter::write("* closer is not valid (mismatched opener type; $type != $openerType) *", $depth);
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('* closer was valid *', $depth);
}
} else {
@@ -1006,7 +1006,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
// the ignore value back to its original value.
$ignore = $originalIgnore;
return $opener;
- } else if ($scopeCloser === $i
+ } elseif ($scopeCloser === $i
&& isset($this->scopeOpeners[$tokenType]) === true
) {
// Unset scope_condition here or else the token will appear to have
@@ -1127,7 +1127,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
}
continue;
- } else if ($currType === $tokenType
+ } elseif ($currType === $tokenType
&& $isShared === false
&& $opener === null
) {
@@ -1251,7 +1251,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
$opener = $i;
}
}//end if
- } else if ($tokenType === T_SEMICOLON
+ } elseif ($tokenType === T_SEMICOLON
&& $opener === null
&& (isset($this->tokens[$stackPtr]['parenthesis_closer']) === false
|| $i > $this->tokens[$stackPtr]['parenthesis_closer'])
@@ -1264,7 +1264,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
}
return ($i - 1);
- } else if ($tokenType === T_OPEN_PARENTHESIS) {
+ } elseif ($tokenType === T_OPEN_PARENTHESIS) {
if (isset($this->tokens[$i]['parenthesis_owner']) === true) {
$owner = $this->tokens[$i]['parenthesis_owner'];
if (isset(Tokens::SCOPE_OPENERS[$this->tokens[$owner]['code']]) === true
@@ -1278,7 +1278,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
$startLine = $this->tokens[$this->tokens[$i]['parenthesis_closer']]['line'];
}
}
- } else if ($tokenType === T_OPEN_CURLY_BRACKET && $opener !== null) {
+ } elseif ($tokenType === T_OPEN_CURLY_BRACKET && $opener !== null) {
// We opened something that we don't have a scope opener for.
// Examples of this are curly brackets for string offsets etc.
// We want to ignore this so that we don't have an invalid scope
@@ -1288,14 +1288,14 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
}
$ignore++;
- } else if ($tokenType === T_CLOSE_CURLY_BRACKET && $ignore > 0) {
+ } elseif ($tokenType === T_CLOSE_CURLY_BRACKET && $ignore > 0) {
// We found the end token for the opener we were ignoring.
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('* finished ignoring curly brace *', $depth);
}
$ignore--;
- } else if ($opener === null
+ } elseif ($opener === null
&& isset($this->scopeOpeners[$currType]) === true
) {
// If we still haven't found the opener after 30 lines,
@@ -1321,7 +1321,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0
return $stackPtr;
}
}
- } else if ($opener !== null
+ } elseif ($opener !== null
&& $tokenType !== T_BREAK
&& isset($this->endScopeTokens[$tokenType]) === true
) {
@@ -1504,7 +1504,7 @@ private function createLevelMap()
if ($lastOpener !== null) {
$openers[$lastOpener] = $lastOpener;
}
- } else if ($lastOpener !== null && $this->tokens[$lastOpener]['scope_closer'] === $i) {
+ } elseif ($lastOpener !== null && $this->tokens[$lastOpener]['scope_closer'] === $i) {
foreach (array_reverse($openers) as $opener) {
if ($this->tokens[$opener]['scope_closer'] === $i) {
$oldOpener = array_pop($openers);
diff --git a/src/Util/Cache.php b/src/Util/Cache.php
index 461c59e3ce..88ea0a79a2 100644
--- a/src/Util/Cache.php
+++ b/src/Util/Cache.php
@@ -74,7 +74,7 @@ public static function load(Ruleset $ruleset, Config $config)
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> external file: $file", 2);
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> internal sniff: $file", 2);
}
@@ -90,7 +90,7 @@ public static function load(Ruleset $ruleset, Config $config)
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> external ruleset: $file", 2);
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write("=> internal ruleset: $file", 2);
}
@@ -278,7 +278,7 @@ static function ($file, $key, $iterator) {
StatusWriter::write('* cache was invalid and has been cleared *', 1);
}
}
- } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ } elseif (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('* cache file does not exist *', 1);
}
diff --git a/src/Util/Common.php b/src/Util/Common.php
index 8e1a8e54be..3988f811fa 100644
--- a/src/Util/Common.php
+++ b/src/Util/Common.php
@@ -521,7 +521,7 @@ public static function suggestType(string $varType)
} else {
return 'array';
}//end if
- } else if (isset(self::ALLOWED_TYPES[$lowerVarType]) === true) {
+ } elseif (isset(self::ALLOWED_TYPES[$lowerVarType]) === true) {
// A valid type, but not lower cased.
return $lowerVarType;
} else {
@@ -566,7 +566,7 @@ public static function getSniffCode($sniffClass)
if ($sniff !== 'Sniff' && substr($sniff, -5) === 'Sniff') {
// Sniff class name.
$sniff = substr($sniff, 0, -5);
- } else if ($sniff !== 'UnitTest' && substr($sniff, -8) === 'UnitTest') {
+ } elseif ($sniff !== 'UnitTest' && substr($sniff, -8) === 'UnitTest') {
// Unit test class name.
$sniff = substr($sniff, 0, -8);
} else {
diff --git a/src/Util/IgnoreList.php b/src/Util/IgnoreList.php
index 86797bc831..f277335730 100644
--- a/src/Util/IgnoreList.php
+++ b/src/Util/IgnoreList.php
@@ -104,7 +104,7 @@ public function set(string $code, bool $ignore)
$part = array_shift($parts);
if (isset($data[$part]) === false) {
$data[$part] = [];
- } else if (is_bool($data[$part]) === true) {
+ } elseif (is_bool($data[$part]) === true) {
$data[$part] = ['.default' => $data[$part]];
}
diff --git a/src/Util/Standards.php b/src/Util/Standards.php
index 2d8b818200..e22b0880aa 100644
--- a/src/Util/Standards.php
+++ b/src/Util/Standards.php
@@ -298,7 +298,7 @@ public static function getInstalledStandardPath(string $standard)
if ($path !== false && is_file($path) === true) {
return $path;
- } else if (Common::isPharFile($standardPath) === true) {
+ } elseif (Common::isPharFile($standardPath) === true) {
$path = Common::realpath($standardPath);
if ($path !== false) {
return $path;
diff --git a/src/Util/Timing.php b/src/Util/Timing.php
index f229dae4c4..177053c741 100644
--- a/src/Util/Timing.php
+++ b/src/Util/Timing.php
@@ -113,7 +113,7 @@ public static function getHumanReadableDuration(float $duration)
if ($secs >= 0.01) {
$timeString .= ", $secs secs";
}
- } else if ($duration >= self::SECOND_IN_MS) {
+ } elseif ($duration >= self::SECOND_IN_MS) {
$timeString = round(($duration / self::SECOND_IN_MS), 2) . ' secs';
} else {
$timeString = round($duration) . 'ms';
diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php
index 6c6b461a9f..2569199426 100644
--- a/tests/Core/Filters/AbstractFilterTestCase.php
+++ b/tests/Core/Filters/AbstractFilterTestCase.php
@@ -221,7 +221,7 @@ protected static function mapPathsToRuntimeOs(array $paths)
foreach ($paths as $key => $value) {
if (is_string($value) === true) {
$paths[$key] = strtr($value, '/', '\\\\');
- } else if (is_array($value) === true) {
+ } elseif (is_array($value) === true) {
$paths[$key] = self::mapPathsToRuntimeOs($value);
}
}
diff --git a/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php
index a189833081..d6084d8e58 100644
--- a/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php
+++ b/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php
@@ -761,9 +761,9 @@ public function testOtherColonsInTernary($testMarker)
if ($colonCount === 1) {
$this->assertSame(T_COLON, $tokens[$i]['code'], 'First colon is not tokenized as T_COLON');
- } else if ($colonCount === 2) {
+ } elseif ($colonCount === 2) {
$this->assertSame(T_INLINE_ELSE, $tokens[$i]['code'], 'Second colon is not tokenized as T_INLINE_ELSE');
- } else if ($colonCount === 3) {
+ } elseif ($colonCount === 3) {
$this->assertSame(T_COLON, $tokens[$i]['code'], 'Third colon is not tokenized as T_COLON');
} else {
$this->fail('Unexpected colon encountered in statement');
@@ -959,15 +959,15 @@ public static function dataReservedKeywordsAsName()
if ($keyword === 'and') {
$tokensTypes[] = T_LOGICAL_AND;
- } else if ($keyword === 'die') {
+ } elseif ($keyword === 'die') {
$tokensTypes[] = T_EXIT;
- } else if ($keyword === 'or') {
+ } elseif ($keyword === 'or') {
$tokensTypes[] = T_LOGICAL_OR;
- } else if ($keyword === 'xor') {
+ } elseif ($keyword === 'xor') {
$tokensTypes[] = T_LOGICAL_XOR;
- } else if ($keyword === '__halt_compiler') {
+ } elseif ($keyword === '__halt_compiler') {
$tokensTypes[] = T_HALT_COMPILER;
- } else if (defined($tokenName) === true) {
+ } elseif (defined($tokenName) === true) {
$tokensTypes[] = constant($tokenName);
}