Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<rule ref="Squiz.Arrays.ArrayDeclaration"/>
<rule ref="Squiz.Commenting.ClosingDeclarationComment"/>
<rule ref="Squiz.ControlStructures.ControlSignature"/>
<rule ref="Squiz.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="Squiz.Commenting.BlockComment"/>
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
Expand Down
48 changes: 24 additions & 24 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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] === '-') {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 15 additions & 15 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filters/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Loading
Loading