diff --git a/autoload.php b/autoload.php index 3ad938ffd8..af7b7c5ec7 100644 --- a/autoload.php +++ b/autoload.php @@ -92,7 +92,7 @@ public static function load(string $className) } else { self::$composerAutoloader = false; } - }//end if + } $ds = DIRECTORY_SEPARATOR; $path = false; @@ -332,4 +332,4 @@ public static function getLoadedFiles() // it gets a chance to hear about every autoload request, and record // the file and class name for it. spl_autoload_register(__NAMESPACE__ . '\Autoload::load', true, true); -}//end if +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d16d85f967..c635b8182c 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -44,7 +44,6 @@ - diff --git a/scripts/BuildRequirementsCheckMatrix.php b/scripts/BuildRequirementsCheckMatrix.php index d86294160e..bae24fee44 100644 --- a/scripts/BuildRequirementsCheckMatrix.php +++ b/scripts/BuildRequirementsCheckMatrix.php @@ -174,8 +174,8 @@ private function getMissingExtensionsBuilds() ]; } } - }//end foreach - }//end foreach + } + } return $builds; } diff --git a/scripts/build-phar.php b/scripts/build-phar.php index c07707df57..6b7f0bc3d0 100644 --- a/scripts/build-phar.php +++ b/scripts/build-phar.php @@ -136,7 +136,7 @@ function stripWhitespaceAndComments(string $fullpath, Config $config) } ++$fileCount; - }//end foreach + } // Add requirements check. $phar->addFromString('requirements.php', stripWhitespaceAndComments(realpath(__DIR__ . '/../requirements.php'), $config)); @@ -168,7 +168,7 @@ function stripWhitespaceAndComments(string $fullpath, Config $config) $phar->setStub($stub); echo 'done' . PHP_EOL; -}//end foreach +} Timing::printRunTime(); diff --git a/src/Config.php b/src/Config.php index 13a108612f..2233162ba6 100644 --- a/src/Config.php +++ b/src/Config.php @@ -344,7 +344,7 @@ public function __set(string $name, $value) default : // No validation required. break; - }//end switch + } $this->settings[$name] = $value; } @@ -444,7 +444,7 @@ public function __construct(array $cliArgs = [], bool $dieOnUnknownArg = true) $lastDir = $currentDir; $currentDir = dirname($currentDir); } while ($currentDir !== '.' && $currentDir !== $lastDir && Common::isReadable($currentDir) === true); - }//end if + } if (defined('STDIN') === false || PHP_OS_FAMILY === 'Windows' @@ -478,7 +478,7 @@ public function __construct(array $cliArgs = [], bool $dieOnUnknownArg = true) $this->overriddenDefaults['stdin'] = true; $this->overriddenDefaults['stdinContent'] = true; } - }//end if + } fclose($handle); } @@ -529,8 +529,8 @@ public function setCommandLineValues(array $args) } } else { $this->processUnknownArgument($arg, $i); - }//end if - }//end for + } + } } @@ -764,7 +764,7 @@ public function processShortArgument(string $arg, int $pos) } else { $this->processUnknownArgument('-' . $arg, $pos); } - }//end switch + } } @@ -958,7 +958,7 @@ public function processLongArgument(string $arg, int $pos) $this->cacheFile = $dir . '/' . basename($this->cacheFile); } } - }//end if + } $this->overriddenDefaults['cacheFile'] = true; @@ -1035,7 +1035,7 @@ public function processLongArgument(string $arg, int $pos) } $this->reportFile = $dir . '/' . basename($this->reportFile); - }//end if + } $this->overriddenDefaults['reportFile'] = true; @@ -1106,8 +1106,8 @@ public function processLongArgument(string $arg, int $pos) $error .= $this->printShortUsage(true); throw new DeepExitException($error, ExitCode::PROCESS_ERROR); } - }//end if - }//end if + } + } $reports[$report] = $output; } else { @@ -1120,7 +1120,7 @@ public function processLongArgument(string $arg, int $pos) foreach ($reportNames as $report) { $reports[$report] = null; } - }//end if + } // Remove the default value so the CLI value overrides it. if (isset($this->overriddenDefaults['reports']) === false) { @@ -1293,9 +1293,9 @@ public function processLongArgument(string $arg, int $pos) } else { $this->processUnknownArgument('--' . $arg, $pos); } - }//end if + } break; - }//end switch + } } @@ -1343,7 +1343,7 @@ private function parseSniffCodes(string $input, string $argument) $parts = explode('.', $sniff, 4); $sniffs[] = $parts[0] . '.' . $parts[1] . '.' . $parts[2]; } - }//end foreach + } $sniffs = array_reduce( $sniffs, @@ -1639,7 +1639,7 @@ public function setConfigData(string $key, ?string $value, bool $temp = false) $error = 'ERROR: Config file ' . $configFile . ' is not writable' . PHP_EOL . PHP_EOL; throw new DeepExitException($error, ExitCode::PROCESS_ERROR); } - }//end if + } $phpCodeSnifferConfig = self::getAllConfigData(); diff --git a/src/Files/File.php b/src/Files/File.php index e9ea5f2bfd..8dab97f01c 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -409,8 +409,8 @@ public function process() $this->ruleset->setSniffProperty($listenerClass, $propertyCode, $settings); } } - }//end if - }//end if + } + } if (PHP_CODESNIFFER_VERBOSITY > 2) { $type = $token['type']; @@ -480,8 +480,8 @@ public function process() $this->ignoredListeners[$class] = true; continue; } - }//end if - }//end if + } + } $this->activeListener = $class; @@ -513,8 +513,8 @@ public function process() } $this->activeListener = ''; - }//end foreach - }//end foreach + } + } // If short open tags are off but the file being checked uses // short open tags, the whole content will be inline HTML @@ -879,7 +879,7 @@ protected function addMessage( $parts[0] . '.' . $parts[1], $parts[0], ]; - }//end if + } if (isset($this->tokenizer->ignoredLines[$line]) === true && $this->tokenizer->ignoredLines[$line]->isIgnored($sniffCode) === true) { return false; @@ -1015,9 +1015,9 @@ protected function addMessage( // This file path is being included. $included = true; break; - }//end foreach - }//end foreach - }//end if + } + } + } if ($included === false) { // There were include rules set, but this file @@ -1652,8 +1652,8 @@ public function getMethodParameters(int $stackPtr) $defaultStart = $this->findNext(Tokens::EMPTY_TOKENS, ($i + 1), null, true); $equalToken = $i; break; - }//end switch - }//end for + } + } return $vars; } @@ -1749,8 +1749,8 @@ public function getMethodProperties(int $stackPtr) case T_STATIC: $isStatic = true; break; - }//end switch - }//end for + } + } $returnType = ''; $returnTypeToken = false; @@ -1810,7 +1810,7 @@ public function getMethodProperties(int $stackPtr) $returnType .= $this->tokens[$i]['content']; $returnTypeEndToken = $i; } - }//end for + } if ($this->tokens[$stackPtr]['code'] === T_FN) { $bodyToken = T_FN_ARROW; @@ -1820,7 +1820,7 @@ public function getMethodProperties(int $stackPtr) $end = $this->findNext([$bodyToken, T_SEMICOLON], $this->tokens[$stackPtr]['parenthesis_closer']); $hasBody = $this->tokens[$end]['code'] === $bodyToken; - }//end if + } if ($returnType !== '' && $nullableReturnType === true) { $returnType = '?' . $returnType; @@ -1975,8 +1975,8 @@ public function getMemberProperties(int $stackPtr) case T_ABSTRACT: $isAbstract = true; break; - }//end switch - }//end for + } + } $type = ''; $typeToken = false; @@ -2022,7 +2022,7 @@ public function getMemberProperties(int $stackPtr) if ($type !== '' && $nullableType === true) { $type = '?' . $type; } - }//end if + } return [ 'scope' => $scope, @@ -2095,7 +2095,7 @@ public function getClassProperties(int $stackPtr) $isReadonly = true; break; } - }//end for + } return [ 'is_abstract' => $isAbstract, @@ -2180,9 +2180,9 @@ public function isReference(int $stackPtr) return true; } } - }//end if - }//end if - }//end if + } + } + } // Pass by reference in function calls and assign by reference in arrays. if ($this->tokens[$tokenBefore]['code'] === T_OPEN_PARENTHESIS @@ -2208,8 +2208,8 @@ public function isReference(int $stackPtr) if ($this->tokens[$nextSignificantAfter]['code'] === T_VARIABLE) { return true; } - }//end if - }//end if + } + } return false; } @@ -2331,7 +2331,7 @@ public function findPrevious( break; } } - }//end for + } return false; } @@ -2397,7 +2397,7 @@ public function findNext( if ($local === true && $this->tokens[$i]['code'] === T_SEMICOLON) { break; } - }//end for + } return false; } @@ -2492,7 +2492,7 @@ public function findStartOfStatement(int $start, $ignore = null) $inNestedExpression = true; break; } - }//end for + } if ($inNestedExpression === false) { // $prevMatch will now either be the scope opener or a match arrow. @@ -2523,9 +2523,9 @@ public function findStartOfStatement(int $start, $ignore = null) } return $next; - }//end if - }//end if - }//end if + } + } + } $lastNotEmpty = $start; @@ -2582,12 +2582,12 @@ public function findStartOfStatement(int $start, $ignore = null) if ($start !== false) { $i = $start; } - }//end if + } if (isset(Tokens::EMPTY_TOKENS[$this->tokens[$i]['code']]) === false) { $lastNotEmpty = $i; } - }//end for + } return 0; } @@ -2647,8 +2647,8 @@ public function findEndOfStatement(int $start, $ignore = null) $start = $nextMatchArrow; } } - }//end if - }//end if + } + } $lastNotEmpty = $start; for ($i = $start; $i < $this->numTokens; $i++) { @@ -2696,12 +2696,12 @@ public function findEndOfStatement(int $start, $ignore = null) if ($end !== false) { $i = $end; } - }//end if + } if (isset(Tokens::EMPTY_TOKENS[$this->tokens[$i]['code']]) === false) { $lastNotEmpty = $i; } - }//end for + } return ($this->numTokens - 1); } @@ -2762,7 +2762,7 @@ public function findFirstOnLine($types, int $start, bool $exclude = false, ?stri $foundToken = $i; } } - }//end for + } return $foundToken; } diff --git a/src/Files/FileList.php b/src/Files/FileList.php index 32c5a9ecd0..cb51718b52 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -97,8 +97,8 @@ public function __construct(Config $config, Ruleset $ruleset) } } else { $this->addFile($path); - }//end if - }//end foreach + } + } reset($this->files); $this->numFiles = count($this->files); diff --git a/src/Files/LocalFile.php b/src/Files/LocalFile.php index e1bf7d7ae4..287efe5240 100644 --- a/src/Files/LocalFile.php +++ b/src/Files/LocalFile.php @@ -119,7 +119,7 @@ public function process() $this->numTokens = $cache['numTokens']; $this->fromCache = true; return; - }//end if + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::writeNewline(); diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index 5985bf8648..9dc37f974b 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -252,7 +252,7 @@ protected function shouldIgnorePath(string $path) $this->ignoreFilePatterns[$pattern] = $type; } } - }//end if + } $relativePath = $path; if (strpos($path, $this->basedir) === 0) { @@ -291,7 +291,7 @@ protected function shouldIgnorePath(string $path) if (preg_match($pattern, $testPath) === 1) { return true; } - }//end foreach + } return false; } diff --git a/src/Fixer.php b/src/Fixer.php index 74cdb05359..066cf51340 100644 --- a/src/Fixer.php +++ b/src/Fixer.php @@ -203,7 +203,7 @@ public function fixFile() } elseif (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::forceWrite("* fixed $this->numFixes violations, starting loop " . ($this->loops + 1) . ' *', 1); } - }//end while + } $this->enabled = false; @@ -487,7 +487,7 @@ public function rollbackChangeset() } $this->changeset = []; - }//end if + } } @@ -543,7 +543,7 @@ public function replaceToken(int $stackPtr, string $content) $oldContent .= $append; $newContent .= $append; } - }//end if + } if ($this->inChangeset === true) { $this->changeset[$stackPtr] = $content; @@ -585,12 +585,12 @@ public function replaceToken(int $stackPtr, string $content) } return false; - }//end if + } $this->oldTokenValues[$stackPtr]['prev'] = $this->oldTokenValues[$stackPtr]['curr']; $this->oldTokenValues[$stackPtr]['curr'] = $content; $this->oldTokenValues[$stackPtr]['loop'] = $this->loops; - }//end if + } $this->fixedTokens[$stackPtr] = $this->tokens[$stackPtr]; $this->tokens[$stackPtr] = $content; @@ -647,7 +647,7 @@ public function revertToken(int $stackPtr) $oldContent .= $append; $newContent .= $append; } - }//end if + } $this->tokens[$stackPtr] = $this->fixedTokens[$stackPtr]; unset($this->fixedTokens[$stackPtr]); @@ -803,7 +803,7 @@ public function changeCodeBlockIndent(int $start, int $end, int $change) } $this->replaceToken($i, $newContent); - }//end for + } if ($useChangeset === true) { $this->endChangeset(); diff --git a/src/Generators/Text.php b/src/Generators/Text.php index 9ed32c3e0d..f902c9bd0b 100644 --- a/src/Generators/Text.php +++ b/src/Generators/Text.php @@ -134,13 +134,13 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node) if ($firstTitleLines !== [] || $secondTitleLines !== []) { $titleRow = $this->linesToTableRows($firstTitleLines, $secondTitleLines); $titleRow .= str_repeat('-', 100) . PHP_EOL; - }//end if + } $codeRow = ''; if ($firstLines !== [] || $secondLines !== []) { $codeRow = $this->linesToTableRows($firstLines, $secondLines); $codeRow .= str_repeat('-', 100) . PHP_EOL . PHP_EOL; - }//end if + } $output = ''; if ($titleRow !== '' || $codeRow !== '') { @@ -222,7 +222,7 @@ private function linesToTableRows(array $column1Lines, array $column2Lines) $rows .= '| '; $rows .= $column2Text . str_repeat(' ', max(0, (48 - strlen($column2Text)))); $rows .= '|' . PHP_EOL; - }//end for + } return $rows; } diff --git a/src/Reporter.php b/src/Reporter.php index c219a582f7..be1f8d322e 100644 --- a/src/Reporter.php +++ b/src/Reporter.php @@ -149,7 +149,7 @@ public function __construct(Config $config) break; } } - }//end if + } if ($reportClassName === '') { $error = "ERROR: Class file for report \"$type\" not found" . PHP_EOL; @@ -175,7 +175,7 @@ public function __construct(Config $config) } else { file_put_contents($output, ''); } - }//end foreach + } } @@ -385,8 +385,8 @@ public function cacheFileReport(File $phpcsFile) file_put_contents($this->tmpFiles[$type], $generatedReport, (FILE_APPEND | LOCK_EX)); } else { file_put_contents($report['output'], $generatedReport, (FILE_APPEND | LOCK_EX)); - }//end if - }//end foreach + } + } if ($errorsShown === true || PHP_CODESNIFFER_CBF === true) { $this->totalFiles++; @@ -482,7 +482,7 @@ public function prepareFileReport(File $phpcsFile) } ksort($errors[$line]); - }//end foreach + } foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) { foreach ($lineWarnings as $column => $colWarnings) { @@ -509,10 +509,10 @@ public function prepareFileReport(File $phpcsFile) } else { $errors[$line][$column] = $newWarnings; } - }//end foreach + } ksort($errors[$line]); - }//end foreach + } ksort($errors); $report['messages'] = $errors; diff --git a/src/Reports/Cbf.php b/src/Reports/Cbf.php index 1468bd2018..fdd9c4eea1 100644 --- a/src/Reports/Cbf.php +++ b/src/Reports/Cbf.php @@ -221,7 +221,7 @@ public function generate( } echo PHP_EOL; - }//end foreach + } echo str_repeat('-', $width) . PHP_EOL; echo "\033[1mA TOTAL OF $totalFixed ERROR"; diff --git a/src/Reports/Checkstyle.php b/src/Reports/Checkstyle.php index 33926eb703..a7d7c3f1a7 100644 --- a/src/Reports/Checkstyle.php +++ b/src/Reports/Checkstyle.php @@ -63,7 +63,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou $out->endElement(); } } - }//end foreach + } $out->endElement(); echo $out->flush(); diff --git a/src/Reports/Code.php b/src/Reports/Code.php index a1e1c9b018..19cdb230b4 100644 --- a/src/Reports/Code.php +++ b/src/Reports/Code.php @@ -70,7 +70,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } $tokens = $phpcsFile->getTokens(); - }//end if + } // Create an array that maps lines to the first token on the line. $lineTokens = []; @@ -256,8 +256,8 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou $snippet .= "\033[0m"; } } - }//end for - }//end if + } + } echo str_repeat('-', $width) . PHP_EOL; @@ -300,12 +300,12 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou ); echo $errorMsg . PHP_EOL; - }//end foreach - }//end foreach + } + } echo str_repeat('-', $width) . PHP_EOL; echo rtrim($snippet) . PHP_EOL; - }//end foreach + } echo str_repeat('-', $width) . PHP_EOL; if ($report['fixable'] > 0) { diff --git a/src/Reports/Diff.php b/src/Reports/Diff.php index 862b39f5ec..42fcc23123 100644 --- a/src/Reports/Diff.php +++ b/src/Reports/Diff.php @@ -56,7 +56,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } $phpcsFile->fixer->startFile($phpcsFile); - }//end if + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** START FILE FIXING ***', 1); diff --git a/src/Reports/Full.php b/src/Reports/Full.php index bd5f6becf5..010707ffa5 100644 --- a/src/Reports/Full.php +++ b/src/Reports/Full.php @@ -83,9 +83,9 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } $maxErrorLength = max($maxErrorLength, ($length + 1)); - }//end foreach - }//end foreach - }//end foreach + } + } + } $file = $report['filename']; $fileLength = strlen($file); @@ -172,7 +172,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } else { $errorMsg .= ' ' . $sourceSuffix; } - }//end if + } // The padding that goes on the front of the line. $padding = ($maxLineNumLength - strlen($line)); @@ -200,9 +200,9 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } echo $errorMsg . PHP_EOL; - }//end foreach - }//end foreach - }//end foreach + } + } + } echo str_repeat('-', $width) . PHP_EOL; if ($report['fixable'] > 0) { diff --git a/src/Reports/Info.php b/src/Reports/Info.php index 104b15cd9b..cb69d08516 100644 --- a/src/Reports/Info.php +++ b/src/Reports/Info.php @@ -154,10 +154,10 @@ public function generate( 'total', number_format($totalCount) ); - }//end if + } echo PHP_EOL; - }//end foreach + } echo str_repeat('-', 70) . PHP_EOL; } diff --git a/src/Reports/Json.php b/src/Reports/Json.php index 9c954278a4..81b99c529f 100644 --- a/src/Reports/Json.php +++ b/src/Reports/Json.php @@ -60,7 +60,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou $messages .= json_encode($messagesObject) . ','; } } - }//end foreach + } echo rtrim($messages, ','); echo ']},'; diff --git a/src/Reports/Junit.php b/src/Reports/Junit.php index 26a44b9ecd..02558f81e3 100644 --- a/src/Reports/Junit.php +++ b/src/Reports/Junit.php @@ -75,7 +75,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } } } - }//end if + } $out->endElement(); echo $out->flush(); diff --git a/src/Reports/Source.php b/src/Reports/Source.php index cd30130a6f..1afa2ab714 100644 --- a/src/Reports/Source.php +++ b/src/Reports/Source.php @@ -128,7 +128,7 @@ public function generate( } $parts[2] = $sniff; - }//end if + } $maxLength = max($maxLength, strlen($sniff)); @@ -139,8 +139,8 @@ public function generate( ]; } else { $sources[$source]['count'] += $count; - }//end if - }//end foreach + } + } if ($showSources === true) { $width = min($width, ($maxLength + 11)); @@ -239,10 +239,10 @@ public function generate( } else { echo $sniff . str_repeat(' ', ($width - 35 - strlen($sniff))); } - }//end if + } echo $sourceData['count'] . PHP_EOL; - }//end foreach + } echo str_repeat('-', $width) . PHP_EOL; echo "\033[1m" . 'A TOTAL OF ' . ($totalErrors + $totalWarnings) . ' SNIFF VIOLATION'; @@ -314,10 +314,10 @@ public function makeFriendlyName(string $name) $lastWasUpper = true; } - }//end if + } $friendlyName .= $name[$i]; - }//end for + } $friendlyName = trim($friendlyName); $friendlyName[0] = strtoupper($friendlyName[0]); diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php index 08640aa4f4..d8cf6e3b4b 100644 --- a/src/Reports/Summary.php +++ b/src/Reports/Summary.php @@ -145,7 +145,7 @@ static function ($keyA, $keyB) { } echo PHP_EOL; - }//end foreach + } echo str_repeat('-', $width) . PHP_EOL; echo "\033[1mA TOTAL OF $totalErrors ERROR"; diff --git a/src/Reports/VersionControl.php b/src/Reports/VersionControl.php index a80b9a6b11..2abd9d0861 100644 --- a/src/Reports/VersionControl.php +++ b/src/Reports/VersionControl.php @@ -84,7 +84,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } unset($blames[($line - 1)]); - }//end foreach + } // Now go through and give the authors some credit for // all the lines that do not have errors. @@ -108,7 +108,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou } $praiseCache[$author]['good']++; - }//end foreach + } foreach ($authorCache as $author => $errors) { echo "AUTHOR>>$author>>$errors" . PHP_EOL; @@ -211,8 +211,8 @@ public function generate( break; default: break; - }//end switch - }//end foreach + } + } // Make sure the report width isn't too big. $maxLength = 0; @@ -316,9 +316,9 @@ public function generate( } echo $line . PHP_EOL; - }//end foreach - }//end if - }//end foreach + } + } + } echo str_repeat('-', $width) . PHP_EOL; echo "\033[1m" . 'A TOTAL OF ' . $errorsShown . ' SNIFF VIOLATION'; diff --git a/src/Reports/Xml.php b/src/Reports/Xml.php index 4bf894bc63..62df16a063 100644 --- a/src/Reports/Xml.php +++ b/src/Reports/Xml.php @@ -69,7 +69,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou $out->endElement(); } } - }//end foreach + } $out->endElement(); diff --git a/src/Ruleset.php b/src/Ruleset.php index 45ba3fcc5b..3fa8da34dc 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -230,7 +230,7 @@ public function __construct(Config $config) } $sniffs = array_merge($sniffs, $this->processRuleset($standard)); - }//end foreach + } // Ignore sniff restrictions if caching is on. if ($config->cache === true) { @@ -326,7 +326,7 @@ public function explain() if ($currentStandard === null) { break; } - }//end if + } if (isset($this->deprecatedSniffs[$sniff]) === true) { $sniff .= ' *'; @@ -334,7 +334,7 @@ public function explain() $sniffsInStandard[] = $sniff; ++$lastCount; - }//end foreach + } if (count($this->deprecatedSniffs) > 0) { echo PHP_EOL . '* Sniffs marked with an asterisk are deprecated.' . PHP_EOL; @@ -447,7 +447,7 @@ public function showSniffDeprecations() $message .= ' ' . implode(PHP_EOL . ' ', explode(PHP_EOL, $wrapped)); $messages[] = $message; - }//end foreach + } if (count($messages) === 0) { return; @@ -585,7 +585,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0) if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write("=> included autoloader $autoloadPath", ($depth + 1)); } - }//end foreach + } // Process custom sniff config settings. // Processing rules: @@ -615,7 +615,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0) if ($applied === true && PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('=> set config value ' . $name . ': ' . (string) $config['value'], ($depth + 1)); } - }//end foreach + } // Process custom command line arguments. // Processing rules: @@ -683,7 +683,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0) // Remember which settings we've seen. $cleanedValue .= $flag; $this->cliSettingsApplied[$cliSettingName] = $depth; - }//end foreach + } if ($cleanedValue === '') { // No flags found which should be applied. @@ -691,14 +691,14 @@ public function processRuleset(string $rulesetPath, int $depth = 0) } $argString = '-' . $cleanedValue; - }//end if + } $cliArgs[] = $argString; if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write("=> set command line value $argString", ($depth + 1)); } - }//end foreach + } foreach ($ruleset->rule as $rule) { if (isset($rule['ref']) === false @@ -744,8 +744,8 @@ public function processRuleset(string $rulesetPath, int $depth = 0) StatusWriter::write('Excluding sniff "' . $sniffCode . '" except for "' . $parts[3] . '"', ($depth + 2)); } } - }//end if - }//end if + } + } if (isset($rule->exclude) === true) { foreach ($rule->exclude as $exclude) { @@ -780,11 +780,11 @@ public function processRuleset(string $rulesetPath, int $depth = 0) $this->expandRulesetReference((string) $exclude['name'], $rulesetDir, ($depth + 1)) ); } - }//end foreach - }//end if + } + } $this->processRule($rule, $newSniffs, $depth); - }//end foreach + } // Set custom php ini values as CLI args. foreach ($ruleset->{'ini'} as $arg) { @@ -811,7 +811,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0) if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write("=> set PHP ini value $name to $value", ($depth + 1)); } - }//end foreach + } if (empty($this->config->files) === true) { // Process hard-coded file paths. @@ -933,7 +933,7 @@ private function expandSniffDirectory(string $directory, int $depth = 0) } $sniffs[] = $path; - }//end foreach + } return $sniffs; } @@ -1080,8 +1080,8 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('=> ' . Common::stripBasepath($ref, $this->config->basepath), ($depth + 2)); } - }//end if - }//end if + } + } if (is_dir($ref) === true) { if (is_file($ref . DIRECTORY_SEPARATOR . 'ruleset.xml') === true) { @@ -1117,7 +1117,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de return $this->processRuleset($ref, ($depth + 2)); } - }//end if + } } @@ -1202,7 +1202,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept StatusWriter::write($statusMessage, ($depth + 2)); } } - }//end if + } // Custom message. if (isset($rule->message) === true @@ -1318,9 +1318,9 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept StatusWriter::write($statusMessage, ($depth + 2)); } - }//end if - }//end foreach - }//end if + } + } + } // Ignore patterns. foreach ($rule->{'exclude-pattern'} as $pattern) { @@ -1345,7 +1345,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept StatusWriter::write($statusMessage . ': ' . (string) $pattern, ($depth + 2)); } - }//end foreach + } // Include patterns. foreach ($rule->{'include-pattern'} as $pattern) { @@ -1370,8 +1370,8 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept StatusWriter::write($statusMessage . ': ' . (string) $pattern, ($depth + 2)); } - }//end foreach - }//end foreach + } + } } @@ -1489,14 +1489,14 @@ public function registerSniffs(array $files, array $restrictions, array $exclusi $this->msgCache->add($message, MessageCollector::ERROR); continue; } - }//end if + } $listeners[$className] = $className; if (PHP_CODESNIFFER_VERBOSITY > 2) { StatusWriter::write("Registered $className"); } - }//end foreach + } $this->sniffs = $listeners; } @@ -1586,7 +1586,7 @@ public function populateTokenListeners() ]; } } - }//end foreach + } } @@ -1707,7 +1707,7 @@ private function getRealPropertyValue($value) if ($valueLc === 'null') { return null; } - }//end if + } return $value; } diff --git a/src/Runner.php b/src/Runner.php index 0e98d6ca78..3181076831 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -138,7 +138,7 @@ public function runPHPCS() } return $exitCode; - }//end try + } return ExitCode::calculate($this->reporter); } @@ -223,7 +223,7 @@ public function runPHPCBF() } return $exitCode; - }//end try + } return ExitCode::calculate($this->reporter); } @@ -347,7 +347,7 @@ private function run() StatusWriter::write("DONE ($size files in cache)"); } } - }//end if + } $numFiles = count($todo); if ($numFiles === 0) { @@ -458,7 +458,7 @@ private function run() $pathsProcessed[] = $path; $todo->next(); - }//end for + } $debugOutput = ob_get_contents(); ob_end_clean(); @@ -493,14 +493,14 @@ private function run() $output .= ";\n?" . '>'; file_put_contents($childOutFilename, $output); exit(); - }//end if - }//end for + } + } $success = $this->processChildProcs($childProcs); if ($success === false) { throw new RuntimeException('One or more child processes failed to run'); } - }//end if + } restore_error_handler(); @@ -621,7 +621,7 @@ public function processFile(File $file) } $file->addErrorOnLine($error, 1, 'Internal.Exception'); - }//end try + } $this->reporter->cacheFileReport($file); @@ -662,8 +662,8 @@ public function processFile(File $file) $this->reporter->cacheFileReport($file); break; } - }//end while - }//end if + } + } // Clean up the file to save (a lot of) memory. $file->cleanUp(); @@ -748,7 +748,7 @@ private function processChildProcs(array $childProcs) $childOutput['totalFixedWarnings'] ); $this->printProgress($file, $totalBatches, $numProcessed); - }//end while + } return $success; } @@ -804,7 +804,7 @@ public function printProgress(File $file, int $numFiles, int $numProcessed) $colorOpen = "\033[32m"; $colorClose = "\033[0m"; } - }//end if + } } else { // Files with errors are E (red). // Files with fixable errors are E (green). @@ -835,9 +835,9 @@ public function printProgress(File $file, int $numFiles, int $numProcessed) $colorClose = "\033[0m"; } - }//end if - }//end if - }//end if + } + } + } StatusWriter::write($colorOpen . $progressDot . $colorClose, 0, 0); diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index 6735c903a6..b972e99362 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -99,7 +99,7 @@ final public function register() } $this->parsedPatterns[$tokenType][] = $patternArray; - }//end foreach + } return array_unique(array_merge($listenTypes, $this->supplementaryTokens)); } @@ -308,7 +308,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac } else { $stackPtr = ($prev - 1); } - }//end if + } } elseif ($pattern[$i]['type'] === 'skip') { // Skip to next piece of relevant code. if ($pattern[$i]['to'] === 'parenthesis_closer') { @@ -388,7 +388,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac } else { $found = $tokens[$stackPtr]['content'] . $found; $hasError = true; - }//end if + } if ($hasError === false && $pattern[($i - 1)]['type'] !== 'newline') { // Make sure they only have 1 newline. @@ -397,9 +397,9 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac $hasError = true; } } - }//end if - }//end for - }//end if + } + } + } $stackPtr = $origStackPtr; $lastAddedStackPtr = null; @@ -456,7 +456,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac $lastAddedStackPtr = $stackPtr; $stackPtr = $next; - }//end if + } if ($stackPtr !== $lastAddedStackPtr) { $found .= $tokenContent; @@ -466,7 +466,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac $found .= $tokens[$stackPtr]['content']; $lastAddedStackPtr = $stackPtr; } - }//end if + } if (isset($pattern[($i + 1)]) === true && $pattern[($i + 1)]['type'] === 'skip' @@ -522,7 +522,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac // our pattern. This means the pattern is not for us. return false; } - }//end if + } // If we skipped past some whitespace tokens, then add them // to the found string. @@ -552,7 +552,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { $hasError = true; } - }//end if + } if ($next !== $lastAddedStackPtr) { $found .= $tokens[$next]['content']; @@ -566,7 +566,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac } else { $stackPtr = ($next + 1); } - }//end if + } } elseif ($pattern[$i]['type'] === 'skip') { if ($pattern[$i]['to'] === 'unknown') { $next = $phpcsFile->findNext( @@ -606,7 +606,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac // Skip to the closing token. $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1); - }//end if + } } elseif ($pattern[$i]['type'] === 'string') { if ($tokens[$stackPtr]['code'] !== T_STRING) { $hasError = true; @@ -659,7 +659,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac $next = ($newline + 1); } } - }//end if + } if ($stackPtr !== $lastAddedStackPtr) { $found .= $phpcsFile->getTokensAsString( @@ -671,8 +671,8 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac } $stackPtr = $next; - }//end if - }//end for + } + } if ($hasError === true) { $error = $this->prepareError($found, $patternCode); @@ -789,7 +789,7 @@ private function parse(string $pattern) $lastToken = ($i - $firstToken); $firstToken = ($i + 3); $i += 2; - }//end if + } if ($specialPattern !== false || $isLastChar === true) { // If we are at the end of the string, don't worry about a limit. @@ -821,7 +821,7 @@ private function parse(string $pattern) if ($isLastChar === false && $i === ($length - 1)) { $i--; } - }//end if + } // Add the skip pattern *after* we have processed // all the tokens from the end of the last skip pattern @@ -829,7 +829,7 @@ private function parse(string $pattern) if ($specialPattern !== false) { $patterns[] = $specialPattern; } - }//end for + } return $patterns; } @@ -873,12 +873,12 @@ private function createSkipPattern(string $pattern, int $from) case ')': $nestedParenthesis++; break; - }//end switch + } if (isset($skip['to']) === true) { break; } - }//end for + } if (isset($skip['to']) === false) { $skip['to'] = 'unknown'; diff --git a/src/Sniffs/AbstractVariableSniff.php b/src/Sniffs/AbstractVariableSniff.php index 4824e6626f..ac254b1ff4 100644 --- a/src/Sniffs/AbstractVariableSniff.php +++ b/src/Sniffs/AbstractVariableSniff.php @@ -138,7 +138,7 @@ final protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, break; } } - }//end if + } if ($inFunction === true) { return $this->processVariable($phpcsFile, $stackPtr); diff --git a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php index 3276800551..303983246e 100644 --- a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php @@ -97,7 +97,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } return; - }//end if + } $expectedIndent = ($startIndent + $this->indent); @@ -144,7 +144,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } else { $phpcsFile->fixer->replaceToken(($first - 1), $padding); } - }//end foreach + } $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($arrayEnd - 1), null, true); if ($tokens[$prev]['line'] === $tokens[$arrayEnd]['line']) { diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php index 4389156197..4d5837aaf2 100644 --- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php @@ -99,15 +99,15 @@ public function process(File $phpcsFile, int $stackPtr) 'line' => $tokens[$stackPtr]['line'], ]; } - }//end if + } if (isset($tokens[$stackPtr]['scope_closer']) === true) { $stackPtr = $tokens[$stackPtr]['scope_closer']; } - }//end if + } $stackPtr = $phpcsFile->findNext($findTokens, ($stackPtr + 1)); - }//end while + } return $phpcsFile->numTokens; } diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index f2859aaf13..beb42a6d4b 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -113,7 +113,7 @@ public function process(File $phpcsFile, int $stackPtr) $opener = $token['parenthesis_opener']; $closer = $token['parenthesis_closer']; - }//end if + } $startPos = $opener; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index 94aa7edfd5..8f770b2351 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -130,7 +130,7 @@ private function processSemicolon(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if + } } diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index 42e45b10a0..fa1b59f70d 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -92,6 +92,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->addWarning($error, $stackPtr, 'NotAllowed'); break; } - }//end for + } } } diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index cb5b2d1b10..dedcefd55b 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -113,7 +113,7 @@ public function process(File $phpcsFile, int $stackPtr) $errorCode .= 'InImplementedInterface'; } } - }//end if + } $params = []; $methodParams = $phpcsFile->getMethodParameters($stackPtr); @@ -189,8 +189,8 @@ public function process(File $phpcsFile, int $stackPtr) // There is a return . return; } - }//end if - }//end if + } + } $foundContent = true; @@ -240,8 +240,8 @@ public function process(File $phpcsFile, int $stackPtr) unset($params[$varContent]); } } - }//end if - }//end for + } + } if ($foundContent === true && count($params) > 0) { $error = 'The method parameter %s is never used'; @@ -283,7 +283,7 @@ public function process(File $phpcsFile, int $stackPtr) ]; } } - }//end for + } if (count($errorInfo) > 0) { $errorInfo = array_reverse($errorInfo); @@ -296,6 +296,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->addWarning($error, $info['position'], $info['errorcode'], $data); } } - }//end if + } } } diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php index f61f6f2e94..01233eb935 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php @@ -149,7 +149,7 @@ public function process(File $phpcsFile, int $stackPtr) if ($parenthesisCount === 0) { break; } - }//end for + } $next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($next + 1), null, true); if ($tokens[$next]['code'] !== T_SEMICOLON && $tokens[$next]['code'] !== T_CLOSE_TAG) { diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index ad1b76dbb8..700cc24ebf 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -175,8 +175,8 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'Doc comment long description must start with a capital letter'; $phpcsFile->addError($error, $long, 'LongNotCapital'); } - }//end if - }//end if + } + } if (empty($tokens[$commentStart]['comment_tags']) === true) { // No tags in the comment. @@ -240,10 +240,10 @@ public function process(File $phpcsFile, int $stackPtr) if ($paramGroupid === null) { $paramGroupid = $groupid; } - }//end if + } $tagGroups[$groupid][] = $tag; - }//end foreach + } foreach ($tagGroups as $groupid => $group) { $maxLength = 0; @@ -296,7 +296,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } // Now check paddings. foreach ($paddings as $tag => $padding) { @@ -316,7 +316,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end foreach + } // If there is a param group, it needs to be first. if ($paramGroupid !== null && $paramGroupid !== 0) { diff --git a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php index 0daa92b4c5..500b5237ce 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php @@ -113,8 +113,8 @@ public function process(File $phpcsFile, int $stackPtr) && $this->isArrayStatic($phpcsFile, $beforeOpeningParenthesisIndex) === false ) { return; - }//end if - }//end if + } + } $phpcsFile->addError( 'Usage of Yoda conditions is not allowed; switch the expression order', diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 283e2598f8..b2dbc8e032 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -225,14 +225,14 @@ public function process(File $phpcsFile, int $stackPtr) if ($next !== false && $tokens[$next]['code'] === T_SEMICOLON) { $end = $next; } - }//end if + } if ($tokens[$end]['code'] !== T_END_HEREDOC && $tokens[$end]['code'] !== T_END_NOWDOC ) { break; } - }//end if + } if (isset($tokens[$end]['parenthesis_closer']) === true) { $end = $tokens[$end]['parenthesis_closer']; @@ -243,7 +243,7 @@ public function process(File $phpcsFile, int $stackPtr) if ($tokens[$end]['code'] !== T_WHITESPACE) { $lastNonEmpty = $end; } - }//end for + } if ($end === $phpcsFile->numTokens) { $end = $lastNonEmpty; @@ -313,7 +313,7 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->addContent($endToken, $addedContent); - }//end if + } $phpcsFile->fixer->endChangeset(); } diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index faf02453c7..59ce71cf18 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -119,8 +119,8 @@ public function process(File $phpcsFile, int $stackPtr) if ($tokenContent !== $newContent) { $phpcsFile->fixer->replaceToken($i, $newContent); } - }//end for - }//end if + } + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php index 56ceeed79c..61cdc130f1 100644 --- a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php @@ -171,7 +171,7 @@ protected function checkLineLength(File $phpcsFile, array $tokens, int $stackPtr return; } } - }//end if + } if ($this->absoluteLineLimit > 0 && $lineLength > $this->absoluteLineLimit diff --git a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php index 22851c2d4d..7b953a1414 100644 --- a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php @@ -96,6 +96,6 @@ public function process(File $phpcsFile, int $stackPtr) } } else { $phpcsFile->recordMetric($stackPtr, 'Multiple statements on same line', 'no'); - }//end if + } } } diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index b2025f46c7..ddfbdb6963 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -194,14 +194,14 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null) break; } } - }//end if + } continue; } 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; - }//end if + } if ($assign !== $stackPtr) { if ($tokens[$assign]['level'] > $tokens[$stackPtr]['level']) { @@ -238,7 +238,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null) } } } - }//end if + } $var = $phpcsFile->findPrevious( Tokens::EMPTY_TOKENS, @@ -277,7 +277,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null) } $assignColumn = ($varEnd + $padding); - }//end if + } if (($assignColumn + $assignLen) > ($assignments[$maxPadding]['assign_col'] + $assignments[$maxPadding]['assign_len'])) { $newPadding = ($varEnd - $assignments[$maxPadding]['var_end'] + $assignLen - $assignments[$maxPadding]['assign_len'] + 1); @@ -301,12 +301,12 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null) } } elseif ($padding > $assignments[$maxPadding]['expected']) { $maxPadding = $assign; - }//end if + } } else { $padding = 1; $assignColumn = ($varEnd + 1); $maxPadding = $assign; - }//end if + } $found = 0; if ($tokens[($var + 1)]['code'] === T_WHITESPACE) { @@ -327,7 +327,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null) $lastLine = $tokens[$assign]['line']; $prevAssign = $assign; - }//end for + } if (empty($assignments) === true) { return $stackPtr; @@ -380,7 +380,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null) $phpcsFile->fixer->replaceToken(($assignment - 1), $newContent); } } - }//end foreach + } if ($numAssignments > 1) { if ($errorGenerated === true) { diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php index 47529a2681..6aee380a24 100644 --- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php @@ -158,8 +158,8 @@ public function checkSpacing(File $phpcsFile, int $stackPtr, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) { // Ignore trailing comma's after last argument as that's outside the scope of this sniff. @@ -185,8 +185,8 @@ public function checkSpacing(File $phpcsFile, int $stackPtr, int $openBracket) } } } - }//end if - }//end if - }//end while + } + } + } } } diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php index f72188c84e..1130cc4b69 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php @@ -131,7 +131,7 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if + } $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line'); } elseif ($lineDifference > 1) { @@ -161,8 +161,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } $ignore = Tokens::PHPCS_ANNOTATION_TOKENS; $ignore[] = T_WHITESPACE; @@ -213,7 +213,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($openingBrace - 1), $indent); } } - }//end if + } $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'new line'); } diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index e1ce5b7994..732277a017 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -111,10 +111,10 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if + } } else { $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line'); - }//end if + } $ignore = Tokens::PHPCS_ANNOTATION_TOKENS; $ignore[] = T_WHITESPACE; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php index fd9fcf23cf..387549dff9 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php @@ -128,7 +128,7 @@ protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $ } $startIndex = $nextNonEmpty; - }//end while + } } diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 6c3ca2b5bb..63153316bb 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -80,7 +80,7 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if + } // Only interested in define statements now. if (strtolower(ltrim($tokens[$stackPtr]['content'], '\\')) !== 'define') { diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php index e1c56735dd..f9eeb6d071 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php @@ -131,7 +131,7 @@ public function process(File $phpcsFile, int $stackPtr) return $i; } } - }//end if + } } diff --git a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php index 62043ba7d1..9e6f50daca 100644 --- a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -191,7 +191,7 @@ public function process(File $phpcsFile, int $stackPtr) if (in_array($function, $this->forbiddenFunctionNames, true) === false) { return; } - }//end if + } $this->addError($phpcsFile, $stackPtr, $function, $pattern); } diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index 739d95d882..de64bf7aef 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -183,7 +183,7 @@ public function process(File $phpcsFile, int $stackPtr) // Skip over return type declarations. return $end; - }//end if + } // Handle everything else. $this->processConstant($phpcsFile, $stackPtr); diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php index acdaa701b5..66597f4d56 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php @@ -76,6 +76,6 @@ public function process(File $phpcsFile, int $stackPtr) } } else { $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'lower'); - }//end if + } } } diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index 8c52af4349..7c66cd0e82 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -149,10 +149,10 @@ public function process(File $phpcsFile, int $stackPtr) $this->processType($phpcsFile, $startOfType, $type, $error, $errorCode); } } - }//end if + } continue; - }//end if + } if ($tokens[$i]['code'] !== T_VARIABLE) { continue; @@ -185,10 +185,10 @@ public function process(File $phpcsFile, int $stackPtr) $this->processType($phpcsFile, $props['type_token'], $type, $error, $errorCode); } } - }//end for + } return; - }//end if + } /* * Check function return type. @@ -247,7 +247,7 @@ public function process(File $phpcsFile, int $stackPtr) $this->processType($phpcsFile, $param['type_hint_token'], $typeHint, $error, $errorCode); } } - }//end foreach + } } @@ -302,7 +302,7 @@ protected function processUnionType(File $phpcsFile, int $typeDeclStart, int $ty ++$typeTokenCount; $type .= $tokens[$i]['content']; - }//end for + } // Handle type at end of type string. if ($typeTokenCount === 1 diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index a6f40bd5cf..1a2125bdbb 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -71,7 +71,7 @@ public function process(File $phpcsFile, int $stackPtr) $next = $phpcsFile->findNext(T_COMMA, ($next + 1), $tokens[$declare]['parenthesis_closer']); } while ($next !== false && $next < $tokens[$declare]['parenthesis_closer']); - }//end if + } if ($found === false) { $error = 'Missing required strict_types declaration'; diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php index 1d14793b7d..57ffdd2f8a 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php @@ -105,7 +105,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->recordMetric($stackPtr, 'Heredoc contains interpolation or expression', 'yes'); return; } - }//end foreach + } $phpcsFile->recordMetric($stackPtr, 'Heredoc contains interpolation or expression', 'no'); diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php index 287bb7f77b..54c2696203 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php @@ -118,8 +118,8 @@ public function process(File $phpcsFile, int $stackPtr) } } break; - }//end switch - }//end for + } + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php index 6de75b982d..28631e5c7f 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php @@ -106,7 +106,7 @@ public function process(File $phpcsFile, int $stackPtr) ]; $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); } - }//end foreach + } // Ignore the rest of the file. return $phpcsFile->numTokens; @@ -175,11 +175,11 @@ protected function getProperties(string $path) fgetc($handle); $properties[$key] = $value; - }//end while + } fclose($handle); - }//end if - }//end foreach + } + } if ($foundPath === false) { return null; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 08d7a18070..686b6d5fdc 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -170,9 +170,9 @@ public function process(File $phpcsFile, int $stackPtr) } else { $phpcsFile->fixer->replaceToken(($stackPtr + 1), $expected); } - }//end if - }//end if - }//end if + } + } + } if ($tokens[$stackPtr]['code'] === T_CLOSE_PARENTHESIS && isset($tokens[($stackPtr - 1)], $tokens[($stackPtr - 2)]) === true @@ -224,8 +224,8 @@ public function process(File $phpcsFile, int $stackPtr) } else { $phpcsFile->fixer->replaceToken(($stackPtr - 1), $expected); } - }//end if - }//end if - }//end if + } + } + } } } diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index 7e3fe732c0..8aa54b31f6 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -130,7 +130,7 @@ public function process(File $phpcsFile, int $stackPtr) // Don't record metrics for empty lines. $recordMetrics = false; - }//end if + } $foundSpaces = substr_count($content, ' '); $foundTabs = substr_count($content, "\t"); @@ -195,7 +195,7 @@ public function process(File $phpcsFile, int $stackPtr) } elseif ($recordMetrics === true) { $phpcsFile->recordMetric($i, 'Line indent', 'mixed'); } - }//end if + } $error = 'Tabs must be used to indent lines; spaces are not allowed'; $errorCode = 'SpacesUsed'; @@ -214,7 +214,7 @@ public function process(File $phpcsFile, int $stackPtr) $padding .= str_repeat(' ', $expectedSpaces); $phpcsFile->fixer->replaceToken($i, $padding . $nonWhitespace); } - }//end for + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index 595cbacfdb..1c9605f90f 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -149,7 +149,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } } else { // Look for tabs so we can report and replace, but don't // record any metrics about them because they aren't @@ -158,7 +158,7 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'Spaces must be used for alignment; tabs are not allowed'; $errorCode = 'NonIndentTabsUsed'; } - }//end if + } if ($foundTabs === 0) { continue; @@ -184,7 +184,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken($i, $newContent); } } - }//end for + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index acd95214b0..3a65509895 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -100,7 +100,7 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if + } // Is this a post-increment/decrement ? $prevNonEmpty = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($stackPtr - 1), null, true); @@ -152,6 +152,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } } } diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index 4358cff786..2778159239 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -109,7 +109,7 @@ public function process(File $phpcsFile, int $stackPtr) } $yieldFromEnd = $i; - }//end if + } $error = 'Language constructs must be followed by a single space; expected 1 space between YIELD FROM found "%s"'; $data = [Common::prepareForOutput($found)]; @@ -130,10 +130,10 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } return ($yieldFromEnd + 1); - }//end if + } if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { $content = $tokens[($stackPtr + 1)]['content']; @@ -155,6 +155,6 @@ public function process(File $phpcsFile, int $stackPtr) if ($fix === true) { $phpcsFile->fixer->addContent($stackPtr, ' '); } - }//end if + } } } diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 72816b33c2..fa088e9e48 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -164,7 +164,7 @@ public function process(File $phpcsFile, int $stackPtr) $this->ignoreIndentation[$token] = true; } - }//end if + } $this->exact = (bool) $this->exact; $this->tabIndent = (bool) $this->tabIndent; @@ -204,7 +204,7 @@ public function process(File $phpcsFile, int $stackPtr) StatusWriter::write("* token $i on line $line set exact flag to $value *"); } - }//end if + } $checkToken = null; $checkIndent = null; @@ -409,7 +409,7 @@ public function process(File $phpcsFile, int $stackPtr) $type = $tokens[$first]['type']; StatusWriter::write("* amended first token is $first ($type) on line $line *", 1); } - }//end if + } if (isset($tokens[$first]['scope_closer']) === true && $tokens[$first]['scope_closer'] === $first @@ -438,7 +438,7 @@ public function process(File $phpcsFile, int $stackPtr) $type = $tokens[$first]['type']; StatusWriter::write("=> indent set to $currentIndent by token $first ($type)", 1); } - }//end if + } } else { // Don't force current indent to be divisible because there could be custom // rules in place between parenthesis, such as with arrays. @@ -453,12 +453,12 @@ public function process(File $phpcsFile, int $stackPtr) $type = $tokens[$first]['type']; StatusWriter::write("=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)", 1); } - }//end if - }//end if + } + } } elseif ($this->debug === true) { StatusWriter::write(' * ignoring single-line definition *', 1); - }//end if - }//end if + } + } // Closing short array bracket should just be indented to at least // the same level as where it was opened (but can be more). @@ -550,11 +550,11 @@ public function process(File $phpcsFile, int $stackPtr) $type = $tokens[$first]['type']; StatusWriter::write("=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)", 1); } - }//end if + } } elseif ($this->debug === true) { StatusWriter::write(' * ignoring single-line definition *', 1); - }//end if - }//end if + } + } // Adjust lines within scopes while auto-fixing. if ($checkToken !== null @@ -600,8 +600,8 @@ public function process(File $phpcsFile, int $stackPtr) $type = $tokens[$checkToken]['type']; StatusWriter::write('=> add adjustment of ' . $adjustments[$checkToken] . " for token $checkToken ($type) on line $line", 1); } - }//end if - }//end if + } + } // Scope closers reset the required indent to the same level as the opening condition. if (($checkToken !== null @@ -675,8 +675,8 @@ public function process(File $phpcsFile, int $stackPtr) } else { $checkToken = null; } - }//end if - }//end if + } + } if ($checkToken !== null && isset(Tokens::SCOPE_OPENERS[$tokens[$checkToken]['code']]) === true @@ -737,7 +737,7 @@ public function process(File $phpcsFile, int $stackPtr) StatusWriter::write("=> checking indent of $checkIndent; main indent remains at $currentIndent", 1); } } - }//end if + } // Method prefix indentation has to be exact or else it will break // the rest of the function declaration, and potentially future ones. @@ -772,8 +772,8 @@ public function process(File $phpcsFile, int $stackPtr) $exact = true; } - }//end if - }//end if + } + } // Open PHP tags needs to be indented to exact column positions // so they don't cause problems with indent checks for the code @@ -804,7 +804,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } // Close tags needs to be indented to exact column positions. if ($checkToken !== null && $tokens[$checkToken]['code'] === T_CLOSE_TAG) { @@ -881,14 +881,14 @@ public function process(File $phpcsFile, int $stackPtr) $expectedTabs, $foundTabs, ]; - }//end if + } } else { $error .= '%s spaces, found %s'; $data = [ $checkIndent, $tokenIndent, ]; - }//end if + } if ($this->debug === true) { $line = $tokens[$checkToken]['line']; @@ -911,7 +911,7 @@ public function process(File $phpcsFile, int $stackPtr) StatusWriter::write('=> add adjustment of ' . $adjustments[$checkToken] . " for token $checkToken ($type) on line $line", 1); } } - }//end if + } if ($checkToken !== null) { $i = $checkToken; @@ -957,7 +957,7 @@ public function process(File $phpcsFile, int $stackPtr) } continue; - }//end if + } // Completely skip multi-line strings as the indent is a part of the // content itself. @@ -1011,7 +1011,7 @@ public function process(File $phpcsFile, int $stackPtr) } continue; - }//end if + } // Close tags reset the indent level, unless they are closing a tag // opened on the same line. @@ -1046,7 +1046,7 @@ public function process(File $phpcsFile, int $stackPtr) } continue; - }//end if + } // Anon classes and functions set the indent based on their own indent level. if ($tokens[$i]['code'] === T_CLOSURE || $tokens[$i]['code'] === T_ANON_CLASS) { @@ -1113,7 +1113,7 @@ public function process(File $phpcsFile, int $stackPtr) } continue; - }//end if + } // Scope openers increase the indent level. if (isset($tokens[$i]['scope_condition']) === true @@ -1171,8 +1171,8 @@ public function process(File $phpcsFile, int $stackPtr) } continue; - }//end if - }//end if + } + } // Closing an anon class, closure, or match. // Each may be returned, which can confuse control structures that @@ -1232,7 +1232,7 @@ public function process(File $phpcsFile, int $stackPtr) $prev = $condition; $parens = 0; - }//end if + } if ($prev === false) { $prev = $phpcsFile->findPrevious([T_EQUAL, T_RETURN], ($tokens[$i]['scope_condition'] - 1), null, false, null, true); @@ -1301,8 +1301,8 @@ public function process(File $phpcsFile, int $stackPtr) $type = $tokens[$first]['type']; StatusWriter::write("=> indent set to $currentIndent by token $first ($type)", 1); } - }//end if - }//end for + } + } // Don't process the rest of the file. return $phpcsFile->numTokens; @@ -1388,8 +1388,8 @@ protected function adjustIndent(File $phpcsFile, int $stackPtr, int $length, int $type = $tokens[$x]['type']; StatusWriter::write("=> Indent adjusted to $length for $type on line $line", 1); } - }//end for - }//end if + } + } return true; } diff --git a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php index 43244b57c9..43d94df70f 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php @@ -52,7 +52,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php index 3aa5a8e7e1..eda1359cc7 100644 --- a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php @@ -89,6 +89,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index e605ef1b78..e40fed1771 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -87,6 +87,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index d368465530..4eadc75b62 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -101,6 +101,6 @@ public function getWarningList($testFile = '') ]; default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php index 31a25eb4e8..355ae172b2 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php @@ -69,6 +69,6 @@ public function getWarningList($testFile = '') ]; default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php index 902eb80dfe..5c6b234d0c 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php @@ -58,6 +58,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index 4b097072a1..9f5aa12592 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -69,6 +69,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index 8a96b59191..d1aaf74c0e 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -103,7 +103,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index 43e8247a94..202072f7e1 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -86,7 +86,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php index 1fb85eb0c0..c1b0523292 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php @@ -41,7 +41,7 @@ public function getErrorList($testFile = '') return [1 => 1]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php index c4d86e9926..0ad8a04e6a 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php @@ -43,7 +43,7 @@ public function getErrorList($testFile = '') return [1 => 1]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index 3a47b27643..2295a90d5b 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -50,7 +50,7 @@ public function getErrorList($testFile = '') return [1 => 1]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php index ef198742ef..c73ecf22a0 100644 --- a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php +++ b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php @@ -44,7 +44,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php index f26c0082c8..aceb710ef8 100644 --- a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php @@ -62,7 +62,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -105,6 +105,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php index ae97c5fc5b..1f19a20f7a 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php @@ -80,7 +80,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php index adacfc1878..2545da6088 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php @@ -66,7 +66,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index 9dba4a86fb..d81a1a0148 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -76,7 +76,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index 40b0ca5d32..3b99f3cb51 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -93,7 +93,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php index 294c61f79a..5809f027d0 100644 --- a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php @@ -82,7 +82,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php index 3ac4cd4ecc..627c21cb14 100644 --- a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php @@ -50,7 +50,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index 4fe2a7d084..0c2e3e41c6 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -53,7 +53,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php index 9873a3785b..1aa1c660dc 100644 --- a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php @@ -38,7 +38,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php index cf4e75d6a1..dd71fefbfa 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php @@ -43,7 +43,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php index 592e8055ce..a49bce496b 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php @@ -72,7 +72,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } @@ -105,6 +105,6 @@ public function getWarningList($testFile = '') ]; default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index bb3d1f3e35..fe0c67d11a 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -77,7 +77,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index 694dcd111a..4105c48631 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -102,7 +102,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index 43b3249c6c..39498ae110 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -45,7 +45,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php index 9774cb8aea..5f2400c1b3 100644 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php @@ -116,7 +116,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php index e5a17a24e0..18744489a4 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php @@ -72,7 +72,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -97,6 +97,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index fc5c2dc3ac..fc5f06685d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -116,7 +116,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index 0d29bb2272..01a99e8e88 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -117,7 +117,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index 58e771aa3a..d311dc7341 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -79,7 +79,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php index e8b35bf561..ffa5b9b0e4 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php @@ -49,7 +49,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php index ace6e1a013..f837721412 100644 --- a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php @@ -95,8 +95,8 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if - }//end if + } + } if ($tokens[($curlyBrace + 1)]['content'] !== $phpcsFile->eolChar) { $error = 'Opening %s brace must be on a line by itself'; @@ -140,6 +140,6 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } } } diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index 70c1490bb1..55e9f48762 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -268,7 +268,7 @@ protected function processTags(File $phpcsFile, int $stackPtr, int $commentStart $phpcsFile->addError($error, $tag, 'Empty' . ucfirst(substr($name, 1)) . 'Tag', $data); continue; } - }//end foreach + } // Check if the tags are in the correct position. $pos = 0; @@ -310,7 +310,7 @@ protected function processTags(File $phpcsFile, int $stackPtr, int $commentStart while (isset($foundTags[$pos]) === true && $foundTags[$pos] === $tag) { $pos++; } - }//end foreach + } } @@ -351,7 +351,7 @@ protected function processCategory(File $phpcsFile, array $tags) ]; $phpcsFile->addError($error, $tag, 'InvalidCategory', $data); } - }//end foreach + } } @@ -402,8 +402,8 @@ protected function processPackage(File $phpcsFile, array $tags) $validName, ]; $phpcsFile->addError($error, $tag, 'InvalidPackage', $data); - }//end if - }//end foreach + } + } } @@ -446,7 +446,7 @@ protected function processSubpackage(File $phpcsFile, array $tags) $validName, ]; $phpcsFile->addError($error, $tag, 'InvalidSubpackage', $data); - }//end foreach + } } @@ -515,7 +515,7 @@ protected function processCopyright(File $phpcsFile, array $tags) $error = '@copyright tag must contain a year and the name of the copyright holder'; $phpcsFile->addError($error, $tag, 'IncompleteCopyright'); } - }//end foreach + } } diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index ce74ddee43..72759b0ee2 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -156,8 +156,8 @@ public function process(File $phpcsFile, int $stackPtr) } $i = $nextNonWhitespace; - }//end for - }//end if + } + } $commentStart = $tokens[$commentEnd]['comment_opener']; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { @@ -221,7 +221,7 @@ protected function processReturn(File $phpcsFile, int $stackPtr, int $commentSta $error = 'Missing @return tag in function comment'; $phpcsFile->addError($error, $tokens[$commentStart]['comment_closer'], 'MissingReturn'); - }//end if + } } @@ -255,7 +255,7 @@ protected function processThrows(File $phpcsFile, int $stackPtr, int $commentSta $error = 'Exception type missing for @throws tag in function comment'; $phpcsFile->addError($error, $tag, 'InvalidThrows'); } - }//end foreach + } } @@ -331,15 +331,15 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta } else { $error = 'Missing parameter comment'; $phpcsFile->addError($error, $tag, 'MissingParamComment'); - }//end if + } } else { $error = 'Missing parameter name'; $phpcsFile->addError($error, $tag, 'MissingParamName'); - }//end if + } } else { $error = 'Missing parameter type'; $phpcsFile->addError($error, $tag, 'MissingParamType'); - }//end if + } $params[] = [ 'tag' => $tag, @@ -351,7 +351,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta 'type_space' => $typeSpace, 'var_space' => $varSpace, ]; - }//end foreach + } $realParams = $phpcsFile->getMethodParameters($stackPtr); $foundParams = []; @@ -409,9 +409,9 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta for ($i = ($commentToken + 1); $i <= $param['comment_end']; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } - }//end if - }//end if - }//end if + } + } + } // Make sure the param name is correct. if (isset($realParams[$pos]) === true) { @@ -437,7 +437,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta // We must have an extra parameter comment. $error = 'Superfluous parameter comment'; $phpcsFile->addError($error, $param['tag'], 'ExtraParamComment'); - }//end if + } if ($param['comment'] === '') { continue; @@ -480,8 +480,8 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta for ($i = ($commentToken + 1); $i <= $param['comment_end']; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } - }//end if - }//end if + } + } // Check the alignment of multi-line param comments. if ($param['tag'] !== $param['comment_end']) { @@ -523,9 +523,9 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta $phpcsFile->fixer->addContentBefore($commentToken, $padding); } } - }//end foreach - }//end if - }//end foreach + } + } + } $realNames = []; foreach ($realParams as $realParam) { diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php index 616e25f963..d2fffa20ef 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php @@ -119,7 +119,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } if ($tokens[$i]['line'] !== $prevLine) { if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) { @@ -130,10 +130,10 @@ public function process(File $phpcsFile, int $stackPtr) // Closing brace needs to be indented to the same level // as the statement. $expectedIndent = $statementIndent; - }//end if + } } else { $expectedIndent = ($statementIndent + $this->indent); - }//end if + } if ($tokens[$i]['code'] === T_COMMENT || isset(Tokens::PHPCS_ANNOTATION_TOKENS[$tokens[$i]['code']]) === true @@ -197,11 +197,11 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } $prevLine = $tokens[$i]['line']; - }//end if + } if (isset(Tokens::NAME_TOKENS[$tokens[$i]['code']]) === true) { $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); @@ -213,7 +213,7 @@ public function process(File $phpcsFile, int $stackPtr) continue; } } - }//end for + } // From here on, we are checking the spacing of the opening and closing // braces. If this IF statement does not use braces, we end here. diff --git a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php index 2c711812c7..fb98247b76 100644 --- a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php +++ b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php @@ -127,6 +127,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken($stackPtr, 'require'); } } - }//end if + } } } diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index cbedac50f4..d3d6048947 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -239,7 +239,7 @@ public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openB } } } - }//end if + } // Checking this: $value = my_function(...[*]). $spaceBeforeClose = 0; @@ -303,9 +303,9 @@ public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openB $phpcsFile->fixer->endChangeset(); } else { $phpcsFile->fixer->replaceToken(($closer - 1), $padding); - }//end if - }//end if - }//end if + } + } + } } @@ -388,7 +388,7 @@ public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBr $phpcsFile->fixer->replaceToken(($first - 1), $padding); } } - }//end if + } $next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($openBracket + 1), null, true); if ($tokens[$next]['line'] === $tokens[$openBracket]['line']) { @@ -442,7 +442,7 @@ public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBr $phpcsFile->fixer->endChangeset(); } - }//end if + } $i = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($openBracket + 1), null, true); @@ -567,17 +567,17 @@ public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBr } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } } else { $nextCode = $i; - }//end if + } if ($inArg === false) { $argStart = $nextCode; $argEnd = $phpcsFile->findEndOfStatement($nextCode, [T_COLON]); } - }//end if + } // If we are within an argument we should be ignoring commas // as these are not signalling the end of an argument. @@ -609,11 +609,11 @@ public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBr $phpcsFile->fixer->endChangeset(); } } - }//end if + } $argStart = $next; $argEnd = $phpcsFile->findEndOfStatement($next, [T_COLON]); - }//end if - }//end for + } + } } } diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 53dfa7c3dc..ab1059df4f 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -86,7 +86,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } // Must be no space before the opening parenthesis. For closures, this is // enforced by the previous check because there is no content between the keywords @@ -135,9 +135,9 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if - }//end if + } + } + } // Must be one space before and after USE keyword for closures. if ($tokens[$stackPtr]['code'] === T_CLOSURE) { @@ -184,8 +184,8 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } if ($this->isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) === true) { $this->processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens); @@ -327,11 +327,11 @@ public function processMultiLineDeclaration(File $phpcsFile, int $stackPtr, arra } $phpcsFile->fixer->endChangeset(); - }//end if + } return; - }//end if - }//end if + } + } $prev = $tokens[($opener - 1)]; if ($prev['code'] !== T_WHITESPACE) { @@ -431,8 +431,8 @@ public function processArgumentList(File $phpcsFile, int $stackPtr, int $indent, $phpcsFile->fixer->addNewlineBefore($closeBracket); } } - }//end if - }//end if + } + } // Each line between the parenthesis should be indented 4 spaces. $openBracket = $tokens[$stackPtr]['parenthesis_opener']; @@ -490,7 +490,7 @@ public function processArgumentList(File $phpcsFile, int $stackPtr, int $indent, } $lastLine = $tokens[$i]['line']; - }//end if + } if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_closer']) === true @@ -523,6 +523,6 @@ public function processArgumentList(File $phpcsFile, int $stackPtr, int $indent, $lastLine = $tokens[$i]['line']; continue; } - }//end for + } } } diff --git a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php index dee42547f9..43e7782356 100644 --- a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php @@ -72,6 +72,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->addError($error, $param['token'], 'NotAtEnd'); return; } - }//end foreach + } } } diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php index 126be891e1..00f994a0ac 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -89,6 +89,6 @@ public function process(File $phpcsFile, int $stackPtr) $data[] = $newName; $phpcsFile->addError($error, $stackPtr, 'Invalid', $data); } - }//end if + } } } diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index 510b0b648f..c82879af92 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -168,7 +168,7 @@ public function process(File $phpcsFile, int $stackPtr) } $previousIndent = $expectedIndent; - }//end if + } // It cant be the last thing on the line either. $content = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); @@ -185,13 +185,13 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } $next = $phpcsFile->findNext( self::TARGET_TOKENS, ($next + 1), $end ); - }//end while + } } } diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index c50032ae1f..e2cb7ad915 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -163,7 +163,7 @@ public function process(File $phpcsFile, int $stackPtr) ]; $fix = $phpcsFile->addFixableError($error, $scopeEnd, 'Indent', $data); } - }//end if + } if ($fix === true) { $spaces = str_repeat(' ', $expectedIndent); diff --git a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php index 76f7bed5fd..5cc6c8f2aa 100644 --- a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php @@ -71,7 +71,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php index f409dfb858..c858eecc00 100644 --- a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php @@ -65,7 +65,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -90,6 +90,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index ad1c003af1..3f38f50882 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -59,7 +59,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -86,6 +86,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php index 5c5d738410..d745c4a08f 100644 --- a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php @@ -103,7 +103,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index ca18221af0..8316a2653a 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -117,7 +117,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 87282cb5d3..d00e3033ca 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -139,7 +139,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php index 1c6d8a5ba4..00b69b5b4e 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -50,7 +50,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php index 36fdb52240..a58c358db0 100644 --- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php @@ -230,7 +230,7 @@ private function searchForConflict(File $phpcsFile, int $start, int $end, array continue; } - }//end if + } // Special case for defined() as it can be used to see // if a constant (a symbol) should be defined or not and @@ -254,7 +254,7 @@ private function searchForConflict(File $phpcsFile, int $start, int $end, array continue; } } - }//end if + } // Conditional statements are allowed in symbol files as long as the // contents is only a symbol definition. So don't count these as effects @@ -290,7 +290,7 @@ private function searchForConflict(File $phpcsFile, int $start, int $end, array $i = $tokens[$i]['scope_closer']; continue; - }//end if + } if ($firstEffect === null) { $firstEffect = $i; @@ -300,7 +300,7 @@ private function searchForConflict(File $phpcsFile, int $start, int $end, array // We have a conflict we have to report, so no point continuing. break; } - }//end for + } return [ 'symbol' => $firstSymbol, diff --git a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php index 1989098890..0668f5c522 100644 --- a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +++ b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php @@ -76,6 +76,6 @@ public function getWarningList($testFile = '') return [1 => 1]; default: return []; - }//end switch + } } } diff --git a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php index e5db7a575a..4653512cea 100644 --- a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php +++ b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php @@ -49,7 +49,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php index 20cd4dfb9a..6ae825b62b 100644 --- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php @@ -129,7 +129,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } } @@ -213,9 +213,9 @@ public function processSingleLineArgumentList(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } else { $phpcsFile->fixer->replaceToken(($closeBracket - 1), ''); - }//end if - }//end if - }//end if + } + } + } } diff --git a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php index 963bed27c8..512b9c888a 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php @@ -81,7 +81,7 @@ public function process(File $phpcsFile, int $stackPtr) $classNameEnd = $i; break; - }//end for + } if ($classNameEnd === null) { return; diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php index 9f16712d7e..53381ac0b1 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php @@ -200,7 +200,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addContent($prev, ' ' . $tokens[$operator]['content']); $phpcsFile->fixer->replaceToken($operator, ''); } - }//end if + } } else { if ($tokens[$prev]['line'] === $tokens[$operator]['line']) { if ($tokens[$next]['line'] === $tokens[$operator]['line']) { @@ -221,9 +221,9 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addContentBefore($next, $tokens[$operator]['content'] . ' '); $phpcsFile->fixer->replaceToken($operator, ''); } - }//end if - }//end if - }//end foreach + } + } + } $phpcsFile->fixer->endChangeset(); } diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index e996687cd2..597f105c1d 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -160,7 +160,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end for + } // Check the closing parenthesis. $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($parenCloser - 1), $parenOpener, true); @@ -188,8 +188,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if ($tokens[$parenCloser]['line'] !== $tokens[$prev]['line']) { $requiredIndent = ($tokens[$first]['column'] - 1); diff --git a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php index 82498a14c9..ded6d87f45 100644 --- a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php @@ -105,7 +105,7 @@ public function process(File $phpcsFile, int $stackPtr) $equals = $phpcsFile->findNext(T_EQUAL, ($equals + 1)); } } - }//end if + } // There should be no space between equal sign and directive value. $value = $phpcsFile->findNext(T_WHITESPACE, ($equals + 1), null, true); @@ -182,8 +182,8 @@ public function process(File $phpcsFile, int $stackPtr) if ($tokens[$token]['type'] === 'T_OPEN_CURLY_BRACKET') { $curlyBracket = $token; } - }//end if - }//end if + } + } if ($curlyBracket !== false) { $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBracket - 1), null, true); @@ -205,7 +205,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } $closeCurlyBracket = $tokens[$curlyBracket]['bracket_closer']; @@ -222,7 +222,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addNewline($prevToken); } } - }//end if + } // Closing curly bracket must align with the declare keyword. if ($tokens[$stackPtr]['column'] !== $tokens[$closeCurlyBracket]['column']) { @@ -253,6 +253,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } } } diff --git a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php index 3947a449b3..2748c3b124 100644 --- a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php @@ -109,7 +109,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->addError($error, $openTag, 'HeaderPosition'); } } - }//end if + } $this->processHeaderLines($phpcsFile, $possibleHeaders[$openTag]); @@ -207,7 +207,7 @@ public function getHeaderLines(File $phpcsFile, int $stackPtr) 'end' => $end, ]; } - }//end if + } $next = $end; break; @@ -265,7 +265,7 @@ public function getHeaderLines(File $phpcsFile, int $stackPtr) // We found the start of the main code block. break(2); - }//end switch + } $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); } while ($next !== false); @@ -318,8 +318,8 @@ public function processHeaderLines(File $phpcsFile, array $headerLines) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } // Make sure we haven't seen this next block before. if (isset($headerLines[($i + 1)]) === true @@ -357,13 +357,13 @@ public function processHeaderLines(File $phpcsFile, array $headerLines) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if (isset($found[$line['type']]) === false) { $found[$line['type']] = $line; } - }//end foreach + } /* Next, check that the order of the header blocks @@ -419,7 +419,7 @@ public function processHeaderLines(File $phpcsFile, array $headerLines) $blockOrder[$prevValidType], ]; $phpcsFile->addError($error, $found[$type]['start'], 'IncorrectOrder', $data); - }//end if - }//end foreach + } + } } } diff --git a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php index 800a829aee..b8b8435327 100644 --- a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php +++ b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php @@ -76,6 +76,6 @@ public function process(File $phpcsFile, int $stackPtr) $depth = 1; } - }//end for + } } } diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index 9083c7a5ea..802c07e27a 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -92,7 +92,7 @@ public function process(File $phpcsFile, int $stackPtr) } break; - }//end for + } if ($tokens[$lastValidContent]['line'] !== ($tokens[$opener]['line'] + 1)) { $error = 'The first trait import statement must be declared on the first non-comment line after the %s opening brace'; @@ -130,14 +130,14 @@ public function process(File $phpcsFile, int $stackPtr) $lastValidContent = $i; } - }//end for + } $phpcsFile->fixer->endChangeset(); - }//end if + } } else { $phpcsFile->addError($error, $useToken, 'UseAfterBrace', $data); - }//end if - }//end if + } + } } else { // Make sure this use statement is not on the same line as the previous one. $prev = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($useToken - 1), null, true); @@ -171,10 +171,10 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if - }//end if - }//end if + } + } + } + } $error = 'Expected 1 space after USE in trait import statement; %s found'; if ($tokens[($useToken + 1)]['code'] !== T_WHITESPACE) { @@ -206,7 +206,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($useToken + 1), ' '); } } - }//end if + } // Check the formatting of the statement. if (isset($tokens[$useToken]['scope_opener']) === true) { @@ -251,7 +251,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } } 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. @@ -286,7 +286,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } } else { // Ensure use statements are grouped. $next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($end + 1), null, true); @@ -294,8 +294,8 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'Imported traits must be grouped together'; $phpcsFile->addError($error, $useTokens[($usePos + 1)], 'NotGrouped'); } - }//end if - }//end foreach + } + } return $tokens[$ooToken]['scope_closer']; } @@ -346,7 +346,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) } else { $phpcsFile->addError($error, $opener, 'OpenBraceNewLine'); } - }//end if + } $error = 'Expected 1 space before opening brace in trait import statement; %s found'; if ($tokens[($opener - 1)]['code'] !== T_WHITESPACE) { @@ -378,7 +378,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($opener - 1), ' '); } } - }//end if + } $next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($opener + 1), ($closer - 1), true); if ($next !== false && $tokens[$next]['line'] !== ($tokens[$opener]['line'] + 1)) { @@ -403,7 +403,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } for ($i = ($stackPtr + 1); $i < $opener; $i++) { if ($tokens[$i]['code'] !== T_COMMA) { @@ -449,8 +449,8 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($i + 1), ' '); } } - }//end if - }//end for + } + } for ($i = ($opener + 1); $i < $closer; $i++) { if ($tokens[$i]['code'] === T_INSTEADOF) { @@ -490,7 +490,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) } } } - }//end if + } $error = 'Expected 1 space after INSTEADOF in trait import statement; %s found'; if ($tokens[($i + 1)]['code'] !== T_WHITESPACE) { @@ -528,8 +528,8 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } if ($tokens[$i]['code'] === T_AS) { $error = 'Expected 1 space before AS in trait import statement; %s found'; @@ -568,7 +568,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) } } } - }//end if + } $error = 'Expected 1 space after AS in trait import statement; %s found'; if ($tokens[($i + 1)]['code'] !== T_WHITESPACE) { @@ -606,8 +606,8 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } if ($tokens[$i]['code'] === T_SEMICOLON) { if ($tokens[($i - 1)]['code'] === T_WHITESPACE) { @@ -638,8 +638,8 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end for + } + } $prev = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($closer - 1), ($opener + 1), true); if ($prev !== false && $tokens[$prev]['line'] !== ($tokens[$closer]['line'] - 1)) { @@ -664,7 +664,7 @@ protected function processUseGroup(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } } diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php index 8edad0b17b..f05556d5a0 100644 --- a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php @@ -61,7 +61,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php index d497f7b75e..1683367cfd 100644 --- a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php @@ -64,7 +64,7 @@ public function getErrorList($testFile = '') return [4 => 2]; default: return []; - }//end switch + } } diff --git a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php index eb9e0e107c..aac0c20b12 100644 --- a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php @@ -37,7 +37,7 @@ public function getErrorList($testFile = '') return [1 => 1]; default: return []; - }//end switch + } } diff --git a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php index d33849be67..29a88becfa 100644 --- a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php @@ -58,7 +58,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index bdace2de13..608ea515e9 100644 --- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -115,8 +115,8 @@ public function processOpen(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } // We'll need the indent of the class/interface declaration for later. $classIndent = 0; @@ -174,7 +174,7 @@ public function processOpen(File $phpcsFile, int $stackPtr) } } } - }//end if + } // Check after the class/interface name. if ($className !== null @@ -244,7 +244,7 @@ public function processOpen(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if + } } else { // Check the whitespace before. Whitespace after is checked // later by looking at the whitespace before the first class name @@ -258,9 +258,9 @@ public function processOpen(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($keyword - 1), ' '); } } - }//end if - }//end if - }//end foreach + } + } + } // Check each of the extends/implements class names. If the extends/implements // keyword is the last content on the line, it means we need to check for @@ -393,7 +393,7 @@ public function processOpen(File $phpcsFile, int $stackPtr) } } } - }//end if + } } else { if ($tokens[($className - 1)]['code'] === T_COMMA) { $error = 'Expected 1 space before "%s"; 0 found'; @@ -430,9 +430,9 @@ public function processOpen(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addContent($prev, ' '); } } - }//end if - }//end if - }//end if + } + } + } if ($checkingImplements === true && $tokens[($className + 1)]['code'] !== T_COMMA @@ -457,8 +457,8 @@ public function processOpen(File $phpcsFile, int $stackPtr) $nextComma = $phpcsFile->findNext(T_COMMA, $className); } else { $nextComma = ($className + 1); - }//end if - }//end foreach + } + } } @@ -497,7 +497,7 @@ public function processClose(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } if ($tokens[$stackPtr]['code'] !== T_ANON_CLASS) { // Check the closing brace is on it's own line, but allow diff --git a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php index c1965c6806..4e95ebbec8 100644 --- a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php @@ -119,8 +119,8 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } if ($propertyInfo['scope_specified'] === false && $propertyInfo['set_scope'] === false) { $error = 'Visibility must be declared on property "%s"'; @@ -176,7 +176,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) } $firstVisibilityModifier = min($scopePtr, $setScopePtr); - }//end if + } if ($hasVisibilityModifier === true && $propertyInfo['is_final'] === true) { $scopePtr = $firstVisibilityModifier; @@ -201,7 +201,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } if ($hasVisibilityModifier === true && $propertyInfo['is_abstract'] === true) { $scopePtr = $firstVisibilityModifier; @@ -226,7 +226,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } if ($hasVisibilityModifier === true && $propertyInfo['is_static'] === true) { $scopePtr = $lastVisibilityModifier; @@ -251,7 +251,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } if ($hasVisibilityModifier === true && $propertyInfo['is_readonly'] === true) { $scopePtr = $lastVisibilityModifier; @@ -276,7 +276,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } } diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index c8276fb91b..4668ce9604 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -105,7 +105,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($parenCloser - 1), $parenOpener, true); if ($tokens[$prev]['line'] === $tokens[$parenCloser]['line']) { @@ -132,6 +132,6 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } } } diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 218787bded..b3693c0909 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -153,8 +153,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if ($tokens[$nextCloser]['scope_condition'] === $nextCase) { // Only need to check some things once, even if the @@ -181,8 +181,8 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } } else { $error = strtoupper($type) . ' statements must be defined using a colon'; if ($tokens[$opener]['code'] === T_SEMICOLON) { @@ -194,7 +194,7 @@ public function process(File $phpcsFile, int $stackPtr) // Probably a case/default statement with colon + curly braces. $phpcsFile->addError($error, $nextCase, 'WrongOpener' . $type); } - }//end if + } // We only want cases from here on in. if ($type !== 'case') { @@ -219,7 +219,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end while + } } @@ -375,7 +375,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end) if ($hasTerminator === false) { return false; } - }//end while + } // If we have not encountered a DEFAULT block by now, we cannot // be sure that the whole statement terminates in every case. @@ -386,7 +386,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end) return $hasTerminator; } else { return false; - }//end if + } } while ($currentCloser !== false && $tokens[$currentCloser]['code'] === T_CLOSE_CURLY_BRACKET); return true; @@ -397,7 +397,7 @@ private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end) if (isset(self::CASE_TERMINATING_TOKENS[$tokens[$terminator]['code']]) === true) { return $terminator; } - }//end if + } return false; } diff --git a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php index 04b2d1329d..50a4f87cc6 100644 --- a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php @@ -77,7 +77,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at end of PHP-only file', 'yes'); } else { $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at end of PHP-only file', 'no'); - }//end if + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php index dcd102a4f9..9f4015fab7 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -163,10 +163,10 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if - }//end if - }//end if + } + } + } + } // Make sure this USE comes after the first namespace declaration. $prev = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1)); @@ -259,7 +259,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } } diff --git a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php index 003e1148e8..4a87a6e66f 100644 --- a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php @@ -88,7 +88,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -116,6 +116,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php index 7e3a38eebf..fa0851c48c 100644 --- a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php @@ -46,7 +46,7 @@ public function getErrorList($testFile = '') return [1 => 1]; default: return []; - }//end switch + } } diff --git a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php index b617a7f9be..ad8e589f69 100644 --- a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php @@ -54,7 +54,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -83,6 +83,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php index a855c03262..55a6826c9c 100644 --- a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php @@ -79,7 +79,7 @@ public function getErrorList($testFile = '') ]; default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index 6350acc688..2b826cf30e 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -115,7 +115,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'yes'); $arrayStart = $stackPtr; $arrayEnd = $tokens[$stackPtr]['bracket_closer']; - }//end if + } // Check for empty arrays. $content = $phpcsFile->findNext(T_WHITESPACE, ($arrayStart + 1), ($arrayEnd + 1), true); @@ -190,7 +190,7 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arra } } } - }//end for + } // Now check each of the double arrows (if any). $nextArrow = $arrayStart; @@ -218,7 +218,7 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arra $phpcsFile->fixer->replaceToken(($nextArrow - 1), ' '); } } - }//end if + } if ($tokens[($nextArrow + 1)]['code'] !== T_WHITESPACE) { $content = $tokens[($nextArrow + 1)]['content']; @@ -243,8 +243,8 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arra $phpcsFile->fixer->replaceToken(($nextArrow + 1), ' '); } } - }//end if - }//end while + } + } if ($valueCount > 0) { $nestedParenthesis = false; @@ -300,7 +300,7 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arra $phpcsFile->fixer->replaceToken(($comma + 1), ' '); } } - }//end if + } if ($tokens[($comma - 1)]['code'] === T_WHITESPACE) { $content = $tokens[($comma - 2)]['content']; @@ -316,8 +316,8 @@ public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arra $phpcsFile->fixer->replaceToken(($comma - 1), ''); } } - }//end foreach - }//end if + } + } } @@ -369,7 +369,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array $phpcsFile->fixer->replaceToken(($arrayEnd - 1), str_repeat(' ', $expected)); } } - }//end if + } $keyUsed = false; $singleUsed = false; @@ -422,7 +422,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } continue; - }//end if + } if ($tokens[$nextToken]['code'] !== T_DOUBLE_ARROW && $tokens[$nextToken]['code'] !== T_COMMA) { continue; @@ -488,7 +488,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array $phpcsFile->addError($error, $nextToken, 'SpaceBeforeComma', $data); } } - }//end if + } $valueContent = $phpcsFile->findNext( Tokens::EMPTY_TOKENS, @@ -508,11 +508,11 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array // Don't decide if an array is key => value indexed or not when PHP 7.4+ array unpacking is used. $singleUsed = true; } - }//end if + } $lastToken = $nextToken; continue; - }//end if + } if ($tokens[$nextToken]['code'] === T_DOUBLE_ARROW) { if ($singleUsed === true) { @@ -557,8 +557,8 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array $currentEntry['value'] = $nextContent; $indices[] = $currentEntry; $lastToken = $nextToken; - }//end if - }//end for + } + } // Check for multi-line arrays that should be single-line. $singleValue = false; @@ -616,8 +616,8 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } return; - }//end if - }//end if + } + } /* This section checks for arrays that don't specify keys. @@ -725,9 +725,9 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } } } - }//end if - }//end foreach - }//end if + } + } + } /* Below the actual indentation of the array is checked. @@ -818,7 +818,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array $phpcsFile->fixer->replaceToken(($indexPointer - 1), str_repeat(' ', $expected)); } } - }//end if + } $arrowStart = ($tokens[$indexPointer]['column'] + $maxLength + 1); if ($tokens[$index['arrow']]['column'] !== $arrowStart) { @@ -846,7 +846,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } continue; - }//end if + } $valueStart = ($arrowStart + 3); if ($tokens[$valuePointer]['column'] !== $valueStart) { @@ -885,7 +885,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array $phpcsFile->fixer->replaceToken(($valuePointer - 1), str_repeat(' ', $expected)); } } - }//end if + } // Check each line ends in a comma. $valueStart = $valuePointer; @@ -930,7 +930,7 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array $phpcsFile->fixer->endChangeset(); } - }//end if + } // Check that there is no space before the comma. if ($nextComma !== false && $tokens[($nextComma - 1)]['code'] === T_WHITESPACE) { @@ -951,6 +951,6 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $array } } } - }//end foreach + } } } diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php index 448a17bed4..bdc85ccc7f 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php @@ -80,8 +80,8 @@ public function processOpen(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } } @@ -162,7 +162,7 @@ public function processClose(File $phpcsFile, int $stackPtr) } } } - }//end if + } if ($difference !== -1 && $difference !== 1) { for ($nextSignificant = $nextContent; $nextSignificant < $phpcsFile->numTokens; $nextSignificant++) { @@ -214,6 +214,6 @@ public function processClose(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if + } } } diff --git a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php index a3c50f3035..18d502e3f0 100644 --- a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php @@ -113,9 +113,9 @@ protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $ // Fix potential whitespace issues in the next loop. return; - }//end if - }//end if - }//end if + } + } + } if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { $found = $tokens[($stackPtr - 1)]['length']; diff --git a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php index 45a7e6e00a..5d7956aeea 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php @@ -118,7 +118,7 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if + } $commentLines = [$stackPtr]; $nextComment = $stackPtr; @@ -147,7 +147,7 @@ public function process(File $phpcsFile, int $stackPtr) ) { break; } - }//end while + } $commentText = str_replace($phpcsFile->eolChar, '', $commentString); $commentText = trim($commentText, "/* \t"); @@ -210,7 +210,7 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if + } $starColumn = $tokens[$stackPtr]['column']; $hasStars = false; @@ -260,13 +260,13 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken($commentLines[1], $padding . $commentText); } - }//end if + } if (preg_match('/^\p{Ll}/u', $commentText) === 1) { $error = 'Block comments must start with a capital letter'; $phpcsFile->addError($error, $commentLines[1], 'NoCapital'); } - }//end if + } // Check that each line of the comment is indented past the star. foreach ($commentLines as $line) { @@ -320,8 +320,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken($line, $padding . $commentText); } - }//end if - }//end foreach + } + } // Finally, test the last line is correct. $lastIndex = (count($commentLines) - 1); @@ -364,8 +364,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken($commentLines[$lastIndex], $padding . $commentText); } - }//end if - }//end if + } + } // Check that the lines before and after this comment are blank. $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index c27bc32125..8aeffb1bc4 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -80,7 +80,7 @@ public function process(File $phpcsFile, int $stackPtr) $comment = '//end trait'; } else { $comment = '//end enum'; - }//end if + } if (isset($tokens[$stackPtr]['scope_closer']) === false) { // Parse error or live coding. @@ -114,7 +114,7 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if + } if (rtrim($tokens[($closingBracket + 1)]['content']) !== $comment) { $fix = $phpcsFile->addFixableError('Expected %s', $closingBracket, 'Incorrect', $data); diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index f3514a5b91..dc37af88e2 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -111,7 +111,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($i - 1), $padding); } } - }//end if + } if ($tokens[$i]['code'] !== T_DOC_COMMENT_STAR) { continue; @@ -138,6 +138,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($i + 1), ' '); } } - }//end for + } } } diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php index 22718c1987..147f173472 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php @@ -183,8 +183,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken($string, $expected); } } - }//end if - }//end foreach + } + } // Check if the tags are in the correct position. $pos = 0; @@ -209,7 +209,7 @@ public function process(File $phpcsFile, int $stackPtr) } $pos++; - }//end foreach + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index ae74f13ec1..bdc5043710 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -142,7 +142,7 @@ protected function processReturn(File $phpcsFile, int $stackPtr, int $commentSta $phpcsFile->addError($error, $return, 'InvalidReturnVoid'); } } - }//end if + } } elseif ($returnType !== 'mixed' && $returnType !== 'never' && in_array('void', $typeNames, true) === false @@ -177,9 +177,9 @@ protected function processReturn(File $phpcsFile, int $stackPtr, int $commentSta $phpcsFile->addError($error, $returnToken, 'InvalidReturnNotVoid'); } } - }//end if - }//end if - }//end if + } + } + } } else { if ($isSpecialMethod === true) { return; @@ -187,7 +187,7 @@ protected function processReturn(File $phpcsFile, int $stackPtr, int $commentSta $error = 'Missing @return tag in function comment'; $phpcsFile->addError($error, $tokens[$commentStart]['comment_closer'], 'MissingReturn'); - }//end if + } } @@ -261,8 +261,8 @@ protected function processThrows(File $phpcsFile, int $stackPtr, int $commentSta $error = '@throws tag comment must end with a full stop'; $phpcsFile->addError($error, ($tag + 2), 'ThrowsNoFullStop'); } - }//end if - }//end foreach + } + } } @@ -366,15 +366,15 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta $error = 'Missing parameter comment'; $phpcsFile->addError($error, $tag, 'MissingParamComment'); $commentLines[] = ['comment' => '']; - }//end if + } } else { $error = 'Missing parameter name'; $phpcsFile->addError($error, $tag, 'MissingParamName'); - }//end if + } } else { $error = 'Missing parameter type'; $phpcsFile->addError($error, $tag, 'MissingParamType'); - }//end if + } $params[] = [ 'tag' => $tag, @@ -385,7 +385,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta 'type_space' => $typeSpace, 'var_space' => $varSpace, ]; - }//end foreach + } $realParams = $phpcsFile->getMethodParameters($stackPtr); $foundParams = []; @@ -492,7 +492,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta $param['var'], ]; $phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data); - }//end if + } } elseif ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) { $typeHint = $realParams[$pos]['type_hint']; if ($typeHint !== '') { @@ -503,8 +503,8 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta ]; $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint', $data); } - }//end if - }//end foreach + } + } $suggestedType = implode('|', $suggestedTypeNames); if ($param['type'] !== $suggestedType) { @@ -545,8 +545,8 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } if ($param['var'] === '') { continue; @@ -598,12 +598,12 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta $error .= 'actual variable name %s'; $phpcsFile->addError($error, $param['tag'], $code, $data); - }//end if + } } elseif (substr($param['var'], -4) !== ',...') { // We must have an extra parameter comment. $error = 'Superfluous parameter comment'; $phpcsFile->addError($error, $param['tag'], 'ExtraParamComment'); - }//end if + } if ($param['comment'] === '') { continue; @@ -623,7 +623,7 @@ protected function processParams(File $phpcsFile, int $stackPtr, int $commentSta $error = 'Parameter comment must end with a full stop'; $phpcsFile->addError($error, $param['tag'], 'ParamCommentFullStop'); } - }//end foreach + } $realNames = []; foreach ($realParams as $realParam) { @@ -693,8 +693,8 @@ protected function checkSpacingAfterParamType(File $phpcsFile, array $param, int } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } } @@ -751,8 +751,8 @@ protected function checkSpacingAfterParamName(File $phpcsFile, array $param, int } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } } diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php index a873b79c3e..1cddd29dd7 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php @@ -158,7 +158,7 @@ public function process(File $phpcsFile, int $stackPtr) } } else { ++$unknownCount; - }//end if + } } while ($currPos < $stackPtrEnd && $currPos !== false); if ($foundThrows === false) { diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index 575f1cb20d..5aab7b075e 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -110,7 +110,7 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead'; $phpcsFile->addError($error, $stackPtr, 'DocBlock'); } - }//end if + } if ($tokens[$stackPtr]['content'][0] === '#') { $error = 'Perl-style comments are not allowed; use "// Comment" instead'; @@ -159,7 +159,7 @@ public function process(File $phpcsFile, int $stackPtr) $commentTokens[] = $nextComment; $lastComment = $nextComment; - }//end while + } $commentText = ''; foreach ($commentTokens as $lastCommentToken) { @@ -209,7 +209,7 @@ public function process(File $phpcsFile, int $stackPtr) $comment, ]; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'SpacingBefore', $data); - }//end if + } if ($fix === true) { $newComment = '// ' . ltrim($tokens[$lastCommentToken]['content'], "/\t "); @@ -217,7 +217,7 @@ public function process(File $phpcsFile, int $stackPtr) } $commentText .= trim(substr($tokens[$lastCommentToken]['content'], 2)); - }//end foreach + } if ($commentText === '') { $error = 'Blank comments are not allowed'; @@ -305,7 +305,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } return ($lastCommentToken + 1); } diff --git a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index fffd476700..639a0024e3 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -124,9 +124,9 @@ public function process(File $phpcsFile, int $stackPtr) $endBrace = $tokens[$stackPtr]; } else { break; - }//end if + } } while (isset($tokens[$nextToken]['scope_closer']) === true); - }//end if + } if ($startCondition['code'] === T_TRY) { // TRY statements need to check until the end of all CATCH statements. diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 621c854007..62d9428b81 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -113,8 +113,8 @@ public function processMemberVar(File $phpcsFile, int $stackPtr) $data = [$tokens[$tag]['content']]; $code = ucwords(ltrim($tokens[$tag]['content'], '@')) . 'TagNotAllowed'; $phpcsFile->addWarning($error, $tag, $code, $data); - }//end if - }//end foreach + } + } // The @var tag is the only one we require. if ($foundVar === null) { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index c1e20ed711..f25775dec4 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -115,7 +115,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), str_repeat(' ', $expected)); } } - }//end if + } // Single space after closing parenthesis. if (isset($tokens[$stackPtr]['parenthesis_closer']) === true @@ -182,10 +182,10 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if - }//end if - }//end if + } + } + } + } // Single newline after opening brace. if (isset($tokens[$stackPtr]['scope_opener']) === true) { @@ -211,7 +211,7 @@ public function process(File $phpcsFile, int $stackPtr) // We found the first bit of a code, or a comment on the // following line. break; - }//end for + } if ($tokens[$next]['line'] === $tokens[$opener]['line']) { $error = 'Newline required after opening brace'; @@ -230,7 +230,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addContent($opener, $phpcsFile->eolChar); $phpcsFile->fixer->endChangeset(); } - }//end if + } } elseif ($tokens[$stackPtr]['code'] === T_WHILE) { // Zero spaces after parenthesis closer, but only if followed by a semicolon. $closer = $tokens[$stackPtr]['parenthesis_closer']; @@ -254,7 +254,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } // Only want to check multi-keyword structures from here on. if ($tokens[$stackPtr]['code'] === T_WHILE) { @@ -288,7 +288,7 @@ public function process(File $phpcsFile, int $stackPtr) } } else { return; - }//end if + } // Single space after closing brace. $found = 1; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php index f2f7aac293..a88f619073 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php @@ -97,7 +97,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } if ($this->requiredSpacesBeforeClose === 0 && $tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) { $error = 'Space found before closing bracket of FOREACH loop'; @@ -127,7 +127,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } $asToken = $phpcsFile->findNext(T_AS, $openingBracket); if ($asToken === false) { @@ -188,7 +188,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } if ($tokens[($asToken - 1)]['code'] !== T_WHITESPACE) { $error = 'Expected 1 space before "as"; 0 found'; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index 68ef309a3c..89f60958f0 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -127,8 +127,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if - }//end if + } + } $prevNonWhiteSpace = $phpcsFile->findPrevious(T_WHITESPACE, ($closingBracket - 1), $openingBracket, true); $beforeClosefixable = true; @@ -199,8 +199,8 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } /* * Check whitespace around each of the semicolon tokens. @@ -294,8 +294,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if - }//end if + } + } } while ($semicolonCount < 2); } } diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php index 670b64574a..00e7129f04 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php @@ -131,7 +131,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($inlineElse + 1), null, true); $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1)); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 4e5bce884f..9f0c77d8fd 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -201,14 +201,14 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } - }//end if + } } else { // Ensure the BREAK statement is not followed by a blank line. if ($nextLine !== ($tokens[$semicolon]['line'] + 1)) { $error = 'Blank lines are not allowed after the DEFAULT case\'s breaking statement'; $phpcsFile->addError($error, $nextBreak, 'SpacingAfterDefaultBreak'); } - }//end if + } $caseLine = $tokens[$nextCase]['line']; $nextLine = $tokens[$nextBreak]['line']; @@ -223,7 +223,7 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'Blank lines are not allowed after ' . strtoupper($type) . ' statements'; $phpcsFile->addError($error, $nextCase, 'SpacingAfter' . $type); } - }//end if + } if ($tokens[$nextBreak]['code'] === T_BREAK) { if ($type === 'Case') { @@ -264,13 +264,13 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'Comment required for empty DEFAULT case'; $phpcsFile->addError($error, $nextCase, 'EmptyDefault'); } - }//end if - }//end if + } + } } elseif ($type === 'Default') { $error = 'DEFAULT case must have a breaking statement'; $phpcsFile->addError($error, $nextCase, 'DefaultNoBreak'); - }//end if - }//end while + } + } if ($foundDefault === false) { $error = 'All SWITCH statements must contain a DEFAULT case'; diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php index a439fc5559..674ef28a1f 100644 --- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php @@ -76,7 +76,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if + } $previousToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true, null, true); if ($previousToken !== false) { @@ -183,7 +183,7 @@ public function process(File $phpcsFile, int $stackPtr) if ($next !== $endBracket) { break; } - }//end if + } if (in_array($prevCode, Tokens::SCOPE_OPENERS, true) === true) { // This operation is inside a control structure like FOREACH @@ -204,8 +204,8 @@ public function process(File $phpcsFile, int $stackPtr) $lastBracket = $bracket; break; - }//end foreach - }//end if + } + } if ($lastBracket === false) { // It is not in a bracketed statement at all. @@ -233,7 +233,7 @@ public function process(File $phpcsFile, int $stackPtr) } return; - }//end if + } $lastAssignment = $phpcsFile->findPrevious(Tokens::ASSIGNMENT_TOKENS, $stackPtr, null, false, null, true); if ($lastAssignment !== false && $lastAssignment > $lastBracket) { @@ -300,7 +300,7 @@ public function addMissingBracketsError(File $phpcsFile, int $stackPtr) } break; - }//end for + } $before = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($before + 1), null, true); @@ -342,7 +342,7 @@ public function addMissingBracketsError(File $phpcsFile, int $stackPtr) } break; - }//end for + } $after = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($after - 1), null, true); diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php index bb645efa77..9182734fc4 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php @@ -134,8 +134,8 @@ public function processBracket(File $phpcsFile, int $openBracket) // No params, so we don't check normal spacing rules. return; - }//end if - }//end if + } + } foreach ($params as $paramNumber => $param) { if ($param['pass_by_reference'] === true) { @@ -161,8 +161,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if ($param['variable_length'] === true) { $variadicToken = $param['variadic_token']; @@ -187,8 +187,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if (isset($param['default_equal_token']) === true) { $equalToken = $param['default_equal_token']; @@ -225,7 +225,7 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } } - }//end if + } $spacesAfter = 0; if ($tokens[$equalToken]['line'] !== $tokens[$param['default_token']]['line']) { @@ -259,8 +259,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } } - }//end if - }//end if + } + } if ($param['type_hint_token'] !== false) { $typeHintToken = $param['type_hint_end_token']; @@ -295,8 +295,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if (isset($param['visibility_token']) === true && $param['visibility_token'] !== false) { $visibilityToken = $param['visibility_token']; @@ -329,8 +329,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if (isset($param['set_visibility_token']) === true && $param['set_visibility_token'] !== false) { $visibilityToken = $param['set_visibility_token']; @@ -363,8 +363,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } if (isset($param['readonly_token']) === true) { $readonlyToken = $param['readonly_token']; @@ -394,8 +394,8 @@ public function processBracket(File $phpcsFile, int $openBracket) $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } $commaToken = false; if ($paramNumber > 0 && $params[($paramNumber - 1)]['comma_token'] !== false) { @@ -448,8 +448,8 @@ public function processBracket(File $phpcsFile, int $openBracket) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } // Don't check spacing after the comma if it is the last content on the line. $checkComma = true; @@ -506,10 +506,10 @@ public function processBracket(File $phpcsFile, int $openBracket) if ($fix === true) { $phpcsFile->fixer->replaceToken(($commaToken + 1), ' '); } - }//end if - }//end if - }//end if - }//end foreach + } + } + } + } // Only check spacing around parenthesis for single line definitions. if ($multiLine === true) { diff --git a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index b3fd17d094..9ae5960362 100644 --- a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -74,7 +74,7 @@ public function isMultiLineDeclaration(File $phpcsFile, int $stackPtr, int $open if ($next !== false && $tokens[$next]['line'] !== $tokens[$end]['line']) { return true; } - }//end foreach + } return false; } @@ -123,7 +123,7 @@ public function processSingleLineDeclaration(File $phpcsFile, int $stackPtr, arr $phpcsFile->fixer->endChangeset(); } } - }//end if + } } @@ -205,8 +205,8 @@ public function processBracket(File $phpcsFile, int $openBracket, array $tokens, $phpcsFile->fixer->endChangeset(); } } - }//end if - }//end if + } + } // Each line between the brackets should contain a single parameter. for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { @@ -238,6 +238,6 @@ public function processBracket(File $phpcsFile, int $openBracket, array $tokens, $phpcsFile->fixer->addNewline($i); } } - }//end for + } } } diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php index 0e946e9110..7659418bcc 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -62,9 +62,9 @@ protected function processVariable(File $phpcsFile, int $stackPtr) $data = [$originalVarName]; $phpcsFile->addError($error, $var, 'MemberNotCamelCaps', $data); } - }//end if - }//end if - }//end if + } + } + } $objOperator = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); if ($tokens[$objOperator]['code'] === T_DOUBLE_COLON) { diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index e7484cf006..6b34b6e4fc 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -107,8 +107,8 @@ public function process(File $phpcsFile, int $stackPtr) ) { break; } - }//end if - }//end for + } + } $start = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($i + 1), null, true); } else { @@ -117,7 +117,7 @@ public function process(File $phpcsFile, int $stackPtr) } $start = $tokens[$end]['parenthesis_opener']; - }//end if + } } elseif ($tokens[$stackPtr]['code'] === T_FOR) { if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) { return; @@ -138,7 +138,7 @@ public function process(File $phpcsFile, int $stackPtr) $start = $tokens[$stackPtr]['parenthesis_opener']; $end = $tokens[$stackPtr]['parenthesis_closer']; - }//end if + } $requiredOps = 0; $foundOps = 0; @@ -198,7 +198,7 @@ public function process(File $phpcsFile, int $stackPtr) if (isset(Tokens::EMPTY_TOKENS[$type]) === false) { $lastNonEmpty = $i; } - }//end for + } $requiredOps++; diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index dc5ea8bb67..dd5865b39f 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -220,6 +220,6 @@ protected function processAssignment(File $phpcsFile, int $stackPtr) $error .= " operators should be used where possible; found \"$found\" but expected \"$expected\""; $phpcsFile->addError($error, $stackPtr, 'Found'); - }//end if + } } } diff --git a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index 63f15f60bb..b3631844c6 100644 --- a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -127,7 +127,7 @@ public function process(File $phpcsFile, int $stackPtr) if (substr($tokenContent, 0, 1) === '*') { $tokenContent = substr($tokenContent, 1); } - }//end if + } $content .= $tokenContent . $phpcsFile->eolChar; $lastLineSeen = $tokens[$i]['line']; @@ -138,7 +138,7 @@ public function process(File $phpcsFile, int $stackPtr) // Closer of a block comment found. break; } - }//end for + } // Ignore typical warning suppression annotations from other tools. if (preg_match('`^\s*@[A-Za-z()\._-]+\s*$`', $content) === 1) { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php index 1f64d3d279..2f80c927c4 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php @@ -114,7 +114,7 @@ public function process(File $phpcsFile, int $stackPtr) // We found our variable. break; } - }//end for + } if ($varToken <= 0) { // Didn't find a variable. diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php index d00442c310..19a699d4ad 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php @@ -92,7 +92,7 @@ public function process(File $phpcsFile, int $stackPtr) $error = 'The use of %s inside a loop condition is not allowed; assign the return value to a variable and use the variable in the loop condition instead'; $data = [$functionName]; $phpcsFile->addError($error, $i, 'Found', $data); - }//end if - }//end for + } + } } } diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index e6ee2e893c..5240ca9e89 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -94,7 +94,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c $this->reportEmptyTagSet($phpcsFile, $stackPtr, $closingTag); return; } - }//end if + } if ($tokens[$firstContent]['line'] === $tokens[$stackPtr]['line']) { $error = 'Opening PHP tag must be on a line by itself'; @@ -142,7 +142,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c $phpcsFile->fixer->endChangeset(); } - }//end if + } $indent = $this->calculateLineIndent($phpcsFile, $stackPtr); $contentColumn = ($tokens[$firstContent]['column'] - 1); @@ -162,8 +162,8 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c } } } - }//end if - }//end if + } + } $lastContentBeforeBlock = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); if ($tokens[$lastContentBeforeBlock]['line'] === $tokens[$stackPtr]['line'] @@ -188,7 +188,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c } $phpcsFile->fixer->endChangeset(); - }//end if + } } else { // Find the first token on the first non-empty line we find. for ($first = ($lastContentBeforeBlock - 1); $first > 0; $first--) { @@ -214,7 +214,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c $phpcsFile->fixer->replaceToken(($stackPtr - 1), str_repeat(' ', $expected)); } } - }//end if + } if ($closingTag === false) { return; @@ -248,7 +248,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c $phpcsFile->fixer->addContentBefore($closingTag, str_repeat(' ', $closerIndent)); $phpcsFile->fixer->addNewlineBefore($closingTag); $phpcsFile->fixer->endChangeset(); - }//end if + } } elseif ($firstContentAfterBlock !== false && $tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line'] ) { @@ -281,8 +281,8 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } $next = $phpcsFile->findNext($this->register(), ($closingTag + 1)); if ($next === false) { @@ -317,7 +317,7 @@ private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $c $phpcsFile->fixer->endChangeset(); } - }//end if + } } @@ -395,8 +395,8 @@ private function validateInlineEmbeddedPhp(File $phpcsFile, int $stackPtr, int $ $data = [$statementCount]; $phpcsFile->addError($error, $stackPtr, 'MultipleStatements', $data); } - }//end if - }//end if + } + } $trailingSpace = 0; if ($tokens[($closeTag - 1)]['code'] === T_WHITESPACE) { diff --git a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php index cbd2f49bd1..ab385d6acb 100644 --- a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php @@ -118,7 +118,7 @@ public function process(File $phpcsFile, int $stackPtr) // No open parenthesis; not a "use function" statement nor a function call. return; - }//end if + } if ($tokens[$prev]['code'] === T_FUNCTION) { // Function declaration, not a function call. diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index 3449afc0c8..fb588efea5 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -91,7 +91,7 @@ public function process(File $phpcsFile, int $stackPtr) if ($tokens[$prev]['code'] === T_FN_ARROW) { return; } - }//end if + } // This token may be part of an inline condition. // If we find a closing parenthesis that belongs to a condition, @@ -160,12 +160,12 @@ public function process(File $phpcsFile, int $stackPtr) $lastLine = $line; } } - }//end if + } // That's all we have to check for these types of statements. return; - }//end if - }//end if + } + } $ourConditions = array_keys($tokens[$stackPtr]['conditions']); @@ -202,7 +202,7 @@ public function process(File $phpcsFile, int $stackPtr) break; } } - }//end for + } if ($nextOpener === null) { $end = $closer; @@ -217,7 +217,7 @@ public function process(File $phpcsFile, int $stackPtr) // Throw an error for all lines until the end of the file. $end = ($phpcsFile->numTokens - 1); - }//end if + } // Find the semicolon or closing PHP tag that ends this statement, // skipping nested statements like FOR loops and closures. @@ -243,7 +243,7 @@ public function process(File $phpcsFile, int $stackPtr) if ($tokens[$start]['code'] === T_SEMICOLON || $tokens[$start]['code'] === T_CLOSE_TAG) { break; } - }//end for + } if (isset($tokens[$start]) === false) { return; @@ -294,6 +294,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); $lastLine = $line; } - }//end for + } } } diff --git a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php index 9bead470f4..1b64bbd7f3 100644 --- a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php @@ -155,6 +155,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addContent($stackPtr, $padding); } } - }//end if + } } } diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index 0522a4f1bf..d13f345ad7 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -114,7 +114,7 @@ public function process(File $phpcsFile, int $stackPtr) } return $skipTo; - }//end if + } foreach (self::ESCAPE_CHARS as $testChar) { if (strpos($workingString, $testChar) !== false) { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index caac5450f3..134af926b2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -98,7 +98,7 @@ public function process(File $phpcsFile, int $stackPtr) } else { $phpcsFile->recordMetric($stackPtr, 'Spaces before control structure close parenthesis', 0); } - }//end if + } if (isset($tokens[$stackPtr]['scope_closer']) === false) { return; @@ -163,7 +163,7 @@ public function process(File $phpcsFile, int $stackPtr) } } else { $phpcsFile->recordMetric($stackPtr, 'Blank lines at start of control structure', 0); - }//end if + } if ($firstContent !== $scopeCloser) { $lastContent = $phpcsFile->findPrevious( @@ -220,8 +220,8 @@ public function process(File $phpcsFile, int $stackPtr) } } else { $phpcsFile->recordMetric($stackPtr, 'Blank lines at end of control structure', 0); - }//end if - }//end if + } + } if ($tokens[$stackPtr]['code'] === T_MATCH) { // Move the scope closer to the semicolon/comma. @@ -258,7 +258,7 @@ public function process(File $phpcsFile, int $stackPtr) ) { $trailingContent = $nextCode; } - }//end if + } if ($tokens[$trailingContent]['code'] === T_ELSE) { if ($tokens[$stackPtr]['code'] === T_IF) { @@ -340,6 +340,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->addNewline($scopeCloser); } } - }//end if + } } } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php index 6a3ed01111..9a6b4020c1 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php @@ -94,8 +94,8 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } } else { if ($found !== 1) { if ($found < 0) { @@ -124,7 +124,7 @@ public function process(File $phpcsFile, int $stackPtr) } } } - }//end if - }//end if + } + } } } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 93a9ce4f85..ef281d88f2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -240,8 +240,8 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if + } + } /* Check the number of blank lines @@ -312,8 +312,8 @@ public function process(File $phpcsFile, int $stackPtr) if ($currentLine === $prevLine) { break; } - }//end for - }//end if + } + } $requiredSpacing = $this->spacing; $errorCode = 'Before'; @@ -365,8 +365,8 @@ public function process(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if - }//end if - }//end if + } + } + } } } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php index f52e46680d..72eb95b9d6 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php @@ -144,7 +144,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) } $i = $nextNonWhitespace; - }//end for + } // There needs to be n blank lines before the var, not counting comments. if ($start === $startOfStatement) { @@ -222,7 +222,7 @@ protected function processMemberVar(File $phpcsFile, int $stackPtr) } $phpcsFile->fixer->endChangeset(); - }//end if + } if ($endOfStatement !== false) { return $endOfStatement; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index 7369d99437..bea4c0cded 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -169,7 +169,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); } } - }//end if + } $hasNext = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($hasNext === false) { @@ -204,10 +204,10 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); } } - }//end if + } return; - }//end if + } $operator = $tokens[$stackPtr]['content']; @@ -265,9 +265,9 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if - }//end if + } + } + } $hasNext = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($hasNext === false) { @@ -323,8 +323,8 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); } } - }//end if - }//end if + } + } } @@ -387,7 +387,7 @@ protected function isOperator(File $phpcsFile, int $stackPtr) if (isset($this->nonOperandTokens[$tokens[$prev]['code']]) === true) { return false; } - }//end if + } return true; } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 6de5671a3f..3ed5643c61 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -105,6 +105,6 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->substrToken(($lineStart - 1), 0, $diff); } } - }//end if + } } } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index d17795cf33..04f3b3bd72 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -87,7 +87,7 @@ public function process(File $phpcsFile, int $stackPtr) return; } } - }//end if + } if ($tokens[$prevToken]['code'] === T_AS) { // Trait visibility change, e.g., "use HelloWorld { sayHello as private; }". @@ -162,7 +162,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); $phpcsFile->fixer->endChangeset(); } - }//end if - }//end if + } + } } } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index 992fb567db..2b18ad77e2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -204,7 +204,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->fixer->endChangeset(); } } - }//end if - }//end if + } + } } } diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php index 520d133a7f..0742574146 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -239,7 +239,7 @@ public function getErrorList($testFile = '') return [8 => 1]; default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php index 7c63e9b200..b4a5bf7962 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php @@ -122,7 +122,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php index 4cfbfd8bd5..0f6e76abc5 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php @@ -50,7 +50,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -78,6 +78,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php index 677be56eae..8aee10cc88 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php @@ -61,7 +61,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index fdce790126..0e241d8043 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -58,7 +58,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index f0810924a5..146da86859 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -182,7 +182,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 6c44c2446c..ca83e0b232 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -88,7 +88,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index 0c00bc83c9..eb26c3d894 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -69,7 +69,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index 7455663593..746ab5c661 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -81,7 +81,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php index 5dbee0eb3b..680f8df4e9 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php @@ -105,7 +105,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php index 28fc70a889..075290bdc2 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php @@ -41,7 +41,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php index 1e7d15f504..b6d3b0db10 100644 --- a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php @@ -52,6 +52,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 0146ba433f..a62598012c 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -49,7 +49,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php index 9738a5cc0d..5c216bfb28 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -80,7 +80,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index 7cf4bbf765..da2938fe7e 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -218,7 +218,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php index 0a345f76cf..07989ccb15 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php @@ -41,7 +41,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index 6a7aa8dcbe..bdc16e1aa5 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -117,6 +117,6 @@ public function getWarningList($testFile = '') ]; default: return []; - }//end switch + } } } diff --git a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php index f77b956164..eca007101b 100644 --- a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php @@ -53,7 +53,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php index 25bdf18e3b..7d93b9024e 100644 --- a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php @@ -43,7 +43,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index a3ccc4ef1b..9a64cc7fee 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -127,7 +127,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php index 2288db1ea6..db2bf4d415 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php @@ -97,7 +97,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index 275d9e1339..c9e0b70a6c 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -114,7 +114,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index 2684993ab7..440d654515 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -81,7 +81,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index ccff6e3348..51636508bc 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -71,7 +71,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index 5de17450bf..cc4ca617d5 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -67,7 +67,7 @@ public function process(File $phpcsFile, int $stackPtr) $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'yes'); } else { $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'no'); - }//end if + } // Ignore the rest of the file. return $phpcsFile->numTokens; diff --git a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php index cdf6a4f418..5eb8b9c603 100644 --- a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -68,9 +68,9 @@ protected function processVariable(File $phpcsFile, int $stackPtr) $data = [$originalVarName]; $phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data); } - }//end if - }//end if - }//end if + } + } + } // There is no way for us to know if the var is public or private, // so we have to ignore a leading underscore if there is one and just @@ -187,7 +187,7 @@ protected function processVariableInString(File $phpcsFile, int $stackPtr) $data = [$varName]; $phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data); } - }//end foreach - }//end if + } + } } } diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php index 93359bee2b..8393f305fc 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -75,7 +75,7 @@ public function getErrorList($testFile = '') default: return []; - }//end switch + } } @@ -113,6 +113,6 @@ public function getWarningList($testFile = '') default: return []; - }//end switch + } } } diff --git a/src/Tokenizers/Comment.php b/src/Tokenizers/Comment.php index da6018dbb6..3ff5780f80 100644 --- a/src/Tokenizers/Comment.php +++ b/src/Tokenizers/Comment.php @@ -155,7 +155,7 @@ public function tokenizeString(string $comment, string $eolChar, int $stackPtr) $stackPtr++; } - }//end foreach + } $tokens[$stackPtr] = $closeTag; if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -224,7 +224,7 @@ private function processLine(string $comment, string $eolChar, int $start, int $ $start += strlen($space['content']); } } - }//end if + } // Process the rest of the line. $eol = strpos($comment, $eolChar, $start); diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 59c1c4b167..a8741c3ef8 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -586,7 +586,7 @@ protected function tokenize(string $code) $statusMessage .= ": $type => $content"; StatusWriter::write($statusMessage, 1, 0); - }//end if + } if ($newStackPtr > 0 && isset(Tokens::EMPTY_TOKENS[$finalTokens[($newStackPtr - 1)]['code']]) === false @@ -623,7 +623,7 @@ protected function tokenize(string $code) $tokens[($stackPtr + 1)][1] = substr($tokens[($stackPtr + 1)][1], 1); } } - }//end if + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::writeNewline(); @@ -692,7 +692,7 @@ protected function tokenize(string $code) break; } } - }//end if + } // Types in typed constants should not be touched, but the constant name should be. if ((isset(static::T_STRING_CONTEXTS[$finalTokens[$lastNotEmptyToken]['code']]) === true @@ -716,7 +716,7 @@ protected function tokenize(string $code) $preserveKeyword = false; $insideConstDeclaration = false; } - }//end if + } if ($finalTokens[$lastNotEmptyToken]['content'] === '&') { $preserveKeyword = true; @@ -749,7 +749,7 @@ protected function tokenize(string $code) $newStackPtr++; continue; } - }//end if + } /* Mark the start of a constant declaration to allow for handling keyword to T_STRING @@ -802,7 +802,7 @@ protected function tokenize(string $code) break; } - }//end if + } /* Prior to PHP 7.4, PHP didn't support stand-alone PHP open tags at the end of a file @@ -842,7 +842,7 @@ protected function tokenize(string $code) $newStackPtr++; continue; - }//end if + } /* Split whitespace off from long PHP open tag tokens and potentially join the whitespace @@ -891,11 +891,11 @@ protected function tokenize(string $code) } $newStackPtr++; - }//end if - }//end if + } + } continue; - }//end if + } /* Parse doc blocks into something that can be easily iterated over. @@ -949,8 +949,8 @@ protected function tokenize(string $code) if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write("* stripped first newline after comment and added it to comment token $stackPtr", 2); } - }//end if - }//end if + } + } /* For Explicit Octal Notation prior to PHP 8.1 we need to combine the @@ -991,7 +991,7 @@ protected function tokenize(string $code) $stackPtr++; continue; - }//end if + } /* PHP 8.1 introduced two dedicated tokens for the & character. @@ -1058,7 +1058,7 @@ protected function tokenize(string $code) // We found the other end of the double quoted string. break; } - }//end for + } $stackPtr = $i; @@ -1086,7 +1086,7 @@ protected function tokenize(string $code) // Continue, as we're done with this token. continue; - }//end if + } /* Detect binary casting and assign the casts their own token. @@ -1202,7 +1202,7 @@ protected function tokenize(string $code) $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; - }//end for + } // Add the end heredoc token to the final array. $finalTokens[$newStackPtr] = self::standardiseToken($tokens[$stackPtr]); @@ -1216,7 +1216,7 @@ protected function tokenize(string $code) // Continue, as we're done with this token. continue; - }//end if + } /* Enum keyword for PHP < 8.1 @@ -1255,7 +1255,7 @@ protected function tokenize(string $code) $newStackPtr++; continue; } - }//end if + } /* Convert enum "case" to T_ENUM_CASE @@ -1295,7 +1295,7 @@ protected function tokenize(string $code) $isEnumCase = true; break; } - }//end for + } if ($isEnumCase === true) { // Modify $tokens directly so we can use it as optimisation for other enum "case". @@ -1314,7 +1314,7 @@ protected function tokenize(string $code) $newStackPtr++; continue; } - }//end if + } /* Asymmetric visibility for PHP < 8.4 @@ -1357,7 +1357,7 @@ protected function tokenize(string $code) $stackPtr += 3; continue; - }//end if + } /* * There is a select group of keywords - true, false, null, exit and die -, @@ -1394,7 +1394,7 @@ protected function tokenize(string $code) continue; } - }//end if + } /* Before PHP 8.0, namespaced names were not tokenized as a single token. @@ -1449,7 +1449,7 @@ protected function tokenize(string $code) ++$i; $newToken['content'] .= $tokens[$i][1]; break; - }//end switch + } while (isset($tokens[($i + 1)], $tokens[($i + 2)]) === true && is_array($tokens[($i + 1)]) === true && $tokens[($i + 1)][0] === T_NS_SEPARATOR @@ -1497,8 +1497,8 @@ protected function tokenize(string $code) } continue; - }//end if - }//end if + } + } /* PHP 8.0 Attributes @@ -1544,7 +1544,7 @@ protected function tokenize(string $code) } continue; - }//end if + } /* Tokenize the parameter labels for PHP 8.0 named parameters as a special T_PARAM_NAME @@ -1600,8 +1600,8 @@ protected function tokenize(string $code) continue; } - }//end if - }//end if + } + } /* "readonly" keyword for PHP < 8.1 @@ -1687,8 +1687,8 @@ protected function tokenize(string $code) } break; - }//end for - }//end if + } + } if ($isReadonlyKeyword === true) { $finalTokens[$newStackPtr] = [ @@ -1718,10 +1718,10 @@ protected function tokenize(string $code) if (PHP_CODESNIFFER_VERBOSITY > 1 && $type !== T_STRING) { StatusWriter::write("* token $stackPtr changed from $type to T_STRING", 2); } - }//end if + } continue; - }//end if + } /* Deal with "yield from" in various PHP versions. @@ -1846,7 +1846,7 @@ protected function tokenize(string $code) unset($yieldFromSubtokens); continue; - }//end if + } /* Between PHP 7.0 and 7.3, the ??= operator was tokenized as @@ -1944,10 +1944,10 @@ protected function tokenize(string $code) } continue; - }//end if + } break; - }//end for + } if ($newType === T_LNUMBER && ((stripos($newContent, '0x') === 0 && hexdec(str_replace('_', '', $newContent)) > PHP_INT_MAX) @@ -1971,7 +1971,7 @@ protected function tokenize(string $code) $newStackPtr++; $stackPtr = ($i - 1); continue; - }//end if + } /* Backfill the T_MATCH token for PHP versions < 8.0 and @@ -2004,7 +2004,7 @@ protected function tokenize(string $code) $isMatch = true; break; - }//end for + } if ($isMatch === true && $token[0] === T_STRING) { $newToken = []; @@ -2033,8 +2033,8 @@ protected function tokenize(string $code) $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; continue; - }//end if - }//end if + } + } /* Retokenize the T_DEFAULT in match control structures as T_MATCH_DEFAULT @@ -2085,8 +2085,8 @@ protected function tokenize(string $code) $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; continue; - }//end if - }//end if + } + } /* Convert ? to T_NULLABLE OR T_INLINE_THEN @@ -2173,7 +2173,7 @@ protected function tokenize(string $code) } break; - }//end for + } /* * This can still be a nullable type or a ternary. @@ -2245,12 +2245,12 @@ protected function tokenize(string $code) if (@isset(Tokens::EMPTY_TOKENS[$tokenType]) === false) { $lastSeenNonEmpty = $tokenType; } - }//end for + } $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; continue; - }//end if + } /* Tokens after a double colon may look like scope openers, @@ -2373,10 +2373,10 @@ function return types. We want to keep the parenthesis map clean, } break; - }//end for - }//end if - }//end if - }//end if + } + } + } + } /* PHP doesn't assign a token to goto labels, so we have to. @@ -2451,9 +2451,9 @@ function return types. We want to keep the parenthesis map clean, $newStackPtr++; continue; - }//end if - }//end if - }//end if + } + } + } /* If this token has newlines in its content, split each line up @@ -2551,7 +2551,7 @@ function return types. We want to keep the parenthesis map clean, break; } - }//end if + } if ($preserveTstring === true) { $finalTokens[$newStackPtr] = [ @@ -2563,7 +2563,7 @@ function return types. We want to keep the parenthesis map clean, $newStackPtr++; continue; } - }//end if + } $newToken = null; if ($tokenIsArray === false) { @@ -2656,8 +2656,8 @@ function return types. We want to keep the parenthesis map clean, StatusWriter::write('* token is return type, not T_INLINE_ELSE', 2); } } - }//end if - }//end if + } + } // Check to see if this is a CASE or DEFAULT opener. if ($isInlineIf === true) { @@ -2682,8 +2682,8 @@ function return types. We want to keep the parenthesis map clean, ) { break; } - }//end for - }//end if + } + } if ($isInlineIf === true) { array_pop($insideInlineIf); @@ -2694,7 +2694,7 @@ function return types. We want to keep the parenthesis map clean, StatusWriter::write('* token changed from T_COLON to T_INLINE_ELSE', 2); } } - }//end if + } // This is a special condition for T_ARRAY tokens used for anything else // but array declarations, like type hinting function arguments as @@ -2747,8 +2747,8 @@ function return types. We want to keep the parenthesis map clean, $finalTokens[$newStackPtr] = $newToken; $newStackPtr++; - }//end if - }//end for + } + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** END PHP TOKENIZING ***', 1); @@ -2824,7 +2824,7 @@ protected function processAdditional() } } } - }//end if + } continue; } elseif ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) { @@ -2878,7 +2878,7 @@ protected function processAdditional() StatusWriter::write("* cleaned $x ($type) *", 2); } } - }//end if + } continue; } elseif ($this->tokens[$i]['code'] === T_FN && isset($this->tokens[($i + 1)]) === true) { @@ -3027,7 +3027,7 @@ protected function processAdditional() $inTernary = false; continue; } - }//end for + } if ($scopeCloser !== $numTokens) { if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -3067,9 +3067,9 @@ protected function processAdditional() $line = $this->tokens[$arrow]['line']; StatusWriter::write("* token $arrow on line $line changed from T_DOUBLE_ARROW to T_FN_ARROW", 2); } - }//end if - }//end if - }//end if + } + } + } // If after all that, the extra tokens are not set, this is not a (valid) arrow function. if (isset($this->tokens[$i]['scope_closer']) === false) { @@ -3147,7 +3147,7 @@ protected function processAdditional() break; } - }//end for + } if ($isShortArray === true) { $this->tokens[$i]['code'] = T_OPEN_SHORT_ARRAY; @@ -3232,8 +3232,8 @@ protected function processAdditional() StatusWriter::write("* token $x changed from T_DOUBLE_ARROW to T_MATCH_ARROW", 2); } } - }//end for - }//end if + } + } continue; } elseif ($this->tokens[$i]['code'] === T_BITWISE_OR @@ -3321,7 +3321,7 @@ protected function processAdditional() } break; - }//end for + } if (($typeTokenCountAfter === 0 && ($this->tokens[$i]['code'] !== T_CLOSE_PARENTHESIS @@ -3392,7 +3392,7 @@ protected function processAdditional() break; } } - }//end if + } if (isset($allowed[$this->tokens[$x]['code']]) === true) { ++$typeTokenCountBefore; @@ -3462,7 +3462,7 @@ protected function processAdditional() } break; - }//end if + } if ($suspectedType === 'constant' && $this->tokens[$x]['code'] === T_CONST) { $confirmed = true; @@ -3482,7 +3482,7 @@ protected function processAdditional() } break; - }//end for + } // Remember the last token we examined as part of the (non-)"type declaration". $lastSeenTypeToken = $x; @@ -3525,11 +3525,11 @@ protected function processAdditional() $confirmed = true; } } - }//end if - }//end if + } + } unset($parens, $last); - }//end if + } if ($confirmed === false || ($parenthesesCount % 2) !== 0) { // Not a (valid) union, intersection or DNF type after all, move on. @@ -3569,8 +3569,8 @@ protected function processAdditional() $line = $this->tokens[$x]['line']; StatusWriter::write("* token $x on line $line changed from T_CLOSE_PARENTHESIS to T_TYPE_CLOSE_PARENTHESIS", 1); } - }//end if - }//end foreach + } + } if (isset($maybeNullable) === true) { $this->tokens[$maybeNullable]['code'] = T_NULLABLE; @@ -3606,7 +3606,7 @@ protected function processAdditional() $this->tokens[$i]['code'] = T_STRING; $this->tokens[$i]['type'] = 'T_STRING'; } - }//end if + } if (($this->tokens[$i]['code'] !== T_CASE && $this->tokens[$i]['code'] !== T_DEFAULT) @@ -3708,7 +3708,7 @@ protected function processAdditional() } } } - }//end if + } unset($this->tokens[$x]['bracket_opener']); unset($this->tokens[$x]['bracket_closer']); @@ -3745,10 +3745,10 @@ protected function processAdditional() } break; - }//end if - }//end foreach - }//end for - }//end for + } + } + } + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** END ADDITIONAL PHP PROCESSING ***', 1); @@ -3826,7 +3826,7 @@ public static function standardiseToken($token) ]; self::$resolveTokenCache[$token[0]] = $newToken; - }//end if + } $newToken['content'] = $token[1]; return $newToken; @@ -3930,7 +3930,7 @@ public static function resolveSimpleToken(string $token) default: $newToken['type'] = 'T_NONE'; break; - }//end switch + } $newToken['code'] = constant($newToken['type']); $newToken['content'] = $token; @@ -4069,7 +4069,7 @@ private function createAttributesNestingMap() if (empty($map) === false) { $this->tokens[$i]['nested_attributes'] = $map; } - }//end if - }//end for + } + } } } diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php index 4af7509c4b..acfb9c4f90 100644 --- a/src/Tokenizers/Tokenizer.php +++ b/src/Tokenizers/Tokenizer.php @@ -243,7 +243,7 @@ private function createPositionMap() $this->replaceTabsInToken($this->tokens[$i]); $length = $this->tokens[$i]['length']; $currColumn += $length; - }//end if + } $this->tokens[$i]['length'] = $length; @@ -312,7 +312,7 @@ private function createPositionMap() $lineHasOtherContent = true; break; - }//end for + } $changedLines = false; for ($next = $i; $next < $this->numTokens; $next++) { @@ -348,8 +348,8 @@ private function createPositionMap() $lineHasOtherContent = true; break; - }//end for - }//end if + } + } if (substr($commentTextLower, 0, 9) === 'phpcs:set') { // Ignore standards for complete lines that change sniff settings. @@ -430,7 +430,7 @@ private function createPositionMap() } $this->tokens[$i]['sniffCodes'] = $enabledSniffs; - }//end if + } $this->tokens[$i]['code'] = T_PHPCS_ENABLE; $this->tokens[$i]['type'] = 'T_PHPCS_ENABLE'; @@ -465,14 +465,14 @@ private function createPositionMap() // so respect the ignore rules it set. $this->ignoredLines[$this->tokens[$i]['line']] = $lineIgnoring; } - }//end if - }//end if - }//end if + } + } + } if ($ignoring !== null && isset($this->ignoredLines[$this->tokens[$i]['line']]) === false) { $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring; } - }//end for + } // If annotations are being ignored, we clear out all the ignore rules // but leave the annotations tokenized as normal. @@ -562,8 +562,8 @@ public function replaceTabsInToken(array &$token, string $prefix = ' ', string $ $currColumn += $pad; $length += $pad; $newContent .= $prefix . str_repeat($padding, ($pad - 1)); - }//end foreach - }//end if + } + } $token['orig_content'] = $token['content']; $token['content'] = $newContent; @@ -646,7 +646,7 @@ private function createTokenMap() $this->tokens[$i]['parenthesis_opener'] = $opener; $this->tokens[$i]['parenthesis_closer'] = $i; $this->tokens[$opener]['parenthesis_closer'] = $i; - }//end if + } } elseif ($this->tokens[$i]['code'] === T_ATTRIBUTE) { $openers[] = $i; if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -677,8 +677,8 @@ private function createTokenMap() } elseif (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write("=> Found unowned attribute closer at $i for $opener", (count($openers) + 1)); } - }//end if - }//end if + } + } /* Bracket mapping. @@ -731,8 +731,8 @@ private function createTokenMap() break; default: continue 2; - }//end switch - }//end for + } + } // Cleanup for any openers that we didn't find closers for. // This typically means there was a syntax error breaking things. @@ -778,8 +778,8 @@ private function createParenthesisNestingMap() if (empty($map) === false) { $this->tokens[$i]['nested_parenthesis'] = $map; } - }//end if - }//end for + } + } } @@ -813,8 +813,8 @@ private function createScopeMap() } $i = $this->recurseScopeMap($i); - }//end if - }//end for + } + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** END SCOPE MAP ***', 1); @@ -873,7 +873,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 $statusMessage .= "]: $type => $content"; StatusWriter::write($statusMessage, $depth); - }//end if + } // Very special case for IF statements in PHP that can be defined without // scope tokens. E.g., if (1) 1; 1 ? (1 ? 1 : 1) : 1; @@ -984,7 +984,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 // The closer was not processed, so we need to // complete that token as well. $todo[] = $scopeCloser; - }//end if + } if ($validCloser === true) { foreach ($todo as $token) { @@ -1014,9 +1014,9 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 } } else { continue; - }//end if - }//end if - }//end if + } + } + } // Is this an opening condition ? if (isset($this->scopeOpeners[$tokenType]) === true) { @@ -1049,7 +1049,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 $i = self::recurseScopeMap($i, ($depth + 1), $ignore); continue; - }//end if + } if ($tokenType === T_CLASS) { // Probably an anonymous class inside another anonymous class, @@ -1071,7 +1071,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 $i = self::recurseScopeMap($i, ($depth + 1), $ignore); continue; - }//end if + } // Found another opening condition but still haven't // found our opener, so we are never going to find one. @@ -1098,7 +1098,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 return $stackPtr; } - }//end if + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('* token is an opening condition *', $depth); @@ -1168,8 +1168,8 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 if (isset($this->scopeOpeners[$tokenType]['end'][T_CLOSE_CURLY_BRACKET]) === true) { $ignore = $oldIgnore; } - }//end if - }//end if + } + } if (isset($this->scopeOpeners[$currType]['start'][$tokenType]) === true && $opener === null @@ -1214,10 +1214,10 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 } break; - }//end if - }//end for - }//end if - }//end if + } + } + } + } if ($ignore === 0 || $tokenType !== T_OPEN_CURLY_BRACKET) { $openerNested = isset($this->tokens[$i]['nested_parenthesis']); @@ -1242,7 +1242,7 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 $opener = $i; } - }//end if + } } elseif ($tokenType === T_SEMICOLON && $opener === null && (isset($this->tokens[$stackPtr]['parenthesis_closer']) === false @@ -1342,10 +1342,10 @@ private function recurseScopeMap(int $stackPtr, int $depth = 1, int &$ignore = 0 } return ($i - 1); - }//end if - }//end if - }//end if - }//end for + } + } + } + } return $stackPtr; } @@ -1394,7 +1394,7 @@ private function createLevelMap() $statusMessage .= "]: $type => $content"; StatusWriter::write($statusMessage, ($level + 1)); - }//end if + } $this->tokens[$i]['level'] = $level; $this->tokens[$i]['conditions'] = $conditions; @@ -1462,8 +1462,8 @@ private function createLevelMap() StatusWriter::write("* cleaned $x:$type *", ($level + 1)); StatusWriter::write("=> level changed from $oldLevel to $newLevel", ($level + 2)); StatusWriter::write("=> conditions changed from $oldConds to $newConds", ($level + 2)); - }//end if - }//end for + } + } unset($conditions[$badToken]); if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -1477,8 +1477,8 @@ private function createLevelMap() if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('* level decreased *', ($level + 2)); } - }//end if - }//end if + } + } $level++; if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -1554,10 +1554,10 @@ private function createLevelMap() StatusWriter::write("* cleaned $x:$type *", ($level + 1)); StatusWriter::write("=> level changed from $oldLevel to $newLevel", ($level + 2)); StatusWriter::write("=> conditions changed from $oldConds to $newConds", ($level + 2)); - }//end if - }//end for - }//end if - }//end if + } + } + } + } $level--; if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -1566,11 +1566,11 @@ private function createLevelMap() $this->tokens[$i]['level'] = $level; $this->tokens[$i]['conditions'] = $conditions; - }//end if - }//end foreach - }//end if - }//end if - }//end for + } + } + } + } + } if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** END LEVEL MAP ***', 1); diff --git a/src/Util/Cache.php b/src/Util/Cache.php index 6c8a543b5c..dfc4cd9c3b 100644 --- a/src/Util/Cache.php +++ b/src/Util/Cache.php @@ -189,7 +189,7 @@ static function ($file, $key, $iterator) { } StatusWriter::write("=> cacheHash: $cacheHash", 2); - }//end if + } if ($config->cacheFile !== null) { $cacheFile = $config->cacheFile; @@ -255,13 +255,13 @@ static function ($file, $key, $iterator) { $cacheFile = $testFile; break; } - }//end foreach + } if ($cacheFile === null) { // Unlikely, but just in case $paths is empty for some reason. $cacheFile = $cacheDir . DIRECTORY_SEPARATOR . "phpcs.$cacheHash.cache"; } - }//end if + } self::$path = $cacheFile; if (PHP_CODESNIFFER_VERBOSITY > 1) { diff --git a/src/Util/Common.php b/src/Util/Common.php index 4ac808962b..7632dd7989 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -308,7 +308,7 @@ public static function prepareForOutput(string $content, array $exclude = []) if (in_array(' ', $exclude, true) === false) { $content = str_replace(' ', "\033[30;1m·\033[0m", $content); } - }//end if + } return $content; } @@ -405,7 +405,7 @@ public static function isCamelCaps( $lastCharWasCaps = $isCaps; } - }//end if + } return true; } @@ -482,7 +482,7 @@ public static function suggestType(string $varType) case 'array()': case 'array': return 'array'; - }//end switch + } if (strpos($lowerVarType, 'array(') !== false) { // Valid array declaration: @@ -509,15 +509,15 @@ public static function suggestType(string $varType) return "array($type1$type2)"; } else { return 'array'; - }//end if + } } elseif (isset(self::ALLOWED_TYPES[$lowerVarType]) === true) { // A valid type, but not lower cased. return $lowerVarType; } else { // Must be a custom type name. return $varType; - }//end if - }//end if + } + } } diff --git a/src/Util/Help.php b/src/Util/Help.php index ecfef28b87..adf2f81668 100644 --- a/src/Util/Help.php +++ b/src/Util/Help.php @@ -206,7 +206,7 @@ private function filterOptions() if (empty($filteredOptions[$category]) === true || count($filteredOptions[$category]) === $spacerCount) { unset($filteredOptions[$category]); } - }//end foreach + } $this->activeOptions = $filteredOptions; } diff --git a/src/Util/Standards.php b/src/Util/Standards.php index 4be2a04f2f..bdcddede51 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -116,7 +116,7 @@ public static function getInstalledStandardDetails( } } } - }//end foreach + } $installedStandards = []; @@ -140,7 +140,7 @@ public static function getInstalledStandardDetails( 'name' => $standardName, 'namespace' => $namespace, ]; - }//end foreach + } return $installedStandards; } @@ -210,7 +210,7 @@ public static function getInstalledStandards( natsort($standardsInDir); $installedStandards += $standardsInDir; - }//end foreach + } return $installedStandards; } @@ -256,7 +256,7 @@ public static function isInstalledStandard(string $standard) if (is_file($ruleset) === true) { return true; } - }//end if + } return false; } @@ -300,7 +300,7 @@ public static function getInstalledStandardPath(string $standard) return $path; } } - }//end foreach + } return null; } diff --git a/tests/Core/Config/SniffsExcludeArgsTest.php b/tests/Core/Config/SniffsExcludeArgsTest.php index 0945b28615..01ac980251 100644 --- a/tests/Core/Config/SniffsExcludeArgsTest.php +++ b/tests/Core/Config/SniffsExcludeArgsTest.php @@ -191,7 +191,7 @@ public static function dataInvalid() ], 'suggestion' => 'sTANDARD.cATEGORY.sNIFF', ]; - }//end foreach + } return $data; } @@ -270,7 +270,7 @@ public static function dataValid() 'value' => 'Standard.Category.Sniff, standard.category.sniff, STANDARD.CATEGORY.SNIFF', 'result' => ['Standard.Category.Sniff'], ]; - }//end foreach + } return $data; } diff --git a/tests/Core/Files/File/GetMethodParametersTest.php b/tests/Core/Files/File/GetMethodParametersTest.php index fddc83dc3a..b1e44c3dbb 100644 --- a/tests/Core/Files/File/GetMethodParametersTest.php +++ b/tests/Core/Files/File/GetMethodParametersTest.php @@ -3264,7 +3264,7 @@ private function getMethodParametersTestHelper($commentString, $expected, $targe if (isset($param['readonly_token']) === true) { $expected[$key]['readonly_token'] += $target; } - }//end foreach + } $this->assertSame($expected, $found); } diff --git a/tests/Core/Ruleset/PopulateTokenListenersTest.php b/tests/Core/Ruleset/PopulateTokenListenersTest.php index 435bd9a978..2f992047ed 100644 --- a/tests/Core/Ruleset/PopulateTokenListenersTest.php +++ b/tests/Core/Ruleset/PopulateTokenListenersTest.php @@ -285,8 +285,8 @@ public function testSetsClassAndSourceIndexes() $details['source'], sprintf('Unexpected value for "source" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) ); - }//end foreach - }//end foreach + } + } } @@ -320,7 +320,7 @@ public function testSetsIncludePatternsToEmptyArrayByDefault() sprintf('Unexpected value for "include" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) ); } - }//end foreach + } } @@ -354,7 +354,7 @@ public function testSetsIgnorePatternsToEmptyArrayByDefault() sprintf('Unexpected value for "ignore" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) ); } - }//end foreach + } } diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index ce0fb95d6c..f883b76393 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -74,7 +74,7 @@ protected function setUp(): void $config = new ConfigDouble(["--standard=$standard"]); self::$ruleset = new Ruleset($config); - }//end if + } } diff --git a/tests/Core/Tokenizers/AbstractTokenizerTestCase.php b/tests/Core/Tokenizers/AbstractTokenizerTestCase.php index bb02c5f43c..299084f356 100644 --- a/tests/Core/Tokenizers/AbstractTokenizerTestCase.php +++ b/tests/Core/Tokenizers/AbstractTokenizerTestCase.php @@ -66,7 +66,7 @@ protected function setUp(): void $this->phpcsFile = new LocalFile($pathToTestFile, $ruleset, $config); $this->phpcsFile->parse(); - }//end if + } } diff --git a/tests/Core/Tokenizers/Comment/CommentTestCase.php b/tests/Core/Tokenizers/Comment/CommentTestCase.php index f0cf358625..8e755e696b 100644 --- a/tests/Core/Tokenizers/Comment/CommentTestCase.php +++ b/tests/Core/Tokenizers/Comment/CommentTestCase.php @@ -119,6 +119,6 @@ protected function checkTokenSequence($startPtr, array $expectedSequence) $tokens[$i]['content'], 'Token content did not match expectations' . $errorMsgSuffix ); - }//end for + } } } diff --git a/tests/Core/Tokenizers/PHP/DNFTypesParseError2Test.php b/tests/Core/Tokenizers/PHP/DNFTypesParseError2Test.php index 9c9ffa4279..3ca281d7d6 100644 --- a/tests/Core/Tokenizers/PHP/DNFTypesParseError2Test.php +++ b/tests/Core/Tokenizers/PHP/DNFTypesParseError2Test.php @@ -186,8 +186,8 @@ public function testBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched($t default: break; - }//end switch - }//end for + } + } } diff --git a/tests/Core/Tokenizers/PHP/DNFTypesTest.php b/tests/Core/Tokenizers/PHP/DNFTypesTest.php index ee1df2dacb..4c38a73aa4 100644 --- a/tests/Core/Tokenizers/PHP/DNFTypesTest.php +++ b/tests/Core/Tokenizers/PHP/DNFTypesTest.php @@ -324,7 +324,7 @@ public function testDNFTypeParentheses($testMarker) // For the purposes of this test, presume it was intended as an intersection. ++$intersectionCount; } - }//end for + } $this->assertGreaterThanOrEqual(1, $intersectionCount, 'Did not find an intersection "&" between the DNF type parentheses'); diff --git a/tests/Core/Tokenizers/PHP/HeredocNowdocTest.php b/tests/Core/Tokenizers/PHP/HeredocNowdocTest.php index 3b912a15eb..1b48a7a811 100644 --- a/tests/Core/Tokenizers/PHP/HeredocNowdocTest.php +++ b/tests/Core/Tokenizers/PHP/HeredocNowdocTest.php @@ -199,6 +199,6 @@ private function checkTokenSequence($startPtr, array $expectedSequence) $tokens[$i]['content'], 'Token content did not match expectations' . $errorMsgSuffix ); - }//end for + } } } diff --git a/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php index 624a556a58..b2181cce0e 100644 --- a/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizers/PHP/NamedFunctionCallArgumentsTest.php @@ -64,7 +64,7 @@ public function testNamedFunctionCallArguments($testMarker, $parameters) $tokens[$colon]['type'], 'Token tokenized as ' . $tokens[$colon]['type'] . ', not T_COLON (type)' ); - }//end foreach + } } @@ -969,7 +969,7 @@ public static function dataReservedKeywordsAsName() $tokensTypes, $keyword, ]; - }//end foreach + } return $data; } diff --git a/tests/Core/Tokenizers/PHP/PHPOpenTagTest.php b/tests/Core/Tokenizers/PHP/PHPOpenTagTest.php index 91108ca282..0ba7db9a0a 100644 --- a/tests/Core/Tokenizers/PHP/PHPOpenTagTest.php +++ b/tests/Core/Tokenizers/PHP/PHPOpenTagTest.php @@ -272,7 +272,7 @@ private function checkTokenSequence($testMarker, array $expectedTokens) ); ++$stackPtr; - }//end foreach + } } diff --git a/tests/Core/Tokenizers/PHP/ResolveSimpleTokenTest.php b/tests/Core/Tokenizers/PHP/ResolveSimpleTokenTest.php index 5908a494dd..34c3ff6a05 100644 --- a/tests/Core/Tokenizers/PHP/ResolveSimpleTokenTest.php +++ b/tests/Core/Tokenizers/PHP/ResolveSimpleTokenTest.php @@ -407,6 +407,6 @@ private function checkTokenSequence($startPtr, array $expectedSequence) ); ++$sequenceKey; - }//end for + } } } diff --git a/tests/Core/Tokenizers/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php b/tests/Core/Tokenizers/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php index 3eca64eb30..fc5eaa24b8 100644 --- a/tests/Core/Tokenizers/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php +++ b/tests/Core/Tokenizers/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php @@ -220,7 +220,7 @@ public function testDNFTypeParentheses($testMarker) $this->assertArrayHasKey('nested_parenthesis', $tokens[$i], "Nested parenthesis key not set on token $i ({$tokens[$i]['type']})"); $this->assertArrayHasKey($openPtr, $tokens[$i]['nested_parenthesis'], 'Nested parenthesis is missing target parentheses set'); $this->assertSame($closePtr, $tokens[$i]['nested_parenthesis'][$openPtr], 'Nested parenthesis closer not set correctly'); - }//end for + } } diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php index a647ef9f2d..65e475014c 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php @@ -265,7 +265,7 @@ public function testSwitchDefault($testMarker, $openerMarker, $closerMarker, $co $tokens[$closer]['scope_closer'], sprintf('T_DEFAULT closer scope closer token incorrect. Marker: %s.', $closerMarker) ); - }//end if + } if (($opener + 1) !== $closer) { $end = $closer; @@ -280,7 +280,7 @@ public function testSwitchDefault($testMarker, $openerMarker, $closerMarker, $co sprintf('T_DEFAULT condition not added for token belonging to the T_DEFAULT structure. Marker: %s.', $testMarker) ); } - }//end if + } } diff --git a/tests/Core/Util/Help/HelpTest.php b/tests/Core/Util/Help/HelpTest.php index a328ab34f7..a047d69081 100644 --- a/tests/Core/Util/Help/HelpTest.php +++ b/tests/Core/Util/Help/HelpTest.php @@ -126,8 +126,8 @@ public function testQaValidCategoryOptionDefinitions() "Option $name: a description should always be accompanied by an argument" ); } - }//end foreach - }//end foreach + } + } } diff --git a/tests/Standards/AbstractSniffTestCase.php b/tests/Standards/AbstractSniffTestCase.php index 27ecdaa649..0c8c79512e 100644 --- a/tests/Standards/AbstractSniffTestCase.php +++ b/tests/Standards/AbstractSniffTestCase.php @@ -232,11 +232,11 @@ final public function testSniff() $diff = trim($phpcsFile->fixer->generateDiff($testFile)); $failureMessages[] = "Missing fixed version of $filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file; the diff is\n$diff"; } - }//end if + } // Restore the config. $config->setSettings($oldConfig); - }//end foreach + } if (empty($failureMessages) === false) { $this->fail(implode(PHP_EOL, $failureMessages)); @@ -301,7 +301,7 @@ public function generateFailureMessages(LocalFile $file) } $allProblems[$line]['found_errors'] = array_merge($foundErrorsTemp, $errorsTemp); - }//end foreach + } if (isset($expectedErrors[$line]) === true) { $allProblems[$line]['expected_errors'] = $expectedErrors[$line]; @@ -310,7 +310,7 @@ public function generateFailureMessages(LocalFile $file) } unset($expectedErrors[$line]); - }//end foreach + } foreach ($expectedErrors as $line => $numErrors) { if (isset($allProblems[$line]) === false) { @@ -347,7 +347,7 @@ public function generateFailureMessages(LocalFile $file) } $allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp); - }//end foreach + } if (isset($expectedWarnings[$line]) === true) { $allProblems[$line]['expected_warnings'] = $expectedWarnings[$line]; @@ -356,7 +356,7 @@ public function generateFailureMessages(LocalFile $file) } unset($expectedWarnings[$line]); - }//end foreach + } foreach ($expectedWarnings as $line => $numWarnings) { if (isset($allProblems[$line]) === false) { @@ -426,8 +426,8 @@ public function generateFailureMessages(LocalFile $file) } $failureMessages[] = $fullMessage; - }//end if - }//end foreach + } + } return $failureMessages; }