diff --git a/autoload.php b/autoload.php
index 4b1d5aa013..6f38c75d96 100644
--- a/autoload.php
+++ b/autoload.php
@@ -78,9 +78,9 @@ public static function load(string $className)
}
if (strpos(__DIR__, 'phar://') !== 0
- && @file_exists(__DIR__.'/../../autoload.php') === true
+ && @file_exists(__DIR__ . '/../../autoload.php') === true
) {
- self::$composerAutoloader = include __DIR__.'/../../autoload.php';
+ self::$composerAutoloader = include __DIR__ . '/../../autoload.php';
if (self::$composerAutoloader instanceof ClassLoader) {
self::$composerAutoloader->unregister();
self::$composerAutoloader->register();
@@ -99,16 +99,16 @@ public static function load(string $className)
if (substr($className, 0, 16) === 'PHP_CodeSniffer\\') {
if (substr($className, 0, 22) === 'PHP_CodeSniffer\Tests\\') {
- $isInstalled = !is_dir(__DIR__.$ds.'tests');
+ $isInstalled = !is_dir(__DIR__ . $ds . 'tests');
if ($isInstalled === false) {
- $path = __DIR__.$ds.'tests';
+ $path = __DIR__ . $ds . 'tests';
} else {
- $path = '@test_dir@'.$ds.'PHP_CodeSniffer'.$ds.'CodeSniffer';
+ $path = '@test_dir@' . $ds . 'PHP_CodeSniffer' . $ds . 'CodeSniffer';
}
- $path .= $ds.substr(str_replace('\\', $ds, $className), 22).'.php';
+ $path .= $ds . substr(str_replace('\\', $ds, $className), 22) . '.php';
} else {
- $path = __DIR__.$ds.'src'.$ds.substr(str_replace('\\', $ds, $className), 16).'.php';
+ $path = __DIR__ . $ds . 'src' . $ds . substr(str_replace('\\', $ds, $className), 16) . '.php';
}
}
@@ -125,7 +125,7 @@ public static function load(string $className)
$className = substr($className, (strlen($nsPrefix) + 1));
}
- $path = $searchPath.$ds.str_replace('\\', $ds, $className).'.php';
+ $path = $searchPath . $ds . str_replace('\\', $ds, $className) . '.php';
if (is_file($path) === true) {
break;
}
@@ -342,5 +342,5 @@ public static function getLoadedFiles()
// Register the autoloader before any existing autoloaders to ensure
// 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);
+ spl_autoload_register(__NAMESPACE__ . '\Autoload::load', true, true);
}//end if
diff --git a/bin/phpcbf b/bin/phpcbf
index 95a872cd9c..d2cfb101c8 100755
--- a/bin/phpcbf
+++ b/bin/phpcbf
@@ -21,10 +21,10 @@
*/
// Check if the PHP version and extensions comply with the minimum requirements before anything else.
-require_once dirname(__DIR__).'/requirements.php';
+require_once dirname(__DIR__) . '/requirements.php';
PHP_CodeSniffer\checkRequirements();
-require_once dirname(__DIR__).'/autoload.php';
+require_once dirname(__DIR__) . '/autoload.php';
$runner = new PHP_CodeSniffer\Runner();
$exitCode = $runner->runPHPCBF();
diff --git a/bin/phpcs b/bin/phpcs
index fe3adaf58a..6ed073477f 100755
--- a/bin/phpcs
+++ b/bin/phpcs
@@ -21,10 +21,10 @@
*/
// Check if the PHP version and extensions comply with the minimum requirements before anything else.
-require_once dirname(__DIR__).'/requirements.php';
+require_once dirname(__DIR__) . '/requirements.php';
PHP_CodeSniffer\checkRequirements();
-require_once dirname(__DIR__).'/autoload.php';
+require_once dirname(__DIR__) . '/autoload.php';
$runner = new PHP_CodeSniffer\Runner();
$exitCode = $runner->runPHPCS();
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index a721c23bce..55cb2265fb 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -61,14 +61,13 @@
-
-
+
diff --git a/requirements.php b/requirements.php
index 39b95df6aa..2558b8fa50 100644
--- a/requirements.php
+++ b/requirements.php
@@ -34,7 +34,7 @@ function checkRequirements()
// Check the PHP version.
if (PHP_VERSION_ID < 70200) {
- $error = 'ERROR: PHP_CodeSniffer requires PHP version 7.2.0 or greater.'.PHP_EOL;
+ $error = 'ERROR: PHP_CodeSniffer requires PHP version 7.2.0 or greater.' . PHP_EOL;
fwrite(STDERR, $error);
exit($exitCode);
}
@@ -55,17 +55,17 @@ function checkRequirements()
if (empty($missingExtensions) === false) {
$last = array_pop($requiredExtensions);
$required = implode(', ', $requiredExtensions);
- $required .= ' and '.$last;
+ $required .= ' and ' . $last;
if (count($missingExtensions) === 1) {
$missing = $missingExtensions[0];
} else {
$last = array_pop($missingExtensions);
$missing = implode(', ', $missingExtensions);
- $missing .= ' and '.$last;
+ $missing .= ' and ' . $last;
}
- $error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.'.PHP_EOL;
+ $error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.' . PHP_EOL;
fwrite(STDERR, sprintf($error, $required, $missing));
exit($exitCode);
}
diff --git a/scripts/build-phar.php b/scripts/build-phar.php
index 84deb18382..545f97e9ae 100644
--- a/scripts/build-phar.php
+++ b/scripts/build-phar.php
@@ -23,12 +23,12 @@
error_reporting(E_ALL);
if (ini_get('phar.readonly') === '1') {
- echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL;
+ echo 'Unable to build, phar.readonly in php.ini is set to read only.' . PHP_EOL;
exit(1);
}
-require_once dirname(__DIR__).'/autoload.php';
-require_once dirname(__DIR__).'/src/Util/Tokens.php';
+require_once dirname(__DIR__) . '/autoload.php';
+require_once dirname(__DIR__) . '/src/Util/Tokens.php';
if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
define('PHP_CODESNIFFER_VERBOSITY', 0);
@@ -54,13 +54,13 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
$tokenizer = new PHP($contents, $config, "\n");
$tokens = $tokenizer->getTokens();
} catch (TokenizerException $e) {
- throw new RuntimeException('Failed to tokenize file '.$fullpath);
+ throw new RuntimeException('Failed to tokenize file ' . $fullpath);
}
$stripped = '';
foreach ($tokens as $token) {
if ($token['code'] === T_ATTRIBUTE_END || $token['code'] === T_OPEN_TAG) {
- $stripped .= $token['content']."\n";
+ $stripped .= $token['content'] . "\n";
continue;
}
@@ -87,13 +87,13 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
];
foreach ($scripts as $script) {
- echo "Building $script phar".PHP_EOL;
+ echo "Building $script phar" . PHP_EOL;
- $pharName = $script.'.phar';
- $pharFile = getcwd().'/'.$pharName;
- echo "\t=> $pharFile".PHP_EOL;
+ $pharName = $script . '.phar';
+ $pharFile = getcwd() . '/' . $pharName;
+ echo "\t=> $pharFile" . PHP_EOL;
if (file_exists($pharFile) === true) {
- echo "\t** file exists, removing **".PHP_EOL;
+ echo "\t** file exists, removing **" . PHP_EOL;
unlink($pharFile);
}
@@ -105,7 +105,7 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
echo "\t=> adding files... ";
- $srcDir = realpath(__DIR__.'/../src');
+ $srcDir = realpath(__DIR__ . '/../src');
$srcDirLen = strlen($srcDir);
$rdi = new RecursiveDirectoryIterator($srcDir, RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
@@ -123,11 +123,11 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
}
$fullpath = $file->getPathname();
- if (strpos($fullpath, DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR) !== false) {
+ if (strpos($fullpath, DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR) !== false) {
continue;
}
- $path = 'src'.substr($fullpath, $srcDirLen);
+ $path = 'src' . substr($fullpath, $srcDirLen);
if (substr($filename, -4) === '.xml') {
$phar->addFile($fullpath, $path);
@@ -140,39 +140,39 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
}//end foreach
// Add requirements check.
- $phar->addFromString('requirements.php', stripWhitespaceAndComments(realpath(__DIR__.'/../requirements.php'), $config));
+ $phar->addFromString('requirements.php', stripWhitespaceAndComments(realpath(__DIR__ . '/../requirements.php'), $config));
// Add autoloader.
- $phar->addFromString('autoload.php', stripWhitespaceAndComments(realpath(__DIR__.'/../autoload.php'), $config));
+ $phar->addFromString('autoload.php', stripWhitespaceAndComments(realpath(__DIR__ . '/../autoload.php'), $config));
// Add licence file.
- $phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt');
+ $phar->addFile(realpath(__DIR__ . '/../licence.txt'), 'licence.txt');
- echo 'done'.PHP_EOL;
- echo "\t Added ".$fileCount.' files'.PHP_EOL;
+ echo 'done' . PHP_EOL;
+ echo "\t Added " . $fileCount . ' files' . PHP_EOL;
/*
Add the stub.
*/
echo "\t=> adding stub... ";
- $stub = '#!/usr/bin/env php'."\n";
- $stub .= 'run'.$script.'();'."\n";
- $stub .= 'exit($exitCode);'."\n";
+ $stub = '#!/usr/bin/env php' . "\n";
+ $stub .= 'run' . $script . '();' . "\n";
+ $stub .= 'exit($exitCode);' . "\n";
$stub .= '__HALT_COMPILER();';
$phar->setStub($stub);
- echo 'done'.PHP_EOL;
+ echo 'done' . PHP_EOL;
}//end foreach
Timing::printRunTime();
echo PHP_EOL;
-echo 'Filesize generated phpcs.phar file: '.number_format(filesize(dirname(__DIR__).'/phpcs.phar'), 0, ',', '.').' bytes'.PHP_EOL;
-echo 'Filesize generated phpcs.phar file: '.number_format(filesize(dirname(__DIR__).'/phpcbf.phar'), 0, ',', '.').' bytes'.PHP_EOL;
+echo 'Filesize generated phpcs.phar file: ' . number_format(filesize(dirname(__DIR__) . '/phpcs.phar'), 0, ',', '.') . ' bytes' . PHP_EOL;
+echo 'Filesize generated phpcs.phar file: ' . number_format(filesize(dirname(__DIR__) . '/phpcbf.phar'), 0, ',', '.') . ' bytes' . PHP_EOL;
diff --git a/scripts/get-requirements-check-matrix.php b/scripts/get-requirements-check-matrix.php
index ea50ed5e47..8743c811f8 100644
--- a/scripts/get-requirements-check-matrix.php
+++ b/scripts/get-requirements-check-matrix.php
@@ -13,6 +13,6 @@
error_reporting(E_ALL);
-require_once __DIR__.'/BuildRequirementsCheckMatrix.php';
+require_once __DIR__ . '/BuildRequirementsCheckMatrix.php';
echo json_encode(['include' => (new PHP_CodeSniffer\BuildRequirementsCheckMatrix())->getBuilds()]);
diff --git a/src/Config.php b/src/Config.php
index 60e4390206..28b777714e 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -440,7 +440,7 @@ public function __construct(array $cliArgs = [], bool $dieOnUnknownArg = true)
do {
foreach (self::CONFIG_FILENAMES as $defaultFilename) {
- $default = $currentDir.DIRECTORY_SEPARATOR.$defaultFilename;
+ $default = $currentDir . DIRECTORY_SEPARATOR . $defaultFilename;
if (is_file($default) === true) {
$this->standards = [$default];
break(2);
@@ -683,7 +683,7 @@ public function processShortArgument(string $arg, int $pos)
$this->printUsage();
throw new DeepExitException('', ExitCode::OKAY);
case 'i' :
- $output = Standards::prepareInstalledStandardsForDisplay().PHP_EOL;
+ $output = Standards::prepareInstalledStandardsForDisplay() . PHP_EOL;
throw new DeepExitException($output, ExitCode::OKAY);
case 'v' :
if ($this->quiet === true) {
@@ -748,7 +748,7 @@ public function processShortArgument(string $arg, int $pos)
$changed = ini_set($ini[0], $ini[1]);
if ($changed === false && ini_get($ini[0]) !== $ini[1]) {
- $error = sprintf('ERROR: Ini option "%s" cannot be changed at runtime.', $ini[0]).PHP_EOL;
+ $error = sprintf('ERROR: Ini option "%s" cannot be changed at runtime.', $ini[0]) . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -771,7 +771,7 @@ public function processShortArgument(string $arg, int $pos)
$unknown[] = $arg;
$this->unknown = $unknown;
} else {
- $this->processUnknownArgument('-'.$arg, $pos);
+ $this->processUnknownArgument('-' . $arg, $pos);
}
}//end switch
@@ -794,8 +794,8 @@ public function processLongArgument(string $arg, int $pos)
$this->printUsage();
throw new DeepExitException('', ExitCode::OKAY);
case 'version':
- $output = 'PHP_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') ';
- $output .= 'by Squiz and PHPCSStandards'.PHP_EOL;
+ $output = 'PHP_CodeSniffer version ' . self::VERSION . ' (' . self::STABILITY . ') ';
+ $output .= 'by Squiz and PHPCSStandards' . PHP_EOL;
throw new DeepExitException($output, ExitCode::OKAY);
case 'colors':
if (isset($this->overriddenDefaults['colors']) === true) {
@@ -841,7 +841,7 @@ public function processLongArgument(string $arg, int $pos)
if (isset($this->cliArgs[($pos + 1)]) === false
|| isset($this->cliArgs[($pos + 2)]) === false
) {
- $error = 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Setting a config option requires a name and value' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -853,50 +853,50 @@ public function processLongArgument(string $arg, int $pos)
try {
$this->setConfigData($key, $value);
} catch (Exception $e) {
- throw new DeepExitException($e->getMessage().PHP_EOL, ExitCode::PROCESS_ERROR);
+ throw new DeepExitException($e->getMessage() . PHP_EOL, ExitCode::PROCESS_ERROR);
}
- $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL;
+ $output = 'Using config file: ' . self::$configDataFile . PHP_EOL . PHP_EOL;
if ($current === null) {
- $output .= "Config value \"$key\" added successfully".PHP_EOL;
+ $output .= "Config value \"$key\" added successfully" . PHP_EOL;
} else {
- $output .= "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL;
+ $output .= "Config value \"$key\" updated successfully; old value was \"$current\"" . PHP_EOL;
}
throw new DeepExitException($output, ExitCode::OKAY);
case 'config-delete':
if (isset($this->cliArgs[($pos + 1)]) === false) {
- $error = 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Deleting a config option requires the name of the option' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL;
+ $output = 'Using config file: ' . self::$configDataFile . PHP_EOL . PHP_EOL;
$key = $this->cliArgs[($pos + 1)];
$current = self::getConfigData($key);
if ($current === null) {
- $output .= "Config value \"$key\" has not been set".PHP_EOL;
+ $output .= "Config value \"$key\" has not been set" . PHP_EOL;
} else {
try {
$this->setConfigData($key, null);
} catch (Exception $e) {
- throw new DeepExitException($e->getMessage().PHP_EOL, ExitCode::PROCESS_ERROR);
+ throw new DeepExitException($e->getMessage() . PHP_EOL, ExitCode::PROCESS_ERROR);
}
- $output .= "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL;
+ $output .= "Config value \"$key\" removed successfully; old value was \"$current\"" . PHP_EOL;
}
throw new DeepExitException($output, ExitCode::OKAY);
case 'config-show':
$data = self::getAllConfigData();
- $output = 'Using config file: '.self::$configDataFile.PHP_EOL.PHP_EOL;
+ $output = 'Using config file: ' . self::$configDataFile . PHP_EOL . PHP_EOL;
$output .= $this->prepareConfigDataForDisplay($data);
throw new DeepExitException($output, ExitCode::OKAY);
case 'runtime-set':
if (isset($this->cliArgs[($pos + 1)]) === false
|| isset($this->cliArgs[($pos + 2)]) === false
) {
- $error = 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Setting a runtime config option requires a name and value' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -947,25 +947,25 @@ public function processLongArgument(string $arg, int $pos)
$dir = dirname($this->cacheFile);
if (is_dir($dir) === false) {
- $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified cache file path "' . $this->cacheFile . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
if ($dir === '.') {
// Passed cache file is a file in the current directory.
- $this->cacheFile = getcwd().'/'.basename($this->cacheFile);
+ $this->cacheFile = getcwd() . '/' . basename($this->cacheFile);
} else {
if ($dir[0] === '/') {
// An absolute path.
$dir = Common::realpath($dir);
} else {
- $dir = Common::realpath(getcwd().'/'.$dir);
+ $dir = Common::realpath(getcwd() . '/' . $dir);
}
if ($dir !== false) {
// Cache file path is relative.
- $this->cacheFile = $dir.'/'.basename($this->cacheFile);
+ $this->cacheFile = $dir . '/' . basename($this->cacheFile);
}
}
}//end if
@@ -973,7 +973,7 @@ public function processLongArgument(string $arg, int $pos)
$this->overriddenDefaults['cacheFile'] = true;
if (is_dir($this->cacheFile) === true) {
- $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified cache file path "' . $this->cacheFile . '" is a directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -983,7 +983,7 @@ public function processLongArgument(string $arg, int $pos)
foreach ($files as $file) {
$path = Common::realpath($file);
if ($path === false) {
- $error = 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified bootstrap file "' . $file . '" does not exist' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -997,7 +997,7 @@ public function processLongArgument(string $arg, int $pos)
$fileList = substr($arg, 10);
$path = Common::realpath($fileList);
if ($path === false) {
- $error = 'ERROR: The specified file list "'.$fileList.'" does not exist'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified file list "' . $fileList . '" does not exist' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1039,18 +1039,18 @@ public function processLongArgument(string $arg, int $pos)
$dir = Common::realpath(dirname($this->reportFile));
if (is_dir($dir) === false) {
- $error = 'ERROR: The specified report file path "'.$this->reportFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified report file path "' . $this->reportFile . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- $this->reportFile = $dir.'/'.basename($this->reportFile);
+ $this->reportFile = $dir . '/' . basename($this->reportFile);
}//end if
$this->overriddenDefaults['reportFile'] = true;
if (is_dir($this->reportFile) === true) {
- $error = 'ERROR: The specified report file path "'.$this->reportFile.'" is a directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified report file path "' . $this->reportFile . '" is a directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1083,7 +1083,7 @@ public function processLongArgument(string $arg, int $pos)
}
if (is_dir($this->basepath) === false) {
- $error = 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified basepath "' . $this->basepath . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1104,15 +1104,15 @@ public function processLongArgument(string $arg, int $pos)
} else {
$dir = Common::realpath(dirname($output));
if (is_dir($dir) === false) {
- $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified ' . $report . ' report file path "' . $output . '" points to a non-existent directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- $output = $dir.'/'.basename($output);
+ $output = $dir . '/' . basename($output);
if (is_dir($output) === true) {
- $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" is a directory'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The specified ' . $report . ' report file path "' . $output . '" is a directory' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1168,9 +1168,9 @@ public function processLongArgument(string $arg, int $pos)
// They specified the tokenizer too.
list($ext, $tokenizer) = explode('/', $ext);
if (strtoupper($tokenizer) !== 'PHP') {
- $error = 'ERROR: Specifying the tokenizer to use for an extension is no longer supported.'.PHP_EOL;
- $error .= 'PHP_CodeSniffer >= 4.0 only supports scanning PHP files.'.PHP_EOL;
- $error .= 'Received: '.substr($arg, 11).PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Specifying the tokenizer to use for an extension is no longer supported.' . PHP_EOL;
+ $error .= 'PHP_CodeSniffer >= 4.0 only supports scanning PHP files.' . PHP_EOL;
+ $error .= 'Received: ' . substr($arg, 11) . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1258,7 +1258,7 @@ public function processLongArgument(string $arg, int $pos)
$validOptions = implode(', ', self::VALID_GENERATORS);
$validOptions = substr_replace($validOptions, ' and', strrpos($validOptions, ','), 1);
$error = sprintf(
- 'ERROR: "%s" is not a valid generator. The following generators are supported: %s.'.PHP_EOL.PHP_EOL,
+ 'ERROR: "%s" is not a valid generator. The following generators are supported: %s.' . PHP_EOL . PHP_EOL,
$generatorName,
$validOptions
);
@@ -1301,7 +1301,7 @@ public function processLongArgument(string $arg, int $pos)
// Value is not valid, so just ignore it.
}
} else {
- $this->processUnknownArgument('--'.$arg, $pos);
+ $this->processUnknownArgument('--' . $arg, $pos);
}
}//end if
break;
@@ -1341,18 +1341,18 @@ private function parseSniffCodes(string $input, string $argument)
}
if ($partCount === 0) {
- $errors[] = 'Standard codes are not supported: '.$sniff;
+ $errors[] = 'Standard codes are not supported: ' . $sniff;
} else if ($partCount === 1) {
- $errors[] = 'Category codes are not supported: '.$sniff;
+ $errors[] = 'Category codes are not supported: ' . $sniff;
} else if ($partCount === 3) {
- $errors[] = 'Message codes are not supported: '.$sniff;
+ $errors[] = 'Message codes are not supported: ' . $sniff;
} else {
- $errors[] = 'Too many parts: '.$sniff;
+ $errors[] = 'Too many parts: ' . $sniff;
}
if ($partCount > 2) {
$parts = explode('.', $sniff, 4);
- $sniffs[] = $parts[0].'.'.$parts[1].'.'.$parts[2];
+ $sniffs[] = $parts[0] . '.' . $parts[1] . '.' . $parts[2];
}
}//end foreach
@@ -1376,15 +1376,15 @@ static function ($carry, $item) {
);
if ($errors !== []) {
- $error = 'ERROR: The --'.$argument.' option only supports sniff codes.'.PHP_EOL;
- $error .= 'Sniff codes are in the form "Standard.Category.Sniff".'.PHP_EOL;
+ $error = 'ERROR: The --' . $argument . ' option only supports sniff codes.' . PHP_EOL;
+ $error .= 'Sniff codes are in the form "Standard.Category.Sniff".' . PHP_EOL;
$error .= PHP_EOL;
- $error .= 'The following problems were detected:'.PHP_EOL;
- $error .= '* '.implode(PHP_EOL.'* ', $errors).PHP_EOL;
+ $error .= 'The following problems were detected:' . PHP_EOL;
+ $error .= '* ' . implode(PHP_EOL . '* ', $errors) . PHP_EOL;
if ($sniffs !== []) {
$error .= PHP_EOL;
- $error .= 'Perhaps try --'.$argument.'="'.implode(',', $sniffs).'" instead.'.PHP_EOL;
+ $error .= 'Perhaps try --' . $argument . '="' . implode(',', $sniffs) . '" instead.' . PHP_EOL;
}
$error .= PHP_EOL;
@@ -1416,7 +1416,7 @@ public function processUnknownArgument(string $arg, int $pos)
return;
}
- $error = "ERROR: option \"$arg\" not known".PHP_EOL.PHP_EOL;
+ $error = "ERROR: option \"$arg\" not known" . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1447,7 +1447,7 @@ public function processFilePath(string $path)
return;
}
- $error = 'ERROR: The file "'.$path.'" does not exist.'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: The file "' . $path . '" does not exist.' . PHP_EOL . PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
} else {
@@ -1498,7 +1498,7 @@ public function printShortUsage(bool $returnOutput = false)
$usage = 'Run "phpcs --help" for usage information';
}
- $usage .= PHP_EOL.PHP_EOL;
+ $usage .= PHP_EOL . PHP_EOL;
if ($returnOutput === true) {
return $usage;
@@ -1528,7 +1528,7 @@ public function printPHPCSUsage()
$longOptions[] = 'config-show';
$longOptions[] = 'generator';
- $shortOptions = Help::DEFAULT_SHORT_OPTIONS.'aems';
+ $shortOptions = Help::DEFAULT_SHORT_OPTIONS . 'aems';
(new Help($this, $longOptions, $shortOptions))->display();
@@ -1587,7 +1587,7 @@ public static function getConfigData(string $key)
*/
public static function getExecutablePath(string $name)
{
- $data = self::getConfigData($name.'_path');
+ $data = self::getConfigData($name . '_path');
if ($data !== null) {
return $data;
}
@@ -1602,9 +1602,9 @@ public static function getExecutablePath(string $name)
}
if (PHP_OS_FAMILY === 'Windows') {
- $cmd = 'where '.escapeshellarg($name).' 2> nul';
+ $cmd = 'where ' . escapeshellarg($name) . ' 2> nul';
} else {
- $cmd = 'which '.escapeshellarg($name).' 2> /dev/null';
+ $cmd = 'which ' . escapeshellarg($name) . ' 2> /dev/null';
}
$result = exec($cmd, $output, $retVal);
@@ -1648,15 +1648,15 @@ public function setConfigData(string $key, ?string $value, bool $temp = false)
}
if ($path !== '') {
- $configFile = dirname($path).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
+ $configFile = dirname($path) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
} else {
- $configFile = dirname(__DIR__).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
+ $configFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
}
if (is_file($configFile) === true
&& is_writable($configFile) === false
) {
- $error = 'ERROR: Config file '.$configFile.' is not writable'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Config file ' . $configFile . ' is not writable' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
}//end if
@@ -1672,12 +1672,12 @@ public function setConfigData(string $key, ?string $value, bool $temp = false)
}
if ($temp === false) {
- $output = '<'.'?php'."\n".' $phpCodeSnifferConfig = ';
+ $output = '<' . '?php' . "\n" . ' $phpCodeSnifferConfig = ';
$output .= var_export($phpCodeSnifferConfig, true);
- $output .= ";\n?".'>';
+ $output .= ";\n?" . '>';
if (file_put_contents($configFile, $output) === false) {
- $error = 'ERROR: Config file '.$configFile.' could not be written'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Config file ' . $configFile . ' could not be written' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1719,9 +1719,9 @@ public static function getAllConfigData()
}
if ($path !== '') {
- $configFile = dirname($path).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
+ $configFile = dirname($path) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
} else {
- $configFile = dirname(__DIR__).DIRECTORY_SEPARATOR.'CodeSniffer.conf';
+ $configFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'CodeSniffer.conf';
}
if (is_file($configFile) === false) {
@@ -1730,7 +1730,7 @@ public static function getAllConfigData()
}
if (Common::isReadable($configFile) === false) {
- $error = 'ERROR: Config file '.$configFile.' is not readable'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Config file ' . $configFile . ' is not readable' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -1769,7 +1769,7 @@ public function prepareConfigDataForDisplay(array $data)
$output = '';
foreach ($data as $name => $value) {
- $output .= str_pad($name.': ', $max).$value.PHP_EOL;
+ $output .= str_pad($name . ': ', $max) . $value . PHP_EOL;
}
return $output;
diff --git a/src/Files/File.php b/src/Files/File.php
index a9fe55b431..f2be65e770 100644
--- a/src/Files/File.php
+++ b/src/Files/File.php
@@ -453,7 +453,7 @@ public function process()
$pattern = str_replace('/', '\\\\', $pattern);
}
- $pattern = '`'.$pattern.'`i';
+ $pattern = '`' . $pattern . '`i';
if (preg_match($pattern, $this->path) === 1) {
$this->ignoredListeners[$class] = true;
continue(2);
@@ -473,7 +473,7 @@ public function process()
$pattern = str_replace('/', '\\\\', $pattern);
}
- $pattern = '`'.$pattern.'`i';
+ $pattern = '`' . $pattern . '`i';
if (preg_match($pattern, $this->path) === 1) {
$included = true;
break;
@@ -494,7 +494,7 @@ public function process()
}
if (PHP_CODESNIFFER_VERBOSITY > 2) {
- StatusWriter::write('Processing '.$this->activeListener.'... ', 3, 0);
+ StatusWriter::write('Processing ' . $this->activeListener . '... ', 3, 0);
}
$ignoreTo = $this->ruleset->sniffs[$class]->process($this, $stackPtr);
@@ -540,7 +540,7 @@ public function process()
arsort($this->listenerTimes, SORT_NUMERIC);
foreach ($this->listenerTimes as $listener => $timeTaken) {
- StatusWriter::write("$listener: ".round(($timeTaken), 4).' secs', 1);
+ StatusWriter::write("$listener: " . round(($timeTaken), 4) . ' secs', 1);
}
StatusWriter::write('*** END SNIFF PROCESSING REPORT ***', 1);
@@ -883,14 +883,14 @@ protected function addMessage(
$listenerCode = substr($sniffCode, 0, strrpos($sniffCode, '.'));
} else {
$listenerCode = Common::getSniffCode($this->activeListener);
- $sniffCode = $listenerCode.'.'.$code;
+ $sniffCode = $listenerCode . '.' . $code;
$parts = explode('.', $sniffCode);
}
$checkCodes = [
$sniffCode,
- $parts[0].'.'.$parts[1].'.'.$parts[2],
- $parts[0].'.'.$parts[1],
+ $parts[0] . '.' . $parts[1] . '.' . $parts[2],
+ $parts[0] . '.' . $parts[1],
$parts[0],
];
}//end if
@@ -1008,7 +1008,7 @@ protected function addMessage(
$replacements['/'] = '\\\\';
}
- $pattern = '`'.strtr($pattern, $replacements).'`i';
+ $pattern = '`' . strtr($pattern, $replacements) . '`i';
$matched = preg_match($pattern, $this->path);
if ($matched === 0) {
@@ -1329,7 +1329,7 @@ public function getDeclarationName(int $stackPtr)
&& $tokenCode !== T_TRAIT
&& $tokenCode !== T_ENUM
) {
- throw new RuntimeException('Token type "'.$this->tokens[$stackPtr]['type'].'" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM');
+ throw new RuntimeException('Token type "' . $this->tokens[$stackPtr]['type'] . '" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM');
}
$stopPoint = $this->numTokens;
@@ -1856,7 +1856,7 @@ public function getMethodProperties(int $stackPtr)
}//end if
if ($returnType !== '' && $nullableReturnType === true) {
- $returnType = '?'.$returnType;
+ $returnType = '?' . $returnType;
}
return [
@@ -2054,7 +2054,7 @@ public function getMemberProperties(int $stackPtr)
}
if ($type !== '' && $nullableType === true) {
- $type = '?'.$type;
+ $type = '?' . $type;
}
}//end if
diff --git a/src/Files/FileList.php b/src/Files/FileList.php
index 315978421b..a7b856a460 100644
--- a/src/Files/FileList.php
+++ b/src/Files/FileList.php
@@ -83,7 +83,7 @@ public function __construct(Config $config, Ruleset $ruleset)
$isPharFile = Common::isPharFile($path);
if (is_dir($path) === true || $isPharFile === true) {
if ($isPharFile === true) {
- $path = 'phar://'.$path;
+ $path = 'phar://' . $path;
}
$filterClass = $this->getFilterClass();
@@ -163,13 +163,13 @@ private function getFilterClass()
// This is a path to a custom filter class.
$filename = realpath($filterType);
if ($filename === false) {
- $error = "ERROR: Custom filter \"$filterType\" not found".PHP_EOL;
+ $error = "ERROR: Custom filter \"$filterType\" not found" . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
$filterClass = Autoload::loadFile($filename);
} else {
- $filterClass = '\PHP_CodeSniffer\Filters\\'.$filterType;
+ $filterClass = '\PHP_CodeSniffer\Filters\\' . $filterType;
}
}
diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php
index 7f20ad6b36..cf9ea478da 100644
--- a/src/Filters/Filter.php
+++ b/src/Filters/Filter.php
@@ -248,7 +248,7 @@ protected function shouldIgnorePath(string $path)
// Need to check this pattern for dirs as well as individual file paths.
$this->ignoreFilePatterns[$pattern] = $type;
- $pattern = substr($pattern, 0, -2).'(?=/|$)';
+ $pattern = substr($pattern, 0, -2) . '(?=/|$)';
$this->ignoreDirPatterns[$pattern] = $type;
} else {
// This is a file-specific pattern, so only need to check this
@@ -291,7 +291,7 @@ protected function shouldIgnorePath(string $path)
$testPath = $path;
}
- $pattern = '`'.$pattern.'`i';
+ $pattern = '`' . $pattern . '`i';
if (preg_match($pattern, $testPath) === 1) {
return true;
}
diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php
index afc445d6f4..b5cd7d5e3b 100644
--- a/src/Filters/GitModified.php
+++ b/src/Filters/GitModified.php
@@ -40,7 +40,7 @@ protected function getAllowedFiles()
{
$modified = [];
- $cmd = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir);
+ $cmd = 'git ls-files -o -m --exclude-standard -- ' . escapeshellarg($this->basedir);
$output = $this->exec($cmd);
$basedir = $this->basedir;
diff --git a/src/Filters/GitStaged.php b/src/Filters/GitStaged.php
index fe32bb35a5..b51337119c 100644
--- a/src/Filters/GitStaged.php
+++ b/src/Filters/GitStaged.php
@@ -42,7 +42,7 @@ protected function getAllowedFiles()
{
$modified = [];
- $cmd = 'git diff --cached --name-only -- '.escapeshellarg($this->basedir);
+ $cmd = 'git diff --cached --name-only -- ' . escapeshellarg($this->basedir);
$output = $this->exec($cmd);
$basedir = $this->basedir;
diff --git a/src/Fixer.php b/src/Fixer.php
index 7a2766ab8b..59e0e7acc8 100644
--- a/src/Fixer.php
+++ b/src/Fixer.php
@@ -169,7 +169,7 @@ public function fixFile()
$max = strlen(count($lines));
foreach ($lines as $lineNum => $line) {
$lineNum++;
- StatusWriter::forceWrite(str_pad($lineNum, $max, ' ', STR_PAD_LEFT).'|'.$line);
+ StatusWriter::forceWrite(str_pad($lineNum, $max, ' ', STR_PAD_LEFT) . '|' . $line);
}
StatusWriter::forceWrite('--- END FILE CONTENT ---');
@@ -183,7 +183,7 @@ public function fixFile()
$this->loops++;
if (PHP_CODESNIFFER_CBF === true && PHP_CODESNIFFER_VERBOSITY > 0) {
- StatusWriter::forceWrite("\r".str_repeat(' ', 80)."\r", 0, 0);
+ StatusWriter::forceWrite("\r" . str_repeat(' ', 80) . "\r", 0, 0);
$statusMessage = "=> Fixing file: $this->numFixes/$fixable violations remaining [made $this->loops pass";
if ($this->loops > 1) {
$statusMessage .= 'es';
@@ -202,7 +202,7 @@ public function fixFile()
// Nothing left to do.
break;
} else if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::forceWrite("* fixed $this->numFixes violations, starting loop ".($this->loops + 1).' *', 1);
+ StatusWriter::forceWrite("* fixed $this->numFixes violations, starting loop " . ($this->loops + 1) . ' *', 1);
}
}//end while
@@ -241,7 +241,7 @@ public function generateDiff(?string $filePath = null, bool $colors = true)
$filePath = $this->currentFile->getFilename();
}
- $cwd = getcwd().DIRECTORY_SEPARATOR;
+ $cwd = getcwd() . DIRECTORY_SEPARATOR;
if (strpos($filePath, $cwd) === 0) {
$filename = substr($filePath, strlen($cwd));
} else {
@@ -609,7 +609,7 @@ public function replaceToken(int $stackPtr, string $content)
$statusMessage = "$sniff:$line replaced token $stackPtr ($type on line $tokenLine) \"$oldContent\" => \"$newContent\"";
$depth = 1;
if (empty($this->changeset) === false) {
- $statusMessage = 'A: '.$statusMessage;
+ $statusMessage = 'A: ' . $statusMessage;
$depth = 2;
}
@@ -667,7 +667,7 @@ public function revertToken(int $stackPtr)
$statusMessage = "$sniff:$line reverted token $stackPtr ($type on line $tokenLine) \"$oldContent\" => \"$newContent\"";
$depth = 1;
if (empty($this->changeset) === false) {
- $statusMessage = 'R: '.$statusMessage;
+ $statusMessage = 'R: ' . $statusMessage;
$depth = 2;
}
@@ -714,7 +714,7 @@ public function substrToken(int $stackPtr, int $start, ?int $length = null)
public function addNewline(int $stackPtr)
{
$current = $this->getTokenContent($stackPtr);
- return $this->replaceToken($stackPtr, $current.$this->currentFile->eolChar);
+ return $this->replaceToken($stackPtr, $current . $this->currentFile->eolChar);
}//end addNewline()
@@ -729,7 +729,7 @@ public function addNewline(int $stackPtr)
public function addNewlineBefore(int $stackPtr)
{
$current = $this->getTokenContent($stackPtr);
- return $this->replaceToken($stackPtr, $this->currentFile->eolChar.$current);
+ return $this->replaceToken($stackPtr, $this->currentFile->eolChar . $current);
}//end addNewlineBefore()
@@ -745,7 +745,7 @@ public function addNewlineBefore(int $stackPtr)
public function addContent(int $stackPtr, string $content)
{
$current = $this->getTokenContent($stackPtr);
- return $this->replaceToken($stackPtr, $current.$content);
+ return $this->replaceToken($stackPtr, $current . $content);
}//end addContent()
@@ -761,7 +761,7 @@ public function addContent(int $stackPtr, string $content)
public function addContentBefore(int $stackPtr, string $content)
{
$current = $this->getTokenContent($stackPtr);
- return $this->replaceToken($stackPtr, $content.$current);
+ return $this->replaceToken($stackPtr, $content . $current);
}//end addContentBefore()
@@ -813,9 +813,9 @@ public function changeCodeBlockIndent(int $start, int $end, int $change)
$padding = '';
}
- $newContent = $padding.ltrim($tokens[$i]['content']);
+ $newContent = $padding . ltrim($tokens[$i]['content']);
} else {
- $newContent = $baseIndent.$tokens[$i]['content'];
+ $newContent = $baseIndent . $tokens[$i]['content'];
}
$this->replaceToken($i, $newContent);
diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php
index ca4b9939ea..0fac2e0969 100644
--- a/src/Generators/Generator.php
+++ b/src/Generators/Generator.php
@@ -51,11 +51,11 @@ public function __construct(Ruleset $ruleset)
$this->ruleset = $ruleset;
$find = [
- DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR,
+ DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR,
'Sniff.php',
];
$replace = [
- DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR,
+ DIRECTORY_SEPARATOR . 'Docs' . DIRECTORY_SEPARATOR,
'Standard.xml',
];
@@ -126,7 +126,7 @@ public function generate()
$documentation = $doc->getElementsByTagName('documentation')->item(0);
if (($documentation instanceof DOMNode) === false) {
throw new GeneratorException(
- 'Missing top-level element in XML documentation file '.$file
+ 'Missing top-level element in XML documentation file ' . $file
);
}
diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php
index c2282f24ff..35d8c6f403 100644
--- a/src/Generators/HTML.php
+++ b/src/Generators/HTML.php
@@ -189,7 +189,7 @@ protected function getFormattedHeader()
);
// Use the correct line endings based on the OS.
- return str_replace("\n", PHP_EOL, $output).PHP_EOL;
+ return str_replace("\n", PHP_EOL, $output) . PHP_EOL;
}//end getFormattedHeader()
@@ -211,10 +211,10 @@ protected function getFormattedToc()
return '';
}
- $output = ' Table of Contents
'.PHP_EOL;
- $output .= ' '.PHP_EOL;
+ $output = ' Table of Contents
' . PHP_EOL;
+ $output .= ' ' . PHP_EOL;
- $listItemTemplate = ' - %s
'.PHP_EOL;
+ $listItemTemplate = ' - %s
' . PHP_EOL;
foreach ($this->docFiles as $file) {
$doc = new DOMDocument();
@@ -224,7 +224,7 @@ protected function getFormattedToc()
$output .= sprintf($listItemTemplate, $this->titleToAnchor($title), $title);
}
- $output .= '
'.PHP_EOL;
+ $output .= '
' . PHP_EOL;
return $output;
@@ -254,7 +254,7 @@ protected function getFormattedFooter()
error_reporting($errorLevel);
// Use the correct line endings based on the OS.
- return str_replace("\n", PHP_EOL, $output).PHP_EOL;
+ return str_replace("\n", PHP_EOL, $output) . PHP_EOL;
}//end getFormattedFooter()
@@ -282,7 +282,7 @@ public function processSniff(DOMElement $doc)
if (trim($content) !== '') {
$title = $this->getTitle($doc);
printf(
- ' %2$s §
'.PHP_EOL,
+ ' %2$s §
' . PHP_EOL,
$this->titleToAnchor($title),
$title
);
@@ -309,8 +309,8 @@ private function titleToAnchor(string $title)
if (isset($this->seenAnchors[$title]) === true) {
// Try to find a unique anchor for this title.
- for ($i = 2; (isset($this->seenAnchors[$title.'-'.$i]) === true); $i++);
- $title .= '-'.$i;
+ for ($i = 2; (isset($this->seenAnchors[$title . '-' . $i]) === true); $i++);
+ $title .= '-' . $i;
}
// Add to "seen" list.
@@ -360,16 +360,16 @@ protected function getFormattedTextBlock(DOMNode $node)
if ($nextLine === '') {
// Next line is a blank line, end the paragraph and start a new one.
// Also skip over the blank line.
- $lines[] = $currentLine.'
'.PHP_EOL.' ';
+ $lines[] = $currentLine . '
' . PHP_EOL . ' ';
++$i;
} else {
// Next line is not blank, so just add a line break.
- $lines[] = $currentLine.'
'.PHP_EOL;
+ $lines[] = $currentLine . '
' . PHP_EOL;
}
}
}
- return '
'.implode('', $lines).'
'.PHP_EOL;
+ return ' ' . implode('', $lines) . '
' . PHP_EOL;
}//end getFormattedTextBlock()
@@ -403,26 +403,26 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
$titleRow = '';
if ($firstTitle !== '' || $secondTitle !== '') {
- $titleRow .= ' '.PHP_EOL;
- $titleRow .= " $firstTitle | ".PHP_EOL;
- $titleRow .= " $secondTitle | ".PHP_EOL;
- $titleRow .= '
'.PHP_EOL;
+ $titleRow .= ' ' . PHP_EOL;
+ $titleRow .= " $firstTitle | " . PHP_EOL;
+ $titleRow .= " $secondTitle | " . PHP_EOL;
+ $titleRow .= '
' . PHP_EOL;
}
$codeRow = '';
if ($first !== '' || $second !== '') {
- $codeRow .= ' '.PHP_EOL;
- $codeRow .= " $first | ".PHP_EOL;
- $codeRow .= " $second | ".PHP_EOL;
- $codeRow .= '
'.PHP_EOL;
+ $codeRow .= ' ' . PHP_EOL;
+ $codeRow .= " $first | " . PHP_EOL;
+ $codeRow .= " $second | " . PHP_EOL;
+ $codeRow .= '
' . PHP_EOL;
}
$output = '';
if ($titleRow !== '' || $codeRow !== '') {
- $output = ' '.PHP_EOL;
+ $output = ' ' . PHP_EOL;
$output .= $titleRow;
$output .= $codeRow;
- $output .= '
'.PHP_EOL;
+ $output .= '
' . PHP_EOL;
}
return $output;
diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php
index fcad3b519f..7f4ecaeaf4 100644
--- a/src/Generators/Markdown.php
+++ b/src/Generators/Markdown.php
@@ -70,7 +70,7 @@ protected function getFormattedHeader()
{
$standard = $this->ruleset->name;
- return "# $standard Coding Standard".PHP_EOL;
+ return "# $standard Coding Standard" . PHP_EOL;
}//end getFormattedHeader()
@@ -88,8 +88,8 @@ protected function getFormattedFooter()
// Turn off errors so we don't get timezone warnings if people
// don't have their timezone set.
$errorLevel = error_reporting(0);
- $output = PHP_EOL.'Documentation generated on '.date('r');
- $output .= ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL;
+ $output = PHP_EOL . 'Documentation generated on ' . date('r');
+ $output .= ' by [PHP_CodeSniffer ' . Config::VERSION . '](https://github.com/PHPCSStandards/PHP_CodeSniffer)' . PHP_EOL;
error_reporting($errorLevel);
return $output;
@@ -119,7 +119,7 @@ protected function processSniff(DOMElement $doc)
if (trim($content) !== '') {
$title = $this->getTitle($doc);
- echo PHP_EOL."## $title".PHP_EOL.PHP_EOL;
+ echo PHP_EOL . "## $title" . PHP_EOL . PHP_EOL;
echo $content;
}
@@ -168,11 +168,11 @@ protected function getFormattedTextBlock(DOMNode $node)
$lines[] = $currentLine;
} else {
// Ensure that line breaks are respected in markdown.
- $lines[] = $currentLine.' ';
+ $lines[] = $currentLine . ' ';
}
}
- return implode(PHP_EOL, $lines).PHP_EOL;
+ return implode(PHP_EOL, $lines) . PHP_EOL;
}//end getFormattedTextBlock()
@@ -206,30 +206,30 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
$titleRow = '';
if ($firstTitle !== '' || $secondTitle !== '') {
- $titleRow .= ' '.PHP_EOL;
- $titleRow .= " $firstTitle | ".PHP_EOL;
- $titleRow .= " $secondTitle | ".PHP_EOL;
- $titleRow .= '
'.PHP_EOL;
+ $titleRow .= ' ' . PHP_EOL;
+ $titleRow .= " $firstTitle | " . PHP_EOL;
+ $titleRow .= " $secondTitle | " . PHP_EOL;
+ $titleRow .= '
' . PHP_EOL;
}
$codeRow = '';
if ($first !== '' || $second !== '') {
- $codeRow .= ' '.PHP_EOL;
- $codeRow .= ''.PHP_EOL.PHP_EOL;
- $codeRow .= " $first".PHP_EOL.PHP_EOL;
- $codeRow .= ' | '.PHP_EOL;
- $codeRow .= ''.PHP_EOL.PHP_EOL;
- $codeRow .= " $second".PHP_EOL.PHP_EOL;
- $codeRow .= ' | '.PHP_EOL;
- $codeRow .= '
'.PHP_EOL;
+ $codeRow .= ' ' . PHP_EOL;
+ $codeRow .= '' . PHP_EOL . PHP_EOL;
+ $codeRow .= " $first" . PHP_EOL . PHP_EOL;
+ $codeRow .= ' | ' . PHP_EOL;
+ $codeRow .= '' . PHP_EOL . PHP_EOL;
+ $codeRow .= " $second" . PHP_EOL . PHP_EOL;
+ $codeRow .= ' | ' . PHP_EOL;
+ $codeRow .= '
' . PHP_EOL;
}
$output = '';
if ($titleRow !== '' || $codeRow !== '') {
- $output .= ' '.PHP_EOL;
+ $output .= ' ' . PHP_EOL;
$output .= $titleRow;
$output .= $codeRow;
- $output .= '
'.PHP_EOL;
+ $output .= '
' . PHP_EOL;
}
return $output;
@@ -267,7 +267,7 @@ private function formatCodeSample(DOMElement $codeElm)
{
$code = (string) $codeElm->nodeValue;
$code = trim($code);
- $code = str_replace("\n", PHP_EOL.' ', $code);
+ $code = str_replace("\n", PHP_EOL . ' ', $code);
$code = str_replace(['', ''], '', $code);
return $code;
diff --git a/src/Generators/Text.php b/src/Generators/Text.php
index dbc5908e09..81d5b362ba 100644
--- a/src/Generators/Text.php
+++ b/src/Generators/Text.php
@@ -68,9 +68,9 @@ protected function getFormattedTitle(DOMElement $doc)
$output = PHP_EOL;
$output .= str_repeat('-', ($titleLength + 4));
- $output .= strtoupper(PHP_EOL."| $displayTitle |".PHP_EOL);
+ $output .= strtoupper(PHP_EOL . "| $displayTitle |" . PHP_EOL);
$output .= str_repeat('-', ($titleLength + 4));
- $output .= PHP_EOL.PHP_EOL;
+ $output .= PHP_EOL . PHP_EOL;
return $output;
@@ -101,7 +101,7 @@ protected function getFormattedTextBlock(DOMNode $node)
$nodeLines = array_map('trim', $nodeLines);
$text = implode(PHP_EOL, $nodeLines);
- return wordwrap($text, 100, PHP_EOL).PHP_EOL.PHP_EOL;
+ return wordwrap($text, 100, PHP_EOL) . PHP_EOL . PHP_EOL;
}//end getFormattedTextBlock()
@@ -136,20 +136,20 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
$titleRow = '';
if ($firstTitleLines !== [] || $secondTitleLines !== []) {
$titleRow = $this->linesToTableRows($firstTitleLines, $secondTitleLines);
- $titleRow .= str_repeat('-', 100).PHP_EOL;
+ $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;
+ $codeRow .= str_repeat('-', 100) . PHP_EOL . PHP_EOL;
}//end if
$output = '';
if ($titleRow !== '' || $codeRow !== '') {
$output = str_repeat('-', 41);
$output .= ' CODE COMPARISON ';
- $output .= str_repeat('-', 42).PHP_EOL;
+ $output .= str_repeat('-', 42) . PHP_EOL;
$output .= $titleRow;
$output .= $codeRow;
}
@@ -224,10 +224,10 @@ private function linesToTableRows(array $column1Lines, array $column2Lines)
$column2Text = ($column2Lines[$i] ?? '');
$rows .= '| ';
- $rows .= $column1Text.str_repeat(' ', max(0, (47 - strlen($column1Text))));
+ $rows .= $column1Text . str_repeat(' ', max(0, (47 - strlen($column1Text))));
$rows .= '| ';
- $rows .= $column2Text.str_repeat(' ', max(0, (48 - strlen($column2Text))));
- $rows .= '|'.PHP_EOL;
+ $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 38c2388449..fdf2258806 100644
--- a/src/Reporter.php
+++ b/src/Reporter.php
@@ -123,14 +123,14 @@ public function __construct(Config $config)
// This is a path to a custom report class.
$filename = realpath($type);
if ($filename === false) {
- $error = "ERROR: Custom report \"$type\" not found".PHP_EOL;
+ $error = "ERROR: Custom report \"$type\" not found" . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
$reportClassName = Autoload::loadFile($filename);
- } else if (class_exists('PHP_CodeSniffer\Reports\\'.ucfirst($type)) === true) {
+ } else if (class_exists('PHP_CodeSniffer\Reports\\' . ucfirst($type)) === true) {
// PHPCS native report.
- $reportClassName = 'PHP_CodeSniffer\Reports\\'.ucfirst($type);
+ $reportClassName = 'PHP_CodeSniffer\Reports\\' . ucfirst($type);
} else if (class_exists($type) === true) {
// FQN of a custom report.
$reportClassName = $type;
@@ -144,21 +144,21 @@ public function __construct(Config $config)
continue;
}
- if (class_exists($nsPrefix.'\\'.$trimmedType) === true) {
- $reportClassName = $nsPrefix.'\\'.$trimmedType;
+ if (class_exists($nsPrefix . '\\' . $trimmedType) === true) {
+ $reportClassName = $nsPrefix . '\\' . $trimmedType;
break;
}
}
}//end if
if ($reportClassName === '') {
- $error = "ERROR: Class file for report \"$type\" not found".PHP_EOL;
+ $error = "ERROR: Class file for report \"$type\" not found" . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
$reportClass = new $reportClassName();
if (($reportClass instanceof Report) === false) {
- throw new RuntimeException('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer\Report" interface.');
+ throw new RuntimeException('Class "' . $reportClassName . '" must implement the "PHP_CodeSniffer\Report" interface.');
}
$this->reports[$type] = [
@@ -333,7 +333,7 @@ public function printReport(string $report)
echo $generatedReport;
}
- file_put_contents($reportFile, $generatedReport.PHP_EOL);
+ file_put_contents($reportFile, $generatedReport . PHP_EOL);
} else {
echo $generatedReport;
if ($filename !== null && file_exists($filename) === true) {
diff --git a/src/Reports/Cbf.php b/src/Reports/Cbf.php
index a0814f5a70..2d64007b13 100644
--- a/src/Reports/Cbf.php
+++ b/src/Reports/Cbf.php
@@ -82,16 +82,16 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
StatusWriter::forceWrite('DONE', 0, 0);
}
- StatusWriter::forceWrite(' in '.Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)));
+ StatusWriter::forceWrite(' in ' . Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)));
}
if ($fixed === true) {
// The filename in the report may be truncated due to a basepath setting
// but we are using it for writing here and not display,
// so find the correct path if basepath is in use.
- $newFilename = $report['filename'].$phpcsFile->config->suffix;
+ $newFilename = $report['filename'] . $phpcsFile->config->suffix;
if ($phpcsFile->config->basepath !== null) {
- $newFilename = $phpcsFile->config->basepath.DIRECTORY_SEPARATOR.$newFilename;
+ $newFilename = $phpcsFile->config->basepath . DIRECTORY_SEPARATOR . $newFilename;
}
$newContent = $phpcsFile->fixer->getContents();
@@ -101,7 +101,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
if ($newFilename === $report['filename']) {
StatusWriter::forceWrite('=> File was overwritten', 1);
} else {
- StatusWriter::forceWrite('=> Fixed file written to '.basename($newFilename), 1);
+ StatusWriter::forceWrite('=> Fixed file written to ' . basename($newFilename), 1);
}
}
}
@@ -110,7 +110,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$warningCount = $phpcsFile->getWarningCount();
$fixableCount = $phpcsFile->getFixableCount();
$fixedCount = ($errors - $fixableCount);
- echo $report['filename'].">>$errorCount>>$warningCount>>$fixableCount>>$fixedCount".PHP_EOL;
+ echo $report['filename'] . ">>$errorCount>>$warningCount>>$fixableCount>>$fixedCount" . PHP_EOL;
return $fixed;
@@ -187,22 +187,22 @@ public function generate(
$width = min($width, ($maxLength + 21));
$width = max($width, 70);
- echo PHP_EOL."\033[1m".'PHPCBF RESULT SUMMARY'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
- echo "\033[1m".'FILE'.str_repeat(' ', ($width - 20)).'FIXED REMAINING'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . "\033[1m" . 'PHPCBF RESULT SUMMARY' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
+ echo "\033[1m" . 'FILE' . str_repeat(' ', ($width - 20)) . 'FIXED REMAINING' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
foreach ($reportFiles as $file => $data) {
$padding = ($width - 18 - $data['strlen']);
if ($padding < 0) {
- $file = '...'.substr($file, (($padding * -1) + 3));
+ $file = '...' . substr($file, (($padding * -1) + 3));
$padding = 0;
}
- echo $file.str_repeat(' ', $padding).' ';
+ echo $file . str_repeat(' ', $padding) . ' ';
if ($data['fixable'] > 0) {
- echo "\033[31mFAILED TO FIX\033[0m".PHP_EOL;
+ echo "\033[31mFAILED TO FIX\033[0m" . PHP_EOL;
continue;
}
@@ -224,14 +224,14 @@ public function generate(
echo PHP_EOL;
}//end foreach
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
echo "\033[1mA TOTAL OF $totalFixed ERROR";
if ($totalFixed !== 1) {
echo 'S';
}
$numFiles = count($reportFiles);
- echo ' WERE FIXED IN '.$numFiles.' FILE';
+ echo ' WERE FIXED IN ' . $numFiles . ' FILE';
if ($numFiles !== 1) {
echo 'S';
}
@@ -239,7 +239,7 @@ public function generate(
echo "\033[0m";
if ($failures > 0) {
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
echo "\033[1mPHPCBF FAILED TO FIX $failures FILE";
if ($failures !== 1) {
echo 'S';
@@ -248,7 +248,7 @@ public function generate(
echo "\033[0m";
}
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Checkstyle.php b/src/Reports/Checkstyle.php
index 64ec36fa82..861411a82a 100644
--- a/src/Reports/Checkstyle.php
+++ b/src/Reports/Checkstyle.php
@@ -100,10 +100,10 @@ public function generate(
bool $interactive = false,
bool $toScreen = true
) {
- echo ''.PHP_EOL;
- echo ''.PHP_EOL;
+ echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
echo $cachedData;
- echo ''.PHP_EOL;
+ echo '' . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Code.php b/src/Reports/Code.php
index 05ab6e353c..15e86ae16f 100644
--- a/src/Reports/Code.php
+++ b/src/Reports/Code.php
@@ -49,7 +49,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
if (empty($tokens) === true) {
if (PHP_CODESNIFFER_VERBOSITY === 1) {
$startTime = microtime(true);
- StatusWriter::forceWrite('CODE report is parsing '.basename($file).' ', 0, 0);
+ StatusWriter::forceWrite('CODE report is parsing ' . basename($file) . ' ', 0, 0);
} else if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::forceWrite("CODE report is forcing parse of $file");
}
@@ -66,7 +66,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
}
if (PHP_CODESNIFFER_VERBOSITY === 1) {
- StatusWriter::forceWrite('DONE in '.Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)));
+ StatusWriter::forceWrite('DONE in ' . Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)));
}
$tokens = $phpcsFile->getTokens();
@@ -163,34 +163,34 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
}
// Print the file header.
- echo PHP_EOL."\033[1mFILE: ";
+ echo PHP_EOL . "\033[1mFILE: ";
if ($fileLength <= ($width - 6)) {
echo $file;
} else {
- echo '...'.substr($file, ($fileLength - ($width - 6)));
+ echo '...' . substr($file, ($fileLength - ($width - 6)));
}
- echo "\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
- echo "\033[1m".'FOUND '.$report['errors'].' ERROR';
+ echo "\033[1m" . 'FOUND ' . $report['errors'] . ' ERROR';
if ($report['errors'] !== 1) {
echo 'S';
}
if ($report['warnings'] > 0) {
- echo ' AND '.$report['warnings'].' WARNING';
+ echo ' AND ' . $report['warnings'] . ' WARNING';
if ($report['warnings'] !== 1) {
echo 'S';
}
}
- echo ' AFFECTING '.count($report['messages']).' LINE';
+ echo ' AFFECTING ' . count($report['messages']) . ' LINE';
if (count($report['messages']) !== 1) {
echo 'S';
}
- echo "\033[0m".PHP_EOL;
+ echo "\033[0m" . PHP_EOL;
foreach ($report['messages'] as $line => $lineErrors) {
$startLine = max(($line - $surroundingLines), 1);
@@ -203,13 +203,13 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
if ($lineTokens[$snippetLine]['start'] === $i) {
// Starting a new line.
if ($snippetLine === $line) {
- $snippet .= "\033[1m".'>> ';
+ $snippet .= "\033[1m" . '>> ';
} else {
$snippet .= ' ';
}
$snippet .= str_repeat(' ', ($maxLineNumLength - strlen($snippetLine)));
- $snippet .= $snippetLine.': ';
+ $snippet .= $snippetLine . ': ';
if ($snippetLine === $line) {
$snippet .= "\033[0m";
}
@@ -244,7 +244,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
// Underline invisible characters as well.
if ($underline === true && trim($tokenContent) === '') {
- $snippet .= "\033[4m".' '."\033[0m".$tokenContent;
+ $snippet .= "\033[4m" . ' ' . "\033[0m" . $tokenContent;
} else {
if ($underline === true) {
$snippet .= "\033[4m";
@@ -259,12 +259,12 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
}//end for
}//end if
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
foreach ($lineErrors as $colErrors) {
foreach ($colErrors as $error) {
$padding = ($maxLineNumLength - strlen($line));
- echo 'LINE '.str_repeat(' ', $padding).$line.': ';
+ echo 'LINE ' . str_repeat(' ', $padding) . $line . ': ';
if ($error['type'] === 'ERROR') {
echo "\033[31mERROR\033[0m";
@@ -288,29 +288,29 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
}
$message = $error['message'];
- $message = str_replace("\n", "\n".$errorPadding, $message);
+ $message = str_replace("\n", "\n" . $errorPadding, $message);
if ($showSources === true) {
- $message = "\033[1m".$message."\033[0m".' ('.$error['source'].')';
+ $message = "\033[1m" . $message . "\033[0m" . ' (' . $error['source'] . ')';
}
$errorMsg = wordwrap(
$message,
$maxErrorSpace,
- PHP_EOL.$errorPadding
+ PHP_EOL . $errorPadding
);
- echo $errorMsg.PHP_EOL;
+ echo $errorMsg . PHP_EOL;
}//end foreach
}//end foreach
- echo str_repeat('-', $width).PHP_EOL;
- echo rtrim($snippet).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
+ echo rtrim($snippet) . PHP_EOL;
}//end foreach
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
if ($report['fixable'] > 0) {
- echo "\033[1m".'PHPCBF CAN FIX THE '.$report['fixable'].' MARKED SNIFF VIOLATIONS AUTOMATICALLY'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo "\033[1m" . 'PHPCBF CAN FIX THE ' . $report['fixable'] . ' MARKED SNIFF VIOLATIONS AUTOMATICALLY' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
}
return true;
diff --git a/src/Reports/Csv.php b/src/Reports/Csv.php
index 156847c840..71b7a30b57 100644
--- a/src/Reports/Csv.php
+++ b/src/Reports/Csv.php
@@ -46,7 +46,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$source = $error['source'];
$severity = $error['severity'];
$fixable = (int) $error['fixable'];
- echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity,$fixable".PHP_EOL;
+ echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity,$fixable" . PHP_EOL;
}
}
}
@@ -83,7 +83,7 @@ public function generate(
bool $interactive = false,
bool $toScreen = true
) {
- echo 'File,Line,Column,Type,Message,Source,Severity,Fixable'.PHP_EOL;
+ echo 'File,Line,Column,Type,Message,Source,Severity,Fixable' . PHP_EOL;
echo $cachedData;
}//end generate()
diff --git a/src/Reports/Diff.php b/src/Reports/Diff.php
index 41f9f6ef70..3f354ec9be 100644
--- a/src/Reports/Diff.php
+++ b/src/Reports/Diff.php
@@ -44,15 +44,15 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
if (empty($tokens) === true) {
if (PHP_CODESNIFFER_VERBOSITY === 1) {
$startTime = microtime(true);
- StatusWriter::write('DIFF report is parsing '.basename($report['filename']).' ', 0, 0);
+ StatusWriter::write('DIFF report is parsing ' . basename($report['filename']) . ' ', 0, 0);
} else if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('DIFF report is forcing parse of '.$report['filename']);
+ StatusWriter::write('DIFF report is forcing parse of ' . $report['filename']);
}
$phpcsFile->parse();
if (PHP_CODESNIFFER_VERBOSITY === 1) {
- StatusWriter::write('DONE in '.Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)));
+ StatusWriter::write('DONE in ' . Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)));
}
$phpcsFile->fixer->startFile($phpcsFile);
@@ -78,7 +78,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
return false;
}
- echo $diff.PHP_EOL;
+ echo $diff . PHP_EOL;
return true;
}//end generateFileReport()
diff --git a/src/Reports/Emacs.php b/src/Reports/Emacs.php
index ed7d2861e4..11a722a93b 100644
--- a/src/Reports/Emacs.php
+++ b/src/Reports/Emacs.php
@@ -42,11 +42,11 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
foreach ($colErrors as $error) {
$message = $error['message'];
if ($showSources === true) {
- $message .= ' ('.$error['source'].')';
+ $message .= ' (' . $error['source'] . ')';
}
$type = strtolower($error['type']);
- echo $report['filename'].':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL;
+ echo $report['filename'] . ':' . $line . ':' . $column . ': ' . $type . ' - ' . $message . PHP_EOL;
}
}
}
diff --git a/src/Reports/Full.php b/src/Reports/Full.php
index b76ee05951..897a6fd8eb 100644
--- a/src/Reports/Full.php
+++ b/src/Reports/Full.php
@@ -95,35 +95,35 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$width = 70;
}
- echo PHP_EOL."\033[1mFILE: ";
+ echo PHP_EOL . "\033[1mFILE: ";
if ($fileLength <= ($width - 6)) {
echo $file;
} else {
- echo '...'.substr($file, ($fileLength - ($width - 6)));
+ echo '...' . substr($file, ($fileLength - ($width - 6)));
}
- echo "\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
- echo "\033[1m".'FOUND '.$report['errors'].' ERROR';
+ echo "\033[1m" . 'FOUND ' . $report['errors'] . ' ERROR';
if ($report['errors'] !== 1) {
echo 'S';
}
if ($report['warnings'] > 0) {
- echo ' AND '.$report['warnings'].' WARNING';
+ echo ' AND ' . $report['warnings'] . ' WARNING';
if ($report['warnings'] !== 1) {
echo 'S';
}
}
- echo ' AFFECTING '.count($report['messages']).' LINE';
+ echo ' AFFECTING ' . count($report['messages']) . ' LINE';
if (count($report['messages']) !== 1) {
echo 'S';
}
- echo "\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
// The maximum amount of space an error message can use.
$maxErrorSpace = ($width - $paddingLength - 1);
@@ -135,7 +135,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$afterMsg = "\033[0m";
}
- $beforeAfterLength = strlen($beforeMsg.$afterMsg);
+ $beforeAfterLength = strlen($beforeMsg . $afterMsg);
foreach ($report['messages'] as $line => $lineErrors) {
foreach ($lineErrors as $colErrors) {
@@ -147,19 +147,19 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
// Add the padding _after_ the wordwrap as the message itself may contain line breaks
// and those lines will also need to receive padding.
- $errorMsg = str_replace("\n", $afterMsg.PHP_EOL.$paddingLine2.$beforeMsg, $errorMsg);
- $errorMsg = $beforeMsg.$errorMsg.$afterMsg;
+ $errorMsg = str_replace("\n", $afterMsg . PHP_EOL . $paddingLine2 . $beforeMsg, $errorMsg);
+ $errorMsg = $beforeMsg . $errorMsg . $afterMsg;
if ($showSources === true) {
$lastMsg = $errorMsg;
- $startPosLastLine = strrpos($errorMsg, PHP_EOL.$paddingLine2.$beforeMsg);
+ $startPosLastLine = strrpos($errorMsg, PHP_EOL . $paddingLine2 . $beforeMsg);
if ($startPosLastLine !== false) {
// Message is multiline. Grab the text of last line of the message, including the color codes.
- $lastMsg = substr($errorMsg, ($startPosLastLine + strlen(PHP_EOL.$paddingLine2)));
+ $lastMsg = substr($errorMsg, ($startPosLastLine + strlen(PHP_EOL . $paddingLine2)));
}
// When show sources is used, the message itself will be bolded, so we need to correct the length.
- $sourceSuffix = '('.$error['source'].')';
+ $sourceSuffix = '(' . $error['source'] . ')';
$lastMsgPlusSourceLength = strlen($lastMsg);
// Add space + source suffix length.
@@ -168,16 +168,16 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$lastMsgPlusSourceLength -= $beforeAfterLength;
if ($lastMsgPlusSourceLength > $maxErrorSpace) {
- $errorMsg .= PHP_EOL.$paddingLine2.$sourceSuffix;
+ $errorMsg .= PHP_EOL . $paddingLine2 . $sourceSuffix;
} else {
- $errorMsg .= ' '.$sourceSuffix;
+ $errorMsg .= ' ' . $sourceSuffix;
}
}//end if
// The padding that goes on the front of the line.
$padding = ($maxLineNumLength - strlen($line));
- echo ' '.str_repeat(' ', $padding).$line.' | ';
+ echo ' ' . str_repeat(' ', $padding) . $line . ' | ';
if ($error['type'] === 'ERROR') {
echo "\033[31mERROR\033[0m";
if ($report['warnings'] > 0) {
@@ -199,15 +199,15 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
echo '] ';
}
- echo $errorMsg.PHP_EOL;
+ echo $errorMsg . PHP_EOL;
}//end foreach
}//end foreach
}//end foreach
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
if ($report['fixable'] > 0) {
- echo "\033[1m".'PHPCBF CAN FIX THE '.$report['fixable'].' MARKED SNIFF VIOLATIONS AUTOMATICALLY'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo "\033[1m" . 'PHPCBF CAN FIX THE ' . $report['fixable'] . ' MARKED SNIFF VIOLATIONS AUTOMATICALLY' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
}
echo PHP_EOL;
diff --git a/src/Reports/Gitblame.php b/src/Reports/Gitblame.php
index 6c126d9642..87c0dee254 100644
--- a/src/Reports/Gitblame.php
+++ b/src/Reports/Gitblame.php
@@ -71,10 +71,10 @@ protected function getBlameContent(string $filename)
$cwd = getcwd();
chdir(dirname($filename));
- $command = 'git blame --date=short "'.basename($filename).'" 2>&1';
+ $command = 'git blame --date=short "' . basename($filename) . '" 2>&1';
$handle = popen($command, 'r');
if ($handle === false) {
- $error = 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Could not execute "' . $command . '"' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
diff --git a/src/Reports/Hgblame.php b/src/Reports/Hgblame.php
index e402559919..1ac1fc36a3 100644
--- a/src/Reports/Hgblame.php
+++ b/src/Reports/Hgblame.php
@@ -77,7 +77,7 @@ protected function getBlameContent(string $filename)
while (empty($fileParts) === false) {
array_pop($fileParts);
$location = implode(DIRECTORY_SEPARATOR, $fileParts);
- if (is_dir($location.DIRECTORY_SEPARATOR.'.hg') === true) {
+ if (is_dir($location . DIRECTORY_SEPARATOR . '.hg') === true) {
$found = true;
break;
}
@@ -86,14 +86,14 @@ protected function getBlameContent(string $filename)
if ($found === true) {
chdir($location);
} else {
- $error = 'ERROR: Could not locate .hg directory '.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Could not locate .hg directory ' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
- $command = 'hg blame -u -d -v "'.$filename.'" 2>&1';
+ $command = 'hg blame -u -d -v "' . $filename . '" 2>&1';
$handle = popen($command, 'r');
if ($handle === false) {
- $error = 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Could not execute "' . $command . '"' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
diff --git a/src/Reports/Info.php b/src/Reports/Info.php
index 434bc2d933..5f29b739d0 100644
--- a/src/Reports/Info.php
+++ b/src/Reports/Info.php
@@ -35,7 +35,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$metrics = $phpcsFile->getMetrics();
foreach ($metrics as $metric => $data) {
foreach ($data['values'] as $value => $count) {
- echo "$metric>>$value>>$count".PHP_EOL;
+ echo "$metric>>$value>>$count" . PHP_EOL;
}
}
@@ -97,15 +97,15 @@ public function generate(
ksort($metrics);
- echo PHP_EOL."\033[1m".'PHP CODE SNIFFER INFORMATION REPORT'."\033[0m".PHP_EOL;
- echo str_repeat('-', 70).PHP_EOL;
+ echo PHP_EOL . "\033[1m" . 'PHP CODE SNIFFER INFORMATION REPORT' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', 70) . PHP_EOL;
foreach ($metrics as $metric => $values) {
if (count($values) === 1) {
$count = reset($values);
$value = key($values);
- echo "$metric: \033[4m$value\033[0m [$count/$count, 100%]".PHP_EOL;
+ echo "$metric: \033[4m$value\033[0m [$count/$count, 100%]" . PHP_EOL;
} else {
$totalCount = 0;
$valueWidth = 0;
@@ -123,7 +123,7 @@ public function generate(
// Account for 'total' line.
$valueWidth = max(5, $valueWidth);
- echo "$metric:".PHP_EOL;
+ echo "$metric:" . PHP_EOL;
ksort($values, SORT_NATURAL);
arsort($values);
@@ -141,7 +141,7 @@ public function generate(
}
printf(
- "\t%-{$valueWidth}s => %{$countWidth}s (%{$percentPrefixWidth}s%{$percentWidth}.2f%%)".PHP_EOL,
+ "\t%-{$valueWidth}s => %{$countWidth}s (%{$percentPrefixWidth}s%{$percentWidth}.2f%%)" . PHP_EOL,
$value,
number_format($count),
$percentPrefix,
@@ -149,9 +149,9 @@ public function generate(
);
}
- echo "\t".str_repeat('-', ($valueWidth + $countWidth + 15)).PHP_EOL;
+ echo "\t" . str_repeat('-', ($valueWidth + $countWidth + 15)) . PHP_EOL;
printf(
- "\t%-{$valueWidth}s => %{$countWidth}s (100.00%%)".PHP_EOL,
+ "\t%-{$valueWidth}s => %{$countWidth}s (100.00%%)" . PHP_EOL,
'total',
number_format($totalCount)
);
@@ -160,7 +160,7 @@ public function generate(
echo PHP_EOL;
}//end foreach
- echo str_repeat('-', 70).PHP_EOL;
+ echo str_repeat('-', 70) . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Json.php b/src/Reports/Json.php
index fa43510cb6..4d48f457ff 100644
--- a/src/Reports/Json.php
+++ b/src/Reports/Json.php
@@ -36,8 +36,8 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$filename = str_replace('\\', '\\\\', $report['filename']);
$filename = str_replace('"', '\"', $filename);
$filename = str_replace('/', '\/', $filename);
- echo '"'.$filename.'":{';
- echo '"errors":'.$report['errors'].',"warnings":'.$report['warnings'].',"messages":[';
+ echo '"' . $filename . '":{';
+ echo '"errors":' . $report['errors'] . ',"warnings":' . $report['warnings'] . ',"messages":[';
$messages = '';
foreach ($report['messages'] as $line => $lineErrors) {
@@ -57,7 +57,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
$messagesObject->column = $column;
$messagesObject->fixable = $fixable;
- $messages .= json_encode($messagesObject).',';
+ $messages .= json_encode($messagesObject) . ',';
}
}
}//end foreach
@@ -97,9 +97,9 @@ public function generate(
bool $interactive = false,
bool $toScreen = true
) {
- echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{';
+ echo '{"totals":{"errors":' . $totalErrors . ',"warnings":' . $totalWarnings . ',"fixable":' . $totalFixable . '},"files":{';
echo rtrim($cachedData, ',');
- echo '}}'.PHP_EOL;
+ echo '}}' . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Junit.php b/src/Reports/Junit.php
index a9a55cac90..0f40e28e4c 100644
--- a/src/Reports/Junit.php
+++ b/src/Reports/Junit.php
@@ -59,7 +59,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
foreach ($lineErrors as $column => $colErrors) {
foreach ($colErrors as $error) {
$out->startElement('testcase');
- $out->writeAttribute('name', $error['source'].' at '.$report['filename']." ($line:$column)");
+ $out->writeAttribute('name', $error['source'] . ' at ' . $report['filename'] . " ($line:$column)");
$error['type'] = strtolower($error['type']);
if ($phpcsFile->config->encoding !== 'utf-8') {
@@ -122,10 +122,10 @@ public function generate(
}
$failures = ($totalErrors + $totalWarnings);
- echo ''.PHP_EOL;
- echo ''.PHP_EOL;
+ echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
echo $cachedData;
- echo ''.PHP_EOL;
+ echo '' . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Notifysend.php b/src/Reports/Notifysend.php
index 8610407e8f..5025a296c4 100644
--- a/src/Reports/Notifysend.php
+++ b/src/Reports/Notifysend.php
@@ -75,7 +75,7 @@ public function __construct()
$this->version = str_replace(
'notify-send ',
'',
- exec($this->path.' --version')
+ exec($this->path . ' --version')
);
}//end __construct()
@@ -98,7 +98,7 @@ public function __construct()
*/
public function generateFileReport(array $report, File $phpcsFile, bool $showSources = false, int $width = 80)
{
- echo $report['filename'].PHP_EOL;
+ echo $report['filename'] . PHP_EOL;
// We want this file counted in the total number
// of checked files even if it has no errors.
@@ -168,17 +168,17 @@ protected function generateMessage(array $checkedFiles, int $totalErrors, int $t
$msg = '';
if ($totalFiles > 1) {
- $msg .= 'Checked '.$totalFiles.' files'.PHP_EOL;
+ $msg .= 'Checked ' . $totalFiles . ' files' . PHP_EOL;
} else {
- $msg .= $checkedFiles[0].PHP_EOL;
+ $msg .= $checkedFiles[0] . PHP_EOL;
}
if ($totalWarnings > 0) {
- $msg .= $totalWarnings.' warnings'.PHP_EOL;
+ $msg .= $totalWarnings . ' warnings' . PHP_EOL;
}
if ($totalErrors > 0) {
- $msg .= $totalErrors.' errors'.PHP_EOL;
+ $msg .= $totalErrors . ' errors' . PHP_EOL;
}
return $msg;
@@ -214,7 +214,7 @@ protected function notifyErrors(string $msg)
$cmd = $this->getBasicCommand();
$cmd .= ' -i error';
$cmd .= ' "PHP CodeSniffer: Error"';
- $cmd .= ' '.escapeshellarg(trim($msg));
+ $cmd .= ' ' . escapeshellarg(trim($msg));
exec($cmd);
}//end notifyErrors()
@@ -230,7 +230,7 @@ protected function getBasicCommand()
$cmd = $this->path;
$cmd .= ' --category dev.validate';
$cmd .= ' -h int:transient:1';
- $cmd .= ' -t '.(int) $this->timeout;
+ $cmd .= ' -t ' . (int) $this->timeout;
if (version_compare($this->version, '0.7.3', '>=') === true) {
$cmd .= ' -a phpcs';
}
diff --git a/src/Reports/Performance.php b/src/Reports/Performance.php
index aa30ba80fe..2c24d2db5f 100644
--- a/src/Reports/Performance.php
+++ b/src/Reports/Performance.php
@@ -36,7 +36,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
{
$times = $phpcsFile->getListenerTimes();
foreach ($times as $sniff => $time) {
- echo "$sniff>>$time".PHP_EOL;
+ echo "$sniff>>$time" . PHP_EOL;
}
return true;
@@ -112,10 +112,10 @@ public function generate(
arsort($totalTimes);
- echo PHP_EOL."\033[1m".'PHP CODE SNIFFER SNIFF PERFORMANCE REPORT'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
- echo "\033[1m".'SNIFF'.str_repeat(' ', ($width - 31)).'TIME TAKEN (SECS) (%)'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . "\033[1m" . 'PHP CODE SNIFFER SNIFF PERFORMANCE REPORT' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
+ echo "\033[1m" . 'SNIFF' . str_repeat(' ', ($width - 31)) . 'TIME TAKEN (SECS) (%)' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
// Mark sniffs which take more than twice as long as the average processing time per sniff
// in orange and when they take more than three times as long as the average,
@@ -124,10 +124,10 @@ public function generate(
$doubleAvgSniffTime = (2 * $avgSniffTime);
$tripleAvgSniffTime = (3 * $avgSniffTime);
- $format = "%- {$maxNameWidth}.{$maxNameWidth}s % 12.6f (% 5.1f %%)".PHP_EOL;
- $formatBold = "\033[1m%- {$maxNameWidth}.{$maxNameWidth}s % 12.6f (% 5.1f %%)\033[0m".PHP_EOL;
- $formatWarning = "%- {$maxNameWidth}.{$maxNameWidth}s \033[33m% 12.6f (% 5.1f %%)\033[0m".PHP_EOL;
- $formatError = "%- {$maxNameWidth}.{$maxNameWidth}s \033[31m% 12.6f (% 5.1f %%)\033[0m".PHP_EOL;
+ $format = "%- {$maxNameWidth}.{$maxNameWidth}s % 12.6f (% 5.1f %%)" . PHP_EOL;
+ $formatBold = "\033[1m%- {$maxNameWidth}.{$maxNameWidth}s % 12.6f (% 5.1f %%)\033[0m" . PHP_EOL;
+ $formatWarning = "%- {$maxNameWidth}.{$maxNameWidth}s \033[33m% 12.6f (% 5.1f %%)\033[0m" . PHP_EOL;
+ $formatError = "%- {$maxNameWidth}.{$maxNameWidth}s \033[31m% 12.6f (% 5.1f %%)\033[0m" . PHP_EOL;
foreach ($totalTimes as $sniff => $time) {
$percent = round((($time / $totalSniffTime) * 100), 1);
@@ -141,19 +141,19 @@ public function generate(
}
}
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
printf($formatBold, 'TOTAL SNIFF PROCESSING TIME', $totalSniffTime, 100);
$runTime = (Timing::getDuration() / 1000);
$phpcsTime = ($runTime - $totalSniffTime);
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
printf($format, 'Time taken by sniffs', $totalSniffTime, round((($totalSniffTime / $runTime) * 100), 1));
printf($format, 'Time taken by PHPCS runner', $phpcsTime, round((($phpcsTime / $runTime) * 100), 1));
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
printf($formatBold, 'TOTAL RUN TIME', $runTime, 100);
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Source.php b/src/Reports/Source.php
index 8ad7ffcb8c..e9ccd18bfb 100644
--- a/src/Reports/Source.php
+++ b/src/Reports/Source.php
@@ -56,7 +56,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
}
foreach ($sources as $source => $data) {
- echo $source.'>>'.$data['fixable'].'>>'.$data['count'].PHP_EOL;
+ echo $source . '>>' . $data['fixable'] . '>>' . $data['count'] . PHP_EOL;
}
return true;
@@ -124,7 +124,7 @@ public function generate(
if (isset($parts[3]) === true) {
$name = $this->makeFriendlyName($parts[3]);
$name[0] = strtolower($name[0]);
- $sniff .= ' '.$name;
+ $sniff .= ' ' . $name;
unset($parts[3]);
}
@@ -160,23 +160,23 @@ public function generate(
array_multisort($counts, SORT_DESC, $sourceCodes, SORT_ASC, SORT_NATURAL, $sources);
- echo PHP_EOL."\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL."\033[1m";
+ echo PHP_EOL . "\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL . "\033[1m";
if ($showSources === true) {
if ($totalFixable > 0) {
- echo ' SOURCE'.str_repeat(' ', ($width - 15)).'COUNT'.PHP_EOL;
+ echo ' SOURCE' . str_repeat(' ', ($width - 15)) . 'COUNT' . PHP_EOL;
} else {
- echo 'SOURCE'.str_repeat(' ', ($width - 11)).'COUNT'.PHP_EOL;
+ echo 'SOURCE' . str_repeat(' ', ($width - 11)) . 'COUNT' . PHP_EOL;
}
} else {
if ($totalFixable > 0) {
- echo ' STANDARD CATEGORY SNIFF'.str_repeat(' ', ($width - 44)).'COUNT'.PHP_EOL;
+ echo ' STANDARD CATEGORY SNIFF' . str_repeat(' ', ($width - 44)) . 'COUNT' . PHP_EOL;
} else {
- echo 'STANDARD CATEGORY SNIFF'.str_repeat(' ', ($width - 40)).'COUNT'.PHP_EOL;
+ echo 'STANDARD CATEGORY SNIFF' . str_repeat(' ', ($width - 40)) . 'COUNT' . PHP_EOL;
}
}
- echo "\033[0m".str_repeat('-', $width).PHP_EOL;
+ echo "\033[0m" . str_repeat('-', $width) . PHP_EOL;
$fixableSources = 0;
@@ -221,14 +221,14 @@ public function generate(
$parts[0] = substr($parts[0], 0, ((strlen($parts[0]) - 8) * -1));
}
- echo $parts[0].str_repeat(' ', (10 - strlen($parts[0])));
+ echo $parts[0] . str_repeat(' ', (10 - strlen($parts[0])));
$category = $parts[1];
if (strlen($category) > 18) {
$category = substr($category, 0, ((strlen($category) - 18) * -1));
}
- echo $category.str_repeat(' ', (20 - strlen($category)));
+ echo $category . str_repeat(' ', (20 - strlen($category)));
$sniff = $parts[2];
if (strlen($sniff) > $maxSniffWidth) {
@@ -236,22 +236,22 @@ public function generate(
}
if ($totalFixable > 0) {
- echo $sniff.str_repeat(' ', ($width - 39 - strlen($sniff)));
+ echo $sniff . str_repeat(' ', ($width - 39 - strlen($sniff)));
} else {
- echo $sniff.str_repeat(' ', ($width - 35 - strlen($sniff)));
+ echo $sniff . str_repeat(' ', ($width - 35 - strlen($sniff)));
}
}//end if
- echo $sourceData['count'].PHP_EOL;
+ echo $sourceData['count'] . PHP_EOL;
}//end foreach
- echo str_repeat('-', $width).PHP_EOL;
- echo "\033[1m".'A TOTAL OF '.($totalErrors + $totalWarnings).' SNIFF VIOLATION';
+ echo str_repeat('-', $width) . PHP_EOL;
+ echo "\033[1m" . 'A TOTAL OF ' . ($totalErrors + $totalWarnings) . ' SNIFF VIOLATION';
if (($totalErrors + $totalWarnings) > 1) {
echo 'S';
}
- echo ' WERE FOUND IN '.count($sources).' SOURCE';
+ echo ' WERE FOUND IN ' . count($sources) . ' SOURCE';
if (count($sources) !== 1) {
echo 'S';
}
@@ -259,11 +259,11 @@ public function generate(
echo "\033[0m";
if ($totalFixable > 0) {
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
}
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php
index b5c8e18b33..45551a4b81 100644
--- a/src/Reports/Summary.php
+++ b/src/Reports/Summary.php
@@ -40,7 +40,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
return false;
}
- echo $report['filename'].'>>'.$report['errors'].'>>'.$report['warnings'].PHP_EOL;
+ echo $report['filename'] . '>>' . $report['errors'] . '>>' . $report['warnings'] . PHP_EOL;
return true;
}//end generateFileReport()
@@ -119,28 +119,28 @@ static function ($keyA, $keyB) {
$width = min($width, ($maxLength + 21));
$width = max($width, 70);
- echo PHP_EOL."\033[1m".'PHP CODE SNIFFER REPORT SUMMARY'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
- echo "\033[1m".'FILE'.str_repeat(' ', ($width - 20)).'ERRORS WARNINGS'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . "\033[1m" . 'PHP CODE SNIFFER REPORT SUMMARY' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
+ echo "\033[1m" . 'FILE' . str_repeat(' ', ($width - 20)) . 'ERRORS WARNINGS' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
foreach ($reportFiles as $file => $data) {
$padding = ($width - 18 - $data['strlen']);
if ($padding < 0) {
- $file = '...'.substr($file, (($padding * -1) + 3));
+ $file = '...' . substr($file, (($padding * -1) + 3));
$padding = 0;
}
- echo $file.str_repeat(' ', $padding).' ';
+ echo $file . str_repeat(' ', $padding) . ' ';
if ($data['errors'] !== 0) {
- echo "\033[31m".$data['errors']."\033[0m";
+ echo "\033[31m" . $data['errors'] . "\033[0m";
echo str_repeat(' ', (8 - strlen((string) $data['errors'])));
} else {
echo '0 ';
}
if ($data['warnings'] !== 0) {
- echo "\033[33m".$data['warnings']."\033[0m";
+ echo "\033[33m" . $data['warnings'] . "\033[0m";
} else {
echo '0';
}
@@ -148,18 +148,18 @@ static function ($keyA, $keyB) {
echo PHP_EOL;
}//end foreach
- echo str_repeat('-', $width).PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
echo "\033[1mA TOTAL OF $totalErrors ERROR";
if ($totalErrors !== 1) {
echo 'S';
}
- echo ' AND '.$totalWarnings.' WARNING';
+ echo ' AND ' . $totalWarnings . ' WARNING';
if ($totalWarnings !== 1) {
echo 'S';
}
- echo ' WERE FOUND IN '.$totalFiles.' FILE';
+ echo ' WERE FOUND IN ' . $totalFiles . ' FILE';
if ($totalFiles !== 1) {
echo 'S';
}
@@ -167,11 +167,11 @@ static function ($keyA, $keyB) {
echo "\033[0m";
if ($totalFixable > 0) {
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
echo "\033[1mPHPCBF CAN FIX $totalFixable OF THESE SNIFF VIOLATIONS AUTOMATICALLY\033[0m";
}
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Svnblame.php b/src/Reports/Svnblame.php
index 0fca60bc18..2478ac2bbd 100644
--- a/src/Reports/Svnblame.php
+++ b/src/Reports/Svnblame.php
@@ -54,10 +54,10 @@ protected function getAuthor(string $line)
*/
protected function getBlameContent(string $filename)
{
- $command = 'svn blame "'.$filename.'" 2>&1';
+ $command = 'svn blame "' . $filename . '" 2>&1';
$handle = popen($command, 'r');
if ($handle === false) {
- $error = 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: Could not execute "' . $command . '"' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
diff --git a/src/Reports/VersionControl.php b/src/Reports/VersionControl.php
index 9f50322782..ea72719fd8 100644
--- a/src/Reports/VersionControl.php
+++ b/src/Reports/VersionControl.php
@@ -111,18 +111,18 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou
}//end foreach
foreach ($authorCache as $author => $errors) {
- echo "AUTHOR>>$author>>$errors".PHP_EOL;
+ echo "AUTHOR>>$author>>$errors" . PHP_EOL;
}
foreach ($praiseCache as $author => $praise) {
- echo "PRAISE>>$author>>".$praise['good'].'>>'.$praise['bad'].PHP_EOL;
+ echo "PRAISE>>$author>>" . $praise['good'] . '>>' . $praise['bad'] . PHP_EOL;
}
foreach ($sourceCache as $author => $sources) {
foreach ($sources as $source => $sourceData) {
$count = $sourceData['count'];
$fixable = (int) $sourceData['fixable'];
- echo "SOURCE>>$author>>$source>>$count>>$fixable".PHP_EOL;
+ echo "SOURCE>>$author>>$source>>$count>>$fixable" . PHP_EOL;
}
}
@@ -234,14 +234,14 @@ public function generate(
$width = max($width, 70);
arsort($authorCache);
- echo PHP_EOL."\033[1m".'PHP CODE SNIFFER '.$this->reportName.' BLAME SUMMARY'."\033[0m".PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL."\033[1m";
+ echo PHP_EOL . "\033[1m" . 'PHP CODE SNIFFER ' . $this->reportName . ' BLAME SUMMARY' . "\033[0m" . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL . "\033[1m";
if ($showSources === true) {
- echo 'AUTHOR SOURCE'.str_repeat(' ', ($width - 43)).'(Author %) (Overall %) COUNT'.PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo 'AUTHOR SOURCE' . str_repeat(' ', ($width - 43)) . '(Author %) (Overall %) COUNT' . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
} else {
- echo 'AUTHOR'.str_repeat(' ', ($width - 34)).'(Author %) (Overall %) COUNT'.PHP_EOL;
- echo str_repeat('-', $width).PHP_EOL;
+ echo 'AUTHOR' . str_repeat(' ', ($width - 34)) . '(Author %) (Overall %) COUNT' . PHP_EOL;
+ echo str_repeat('-', $width) . PHP_EOL;
}
echo "\033[0m";
@@ -264,18 +264,18 @@ public function generate(
$percent = round(($praiseCache[$author]['bad'] / $total * 100), 2);
}
- $overallPercent = '('.round((($count / $errorsShown) * 100), 2).')';
- $authorPercent = '('.$percent.')';
- $line = str_repeat(' ', (6 - strlen($count))).$count;
- $line = str_repeat(' ', (12 - strlen($overallPercent))).$overallPercent.$line;
- $line = str_repeat(' ', (11 - strlen($authorPercent))).$authorPercent.$line;
- $line = $author.str_repeat(' ', ($width - strlen($author) - strlen($line))).$line;
+ $overallPercent = '(' . round((($count / $errorsShown) * 100), 2) . ')';
+ $authorPercent = '(' . $percent . ')';
+ $line = str_repeat(' ', (6 - strlen($count))) . $count;
+ $line = str_repeat(' ', (12 - strlen($overallPercent))) . $overallPercent . $line;
+ $line = str_repeat(' ', (11 - strlen($authorPercent))) . $authorPercent . $line;
+ $line = $author . str_repeat(' ', ($width - strlen($author) - strlen($line))) . $line;
if ($showSources === true) {
$line = "\033[1m$line\033[0m";
}
- echo $line.PHP_EOL;
+ echo $line . PHP_EOL;
if ($showSources === true && isset($sourceCache[$author]) === true) {
$errors = $sourceCache[$author];
@@ -294,7 +294,7 @@ public function generate(
$source = substr($source, 0, $maxSniffWidth);
}
- $line = str_repeat(' ', (5 - strlen($count))).$count;
+ $line = str_repeat(' ', (5 - strlen($count))) . $count;
echo ' ';
if ($totalFixable > 0) {
@@ -316,18 +316,18 @@ public function generate(
echo str_repeat(' ', ($width - 14 - strlen($source)));
}
- echo $line.PHP_EOL;
+ 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';
+ echo str_repeat('-', $width) . PHP_EOL;
+ echo "\033[1m" . 'A TOTAL OF ' . $errorsShown . ' SNIFF VIOLATION';
if ($errorsShown !== 1) {
echo 'S';
}
- echo ' WERE COMMITTED BY '.count($authorCache).' AUTHOR';
+ echo ' WERE COMMITTED BY ' . count($authorCache) . ' AUTHOR';
if (count($authorCache) !== 1) {
echo 'S';
}
@@ -336,15 +336,15 @@ public function generate(
if ($totalFixable > 0) {
if ($showSources === true) {
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
} else {
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL;
echo "\033[1mPHPCBF CAN FIX $totalFixable OF THESE SNIFF VIOLATIONS AUTOMATICALLY\033[0m";
}
}
- echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
+ echo PHP_EOL . str_repeat('-', $width) . PHP_EOL . PHP_EOL;
}//end generate()
diff --git a/src/Reports/Xml.php b/src/Reports/Xml.php
index 8acba0e5dd..e119a5f55f 100644
--- a/src/Reports/Xml.php
+++ b/src/Reports/Xml.php
@@ -117,10 +117,10 @@ public function generate(
bool $interactive = false,
bool $toScreen = true
) {
- echo ''.PHP_EOL;
- echo ''.PHP_EOL;
+ echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
echo $cachedData;
- echo ''.PHP_EOL;
+ echo '' . PHP_EOL;
}//end generate()
diff --git a/src/Ruleset.php b/src/Ruleset.php
index ece573b1b7..b6e9faa0df 100644
--- a/src/Ruleset.php
+++ b/src/Ruleset.php
@@ -189,9 +189,9 @@ public function __construct(Config $config)
if ($installed === null) {
$standard = Common::realpath($standard);
if (is_dir($standard) === true
- && is_file(Common::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml')) === true
+ && is_file(Common::realpath($standard . DIRECTORY_SEPARATOR . 'ruleset.xml')) === true
) {
- $standard = Common::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml');
+ $standard = Common::realpath($standard . DIRECTORY_SEPARATOR . 'ruleset.xml');
}
} else {
$standard = $installed;
@@ -241,14 +241,14 @@ public function __construct(Config $config)
$sniffRestrictions = [];
foreach ($restrictions as $sniffCode) {
$parts = explode('.', strtolower($sniffCode));
- $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff';
+ $sniffName = $parts[0] . '\sniffs\\' . $parts[1] . '\\' . $parts[2] . 'sniff';
$sniffRestrictions[$sniffName] = true;
}
$sniffExclusions = [];
foreach ($exclusions as $sniffCode) {
$parts = explode('.', strtolower($sniffCode));
- $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff';
+ $sniffName = $parts[0] . '\sniffs\\' . $parts[1] . '\\' . $parts[2] . 'sniff';
$sniffExclusions[$sniffName] = true;
}
@@ -285,7 +285,7 @@ public function explain()
// and echo out the collected info about the last standard.
$sniffs[] = '';
- $summaryLine = PHP_EOL."The $this->name standard contains 1 sniff".PHP_EOL;
+ $summaryLine = PHP_EOL . "The $this->name standard contains 1 sniff" . PHP_EOL;
if ($sniffCount !== 1) {
$summaryLine = str_replace('1 sniff', "$sniffCount sniffs", $summaryLine);
}
@@ -309,16 +309,16 @@ public function explain()
// Reached the first item in the next standard.
// Echo out the info collected from the previous standard.
if ($currentStandard !== $lastStandard) {
- $subTitle = $lastStandard.' ('.$lastCount.' sniff';
+ $subTitle = $lastStandard . ' (' . $lastCount . ' sniff';
if ($lastCount > 1) {
$subTitle .= 's';
}
$subTitle .= ')';
- echo PHP_EOL.$subTitle.PHP_EOL;
- echo str_repeat('-', strlen($subTitle)).PHP_EOL;
- echo ' '.implode(PHP_EOL.' ', $sniffsInStandard).PHP_EOL;
+ echo PHP_EOL . $subTitle . PHP_EOL;
+ echo str_repeat('-', strlen($subTitle)) . PHP_EOL;
+ echo ' ' . implode(PHP_EOL . ' ', $sniffsInStandard) . PHP_EOL;
$lastStandard = $currentStandard;
$lastCount = 0;
@@ -338,7 +338,7 @@ public function explain()
}//end foreach
if (count($this->deprecatedSniffs) > 0) {
- echo PHP_EOL.'* Sniffs marked with an asterisk are deprecated.'.PHP_EOL;
+ echo PHP_EOL . '* Sniffs marked with an asterisk are deprecated.' . PHP_EOL;
}
}//end explain()
@@ -435,10 +435,10 @@ public function showSniffDeprecations()
// Truncate the error code if there is not enough report width.
if (strlen($sniffCode) > $maxMessageWidth) {
- $sniffCode = substr($sniffCode, 0, ($maxMessageWidth - 3)).'...';
+ $sniffCode = substr($sniffCode, 0, ($maxMessageWidth - 3)) . '...';
}
- $message = '- '."\033[36m".$sniffCode."\033[0m".PHP_EOL;
+ $message = '- ' . "\033[36m" . $sniffCode . "\033[0m" . PHP_EOL;
$maxActualWidth = max($maxActualWidth, strlen($sniffCode));
// Normalize new line characters in custom message.
@@ -447,7 +447,7 @@ public function showSniffDeprecations()
$notice = trim(sprintf($messageTemplate, $deprecatedSince, $removedIn, $customMessage));
$maxActualWidth = max($maxActualWidth, min(strlen($notice), $maxMessageWidth));
$wrapped = wordwrap($notice, $maxMessageWidth, PHP_EOL);
- $message .= ' '.implode(PHP_EOL.' ', explode(PHP_EOL, $wrapped));
+ $message .= ' ' . implode(PHP_EOL . ' ', explode(PHP_EOL, $wrapped));
$messages[] = $message;
}//end foreach
@@ -466,7 +466,7 @@ public function showSniffDeprecations()
$summaryLine = wordwrap($summaryLine, $reportWidth, PHP_EOL);
if ($this->config->colors === true) {
- StatusWriter::write("\033[33m".$summaryLine."\033[0m");
+ StatusWriter::write("\033[33m" . $summaryLine . "\033[0m");
} else {
StatusWriter::write($summaryLine);
}
@@ -533,16 +533,16 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
{
$rulesetPath = Common::realpath($rulesetPath);
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('Processing ruleset '.Common::stripBasepath($rulesetPath, $this->config->basepath), $depth);
+ StatusWriter::write('Processing ruleset ' . Common::stripBasepath($rulesetPath, $this->config->basepath), $depth);
}
libxml_use_internal_errors(true);
$ruleset = simplexml_load_string(file_get_contents($rulesetPath));
if ($ruleset === false) {
- $errorMsg = "ERROR: Ruleset $rulesetPath is not valid".PHP_EOL;
+ $errorMsg = "ERROR: Ruleset $rulesetPath is not valid" . PHP_EOL;
$errors = libxml_get_errors();
foreach ($errors as $error) {
- $errorMsg .= '- On line '.$error->line.', column '.$error->column.': '.$error->message;
+ $errorMsg .= '- On line ' . $error->line . ', column ' . $error->column . ': ' . $error->message;
}
libxml_clear_errors();
@@ -559,10 +559,10 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
$rulesetDir = dirname($rulesetPath);
$this->rulesetDirs[] = $rulesetDir;
- $sniffDir = $rulesetDir.DIRECTORY_SEPARATOR.'Sniffs';
+ $sniffDir = $rulesetDir . DIRECTORY_SEPARATOR . 'Sniffs';
if (is_dir($sniffDir) === true) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('Adding sniff files from '.Common::stripBasepath($sniffDir, $this->config->basepath).' directory', ($depth + 1));
+ StatusWriter::write('Adding sniff files from ' . Common::stripBasepath($sniffDir, $this->config->basepath) . ' directory', ($depth + 1));
}
$ownSniffs = $this->expandSniffDirectory($sniffDir, $depth);
@@ -577,12 +577,12 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
$autoloadPath = (string) $autoload;
// Try relative autoload paths first.
- $relativePath = Common::realpath(dirname($rulesetPath).DIRECTORY_SEPARATOR.$autoloadPath);
+ $relativePath = Common::realpath(dirname($rulesetPath) . DIRECTORY_SEPARATOR . $autoloadPath);
if ($relativePath !== false && is_file($relativePath) === true) {
$autoloadPath = $relativePath;
} else if (is_file($autoloadPath) === false) {
- throw new RuntimeException('ERROR: The specified autoload file "'.$autoload.'" does not exist');
+ throw new RuntimeException('ERROR: The specified autoload file "' . $autoload . '" does not exist');
}
include_once $autoloadPath;
@@ -608,7 +608,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
) {
// Ignore this config. A higher level ruleset has already set a value for this directive.
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> ignoring config value '.$name.': '.(string) $config['value'].' => already changed by a higher level ruleset ', ($depth + 1));
+ StatusWriter::write('=> ignoring config value ' . $name . ': ' . (string) $config['value'] . ' => already changed by a higher level ruleset ', ($depth + 1));
}
continue;
@@ -618,7 +618,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
$applied = $this->config->setConfigData($name, (string) $config['value'], true);
if ($applied === true && PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> set config value '.$name.': '.(string) $config['value'], ($depth + 1));
+ StatusWriter::write('=> set config value ' . $name . ': ' . (string) $config['value'], ($depth + 1));
}
}//end foreach
@@ -645,12 +645,12 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
) {
// Ignore this CLI flag. A higher level ruleset has already set a value for this setting.
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = '=> ignoring command line arg --'.$name;
+ $statusMessage = '=> ignoring command line arg --' . $name;
if (isset($arg['value']) === true) {
- $statusMessage .= '='.(string) $arg['value'];
+ $statusMessage .= '=' . (string) $arg['value'];
}
- StatusWriter::write($statusMessage.' => already changed by a higher level ruleset ', ($depth + 1));
+ StatusWriter::write($statusMessage . ' => already changed by a higher level ruleset ', ($depth + 1));
}
continue;
@@ -659,9 +659,9 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
// Remember which settings we've seen.
$this->cliSettingsApplied[$cliSettingName] = $depth;
- $argString = '--'.$name;
+ $argString = '--' . $name;
if (isset($arg['value']) === true) {
- $argString .= '='.(string) $arg['value'];
+ $argString .= '=' . (string) $arg['value'];
}
} else {
// "Short" CLI flag. Arg is in the format `` and
@@ -679,7 +679,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
) {
// Ignore this CLI flag. A higher level ruleset has already set a value for this setting.
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> ignoring command line flag -'.$flag.' => already changed by a higher level ruleset ', ($depth + 1));
+ StatusWriter::write('=> ignoring command line flag -' . $flag . ' => already changed by a higher level ruleset ', ($depth + 1));
}
continue;
@@ -695,7 +695,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
continue;
}
- $argString = '-'.$cleanedValue;
+ $argString = '-' . $cleanedValue;
}//end if
$cliArgs[] = $argString;
@@ -713,7 +713,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
}
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('Processing rule "'.$rule['ref'].'"', ($depth + 1));
+ StatusWriter::write('Processing rule "' . $rule['ref'] . '"', ($depth + 1));
}
$expandedSniffs = $this->expandRulesetReference((string) $rule['ref'], $rulesetDir, $depth);
@@ -726,7 +726,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
&& $parts[1] !== ''
&& $parts[2] !== ''
) {
- $sniffCode = $parts[0].'.'.$parts[1].'.'.$parts[2];
+ $sniffCode = $parts[0] . '.' . $parts[1] . '.' . $parts[2];
if (isset($this->ruleset[$sniffCode]['severity']) === true
&& $this->ruleset[$sniffCode]['severity'] === 0
) {
@@ -746,7 +746,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
$this->ruleset[$sniffCode]['severity'] = 0;
$this->ruleset[(string) $rule['ref']]['severity'] = 5;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('Excluding sniff "'.$sniffCode.'" except for "'.$parts[3].'"', ($depth + 2));
+ StatusWriter::write('Excluding sniff "' . $sniffCode . '" except for "' . $parts[3] . '"', ($depth + 2));
}
}
}//end if
@@ -757,7 +757,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
if (isset($exclude['name']) === false) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('* ignoring empty exclude rule *', ($depth + 2));
- StatusWriter::write('=> '.$exclude->asXML(), ($depth + 3));
+ StatusWriter::write('=> ' . $exclude->asXML(), ($depth + 3));
}
continue;
@@ -768,7 +768,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
}
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('Excluding rule "'.$exclude['name'].'"', ($depth + 2));
+ StatusWriter::write('Excluding rule "' . $exclude['name'] . '"', ($depth + 2));
}
// Check if a single code is being excluded, which is a shortcut
@@ -858,7 +858,7 @@ public function processRuleset(string $rulesetPath, int $depth = 0)
$this->ignorePatterns[(string) $pattern] = (string) $pattern['type'];
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> added global '.(string) $pattern['type'].' ignore pattern: '.(string) $pattern, ($depth + 1));
+ StatusWriter::write('=> added global ' . (string) $pattern['type'] . ' ignore pattern: ' . (string) $pattern, ($depth + 1));
}
}
@@ -930,12 +930,12 @@ private function expandSniffDirectory(string $directory, int $depth = 0)
// standard. We use the offset with strpos() to allow hidden directories
// before, valid example:
// /home/foo/.composer/vendor/squiz/custom_tool/MyStandard/Sniffs/...
- if (strpos($path, DIRECTORY_SEPARATOR.'.', $dirLen) !== false) {
+ if (strpos($path, DIRECTORY_SEPARATOR . '.', $dirLen) !== false) {
continue;
}
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> '.Common::stripBasepath($path, $this->config->basepath), ($depth + 2));
+ StatusWriter::write('=> ' . Common::stripBasepath($path, $this->config->basepath), ($depth + 2));
}
$sniffs[] = $path;
@@ -962,7 +962,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
{
// Naming an (external) standard "Internal" is not supported.
if (strtolower($ref) === 'internal') {
- $message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
+ $message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".' . PHP_EOL;
$message .= 'Contact the maintainer of the standard to fix this.';
$this->msgCache->add($message, MessageCollector::ERROR);
@@ -984,11 +984,11 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
// to absolute paths. If this fails, let the reference run through
// the normal checks and have it fail as normal.
if (substr($ref, 0, 1) === '.') {
- $realpath = Common::realpath($rulesetDir.'/'.$ref);
+ $realpath = Common::realpath($rulesetDir . '/' . $ref);
if ($realpath !== false) {
$ref = $realpath;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> '.Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
+ StatusWriter::write('=> ' . Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
}
}
}
@@ -1000,7 +1000,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
if ($realpath !== false) {
$ref = $realpath;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> '.Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
+ StatusWriter::write('=> ' . Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
}
}
}
@@ -1016,8 +1016,8 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
$path = Standards::getInstalledStandardPath($ref);
if ($path !== null && Common::isPharFile($path) === true && strpos($path, 'ruleset.xml') === false) {
// If the ruleset exists inside the phar file, use it.
- if (file_exists($path.DIRECTORY_SEPARATOR.'ruleset.xml') === true) {
- $path .= DIRECTORY_SEPARATOR.'ruleset.xml';
+ if (file_exists($path . DIRECTORY_SEPARATOR . 'ruleset.xml') === true) {
+ $path .= DIRECTORY_SEPARATOR . 'ruleset.xml';
} else {
$path = null;
}
@@ -1026,7 +1026,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
if ($path !== null) {
$ref = $path;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> '.Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
+ StatusWriter::write('=> ' . Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
}
} else if (is_dir($ref) === false) {
// Work out the sniff path.
@@ -1042,10 +1042,10 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
$path = '';
} else if (count($parts) === 2) {
// A directory of sniffs?
- $path = DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR.$parts[1];
+ $path = DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR . $parts[1];
} else {
// A single sniff?
- $path = DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR.$parts[1].DIRECTORY_SEPARATOR.$parts[2].'Sniff.php';
+ $path = DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR . $parts[1] . DIRECTORY_SEPARATOR . $parts[2] . 'Sniff.php';
}
}
@@ -1057,9 +1057,9 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
) {
// Phar files can only return the directory,
// since ruleset can be omitted if building one standard.
- $newRef = Common::realpath($stdPath.$path);
+ $newRef = Common::realpath($stdPath . $path);
} else {
- $newRef = Common::realpath(dirname($stdPath).$path);
+ $newRef = Common::realpath(dirname($stdPath) . $path);
}
}
@@ -1074,7 +1074,7 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
continue;
}
- $newRef = Common::realpath($dir.$path);
+ $newRef = Common::realpath($dir . $path);
if ($newRef !== false) {
$ref = $newRef;
@@ -1085,19 +1085,19 @@ private function expandRulesetReference(string $ref, string $rulesetDir, int $de
}
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- StatusWriter::write('=> '.Common::stripBasepath($ref, $this->config->basepath), ($depth + 2));
+ 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) {
+ if (is_file($ref . DIRECTORY_SEPARATOR . 'ruleset.xml') === true) {
// We are referencing an external coding standard.
if (PHP_CODESNIFFER_VERBOSITY > 1) {
StatusWriter::write('* rule is referencing a standard using directory name; processing *', ($depth + 2));
}
- return $this->processRuleset($ref.DIRECTORY_SEPARATOR.'ruleset.xml', ($depth + 2));
+ return $this->processRuleset($ref . DIRECTORY_SEPARATOR . 'ruleset.xml', ($depth + 2));
} else {
// We are referencing a whole directory of sniffs.
if (PHP_CODESNIFFER_VERBOSITY > 1) {
@@ -1163,7 +1163,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
$sniffCategory = array_pop($parts);
array_pop($parts);
$sniffStandard = array_pop($parts);
- $todo[] = $sniffStandard.'.'.$sniffCategory.'.'.substr($sniffName, 0, -9);
+ $todo[] = $sniffStandard . '.' . $sniffCategory . '.' . substr($sniffName, 0, -9);
}
}
@@ -1178,7 +1178,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
$this->ruleset[$code]['severity'] = (int) $rule->severity;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = '=> severity set to '.(int) $rule->severity;
+ $statusMessage = '=> severity set to ' . (int) $rule->severity;
if ($code !== $ref) {
$statusMessage .= " for $code";
}
@@ -1202,7 +1202,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
} else {
$this->ruleset[$code]['type'] = $type;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = '=> message type set to '.(string) $rule->type;
+ $statusMessage = '=> message type set to ' . (string) $rule->type;
if ($code !== $ref) {
$statusMessage .= " for $code";
}
@@ -1222,7 +1222,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
$this->ruleset[$code]['message'] = (string) $rule->message;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = '=> message set to '.(string) $rule->message;
+ $statusMessage = '=> message set to ' . (string) $rule->message;
if ($code !== $ref) {
$statusMessage .= " for $code";
}
@@ -1258,10 +1258,10 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
&& (string) $prop['type'] === 'array'
) {
if (isset($prop['value']) === true) {
- $message = 'Passing an array of values to a property using a comma-separated string'.PHP_EOL;
- $message .= 'is no longer supported since PHP_CodeSniffer 4.0.0.'.PHP_EOL;
- $message .= "The unsupported syntax was used for property \"$name\"".PHP_EOL;
- $message .= "for sniff \"$code\".".PHP_EOL;
+ $message = 'Passing an array of values to a property using a comma-separated string' . PHP_EOL;
+ $message .= 'is no longer supported since PHP_CodeSniffer 4.0.0.' . PHP_EOL;
+ $message .= "The unsupported syntax was used for property \"$name\"" . PHP_EOL;
+ $message .= "for sniff \"$code\"." . PHP_EOL;
$message .= 'Pass array values via nodes instead.';
$this->msgCache->add($message, MessageCollector::ERROR);
@@ -1290,10 +1290,10 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
if (isset($element['key']) === true) {
$key = (string) $element['key'];
$values[$key] = $value;
- $printValue .= $key.'=>'.$value.',';
+ $printValue .= $key . '=>' . $value . ',';
} else {
$values[] = $value;
- $printValue .= $value.',';
+ $printValue .= $value . ',';
}
}
@@ -1319,7 +1319,7 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
'scope' => $propertyScope,
];
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = "=> property \"$name\" set to \"".(string) $prop['value'].'"';
+ $statusMessage = "=> property \"$name\" set to \"" . (string) $prop['value'] . '"';
if ($code !== $ref) {
$statusMessage .= " for $code";
}
@@ -1346,12 +1346,12 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
$this->ignorePatterns[$code][(string) $pattern] = (string) $pattern['type'];
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = '=> added rule-specific '.(string) $pattern['type'].' ignore pattern';
+ $statusMessage = '=> added rule-specific ' . (string) $pattern['type'] . ' ignore pattern';
if ($code !== $ref) {
$statusMessage .= " for $code";
}
- StatusWriter::write($statusMessage.': '.(string) $pattern, ($depth + 2));
+ StatusWriter::write($statusMessage . ': ' . (string) $pattern, ($depth + 2));
}
}//end foreach
@@ -1371,12 +1371,12 @@ private function processRule(SimpleXMLElement $rule, array $newSniffs, int $dept
$this->includePatterns[$code][(string) $pattern] = (string) $pattern['type'];
if (PHP_CODESNIFFER_VERBOSITY > 1) {
- $statusMessage = '=> added rule-specific '.(string) $pattern['type'].' include pattern';
+ $statusMessage = '=> added rule-specific ' . (string) $pattern['type'] . ' include pattern';
if ($code !== $ref) {
$statusMessage .= " for $code";
}
- StatusWriter::write($statusMessage.': '.(string) $pattern, ($depth + 2));
+ StatusWriter::write($statusMessage . ': ' . (string) $pattern, ($depth + 2));
}
}//end foreach
}//end foreach
@@ -1437,7 +1437,7 @@ public function registerSniffs(array $files, array $restrictions, array $exclusi
foreach ($files as $file) {
// Work out where the position of /StandardName/Sniffs/... is
// so we can determine what the class will be called.
- $sniffPos = strrpos($file, DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR);
+ $sniffPos = strrpos($file, DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR);
if ($sniffPos === false) {
continue;
}
@@ -1473,8 +1473,8 @@ public function registerSniffs(array $files, array $restrictions, array $exclusi
}
if ($reflection->implementsInterface(Sniff::class) === false) {
- $message = 'All sniffs must implement the PHP_CodeSniffer\\Sniffs\\Sniff interface.'.PHP_EOL;
- $message .= "Interface not implemented for sniff $className.".PHP_EOL;
+ $message = 'All sniffs must implement the PHP_CodeSniffer\\Sniffs\\Sniff interface.' . PHP_EOL;
+ $message .= "Interface not implemented for sniff $className." . PHP_EOL;
$message .= 'Contact the sniff author to fix the sniff.';
$this->msgCache->add($message, MessageCollector::ERROR);
continue;
@@ -1493,7 +1493,7 @@ public function registerSniffs(array $files, array $restrictions, array $exclusi
continue;
}
- $message = 'Support for scanning files other than PHP, like CSS/JS files, has been removed in PHP_CodeSniffer 4.0.'.PHP_EOL;
+ $message = 'Support for scanning files other than PHP, like CSS/JS files, has been removed in PHP_CodeSniffer 4.0.' . PHP_EOL;
$message .= 'The %s sniff is listening for %s.';
$message = sprintf($message, Common::getSniffCode($className), implode(', ', $value));
$this->msgCache->add($message, MessageCollector::ERROR);
@@ -1528,7 +1528,7 @@ public function populateTokenListeners()
try {
$sniffCode = Common::getSniffCode($sniffClass);
} catch (InvalidArgumentException $e) {
- $message = "The sniff $sniffClass does not comply with the PHP_CodeSniffer naming conventions.".PHP_EOL;
+ $message = "The sniff $sniffClass does not comply with the PHP_CodeSniffer naming conventions." . PHP_EOL;
$message .= 'Contact the sniff author to fix the sniff.';
$this->msgCache->add($message, MessageCollector::ERROR);
@@ -1641,7 +1641,7 @@ public function setSniffProperty(string $sniffClass, string $name, array $settin
if ($isSettable === false) {
if ($settings['scope'] === 'sniff') {
$notice = "Property \"$propertyName\" does not exist on sniff ";
- $notice .= array_search($sniffClass, $this->sniffCodes, true).'.';
+ $notice .= array_search($sniffClass, $this->sniffCodes, true) . '.';
$this->msgCache->add($notice, MessageCollector::ERROR);
}
diff --git a/src/Runner.php b/src/Runner.php
index 740dfaa9b3..016674305a 100644
--- a/src/Runner.php
+++ b/src/Runner.php
@@ -95,7 +95,7 @@ public function runPHPCS()
foreach ($standards as $standard) {
$this->config->standards = [$standard];
$ruleset = new Ruleset($this->config);
- $class = 'PHP_CodeSniffer\Generators\\'.$this->config->generator;
+ $class = 'PHP_CodeSniffer\Generators\\' . $this->config->generator;
$generator = new $class($ruleset);
$generator->generate();
}
@@ -251,8 +251,8 @@ public function init()
if (Standards::isInstalledStandard($standard) === false) {
// They didn't select a valid coding standard, so help them
// out by letting them know which standards are installed.
- $error = 'ERROR: the "'.$standard.'" coding standard is not installed.'.PHP_EOL.PHP_EOL;
- $error .= Standards::prepareInstalledStandardsForDisplay().PHP_EOL;
+ $error = 'ERROR: the "' . $standard . '" coding standard is not installed.' . PHP_EOL . PHP_EOL;
+ $error .= Standards::prepareInstalledStandardsForDisplay() . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
}
@@ -282,7 +282,7 @@ public function init()
$this->ruleset->showSniffDeprecations();
}
} catch (RuntimeException $e) {
- $error = rtrim($e->getMessage(), "\r\n").PHP_EOL.PHP_EOL;
+ $error = rtrim($e->getMessage(), "\r\n") . PHP_EOL . PHP_EOL;
$error .= $this->config->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -322,7 +322,7 @@ private function run()
$todo->addFile($dummy->path, $dummy);
} else {
if (empty($this->config->files) === true) {
- $error = 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: You must supply at least one file or directory to process.' . PHP_EOL . PHP_EOL;
$error .= $this->config->printShortUsage(true);
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -354,8 +354,8 @@ private function run()
$numFiles = count($todo);
if ($numFiles === 0) {
- $error = 'ERROR: No files were checked.'.PHP_EOL;
- $error .= 'All specified files were excluded or did not match filtering rules.'.PHP_EOL.PHP_EOL;
+ $error = 'ERROR: No files were checked.' . PHP_EOL;
+ $error .= 'All specified files were excluded or did not match filtering rules.' . PHP_EOL . PHP_EOL;
throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
}
@@ -383,7 +383,7 @@ private function run()
$currDir = dirname($path);
if ($lastDir !== $currDir) {
if (PHP_CODESNIFFER_VERBOSITY > 0) {
- StatusWriter::write('Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath));
+ StatusWriter::write('Changing into directory ' . Common::stripBasepath($currDir, $this->config->basepath));
}
$lastDir = $currDir;
@@ -391,7 +391,7 @@ private function run()
$this->processFile($file);
} else if (PHP_CODESNIFFER_VERBOSITY > 0) {
- StatusWriter::write('Skipping '.basename($file->path));
+ StatusWriter::write('Skipping ' . basename($file->path));
}
$numProcessed++;
@@ -451,7 +451,7 @@ private function run()
$currDir = dirname($path);
if ($lastDir !== $currDir) {
if (PHP_CODESNIFFER_VERBOSITY > 0) {
- StatusWriter::write('Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath));
+ StatusWriter::write('Changing into directory ' . Common::stripBasepath($currDir, $this->config->basepath));
}
$lastDir = $currDir;
@@ -478,7 +478,7 @@ private function run()
'totalFixedWarnings' => $this->reporter->totalFixedWarnings,
];
- $output = '<'.'?php'."\n".' $childOutput = ';
+ $output = '<' . '?php' . "\n" . ' $childOutput = ';
$output .= var_export($childOutput, true);
$output .= ";\n\$debugOutput = ";
$output .= var_export($debugOutput, true);
@@ -493,7 +493,7 @@ private function run()
$output .= var_export($childCache, true);
}
- $output .= ";\n?".'>';
+ $output .= ";\n?" . '>';
file_put_contents($childOutFilename, $output);
exit();
}//end if
@@ -565,14 +565,14 @@ public function processFile(File $file)
$newlines = 1;
}
- StatusWriter::write('Processing '.basename($file->path).' ', 0, $newlines);
+ StatusWriter::write('Processing ' . basename($file->path) . ' ', 0, $newlines);
}
try {
$file->process();
if (PHP_CODESNIFFER_VERBOSITY > 0) {
- StatusWriter::write('DONE in '.Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)), 0, 0);
+ StatusWriter::write('DONE in ' . Timing::getHumanReadableDuration(Timing::getDurationSince($startTime)), 0, 0);
if (PHP_CODESNIFFER_CBF === true) {
$errors = $file->getFixableErrorCount();
@@ -585,7 +585,7 @@ public function processFile(File $file)
}
}
} catch (Exception $e) {
- $error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage();
+ $error = 'An error occurred during processing; checking has been aborted. The error message was: ' . $e->getMessage();
// Determine which sniff caused the error.
$sniffStack = null;
@@ -612,7 +612,7 @@ public function processFile(File $file)
if (empty($nextStack) === false
&& isset($nextStack['class']) === true
) {
- $sniffCode = 'the '.Common::getSniffCode($nextStack['class']).' sniff';
+ $sniffCode = 'the ' . Common::getSniffCode($nextStack['class']) . ' sniff';
}
} catch (InvalidArgumentException $e) {
// Sniff code could not be determined. This may be an abstract sniff class.
@@ -622,7 +622,7 @@ public function processFile(File $file)
$sniffCode = substr(strrchr(str_replace('\\', '/', $sniffStack['file']), '/'), 1);
}
- $error .= sprintf(PHP_EOL.'The error originated in %s on line %s.', $sniffCode, $sniffStack['line']);
+ $error .= sprintf(PHP_EOL . 'The error originated in %s on line %s.', $sniffCode, $sniffStack['line']);
}
$file->addErrorOnLine($error, 1, 'Internal.Exception');
@@ -846,7 +846,7 @@ public function printProgress(File $file, int $numFiles, int $numProcessed)
}//end if
}//end if
- StatusWriter::write($colorOpen.$progressDot.$colorClose, 0, 0);
+ StatusWriter::write($colorOpen . $progressDot . $colorClose, 0, 0);
$numPerLine = 60;
if ($numProcessed !== $numFiles && ($numProcessed % $numPerLine) !== 0) {
@@ -862,7 +862,7 @@ public function printProgress(File $file, int $numFiles, int $numProcessed)
$padding += ($numPerLine - ($numFiles - (floor($numFiles / $numPerLine) * $numPerLine)));
}
- StatusWriter::write(str_repeat(' ', $padding)." $numProcessed / $numFiles ($percent%)");
+ StatusWriter::write(str_repeat(' ', $padding) . " $numProcessed / $numFiles ($percent%)");
}//end printProgress()
@@ -877,9 +877,9 @@ public function printProgress(File $file, int $numFiles, int $numProcessed)
private function registerOutOfMemoryShutdownMessage(string $command)
{
// Allocate all needed memory beforehand as much as possible.
- $errorMsg = PHP_EOL.'The PHP_CodeSniffer "%1$s" command ran out of memory.'.PHP_EOL;
- $errorMsg .= 'Either raise the "memory_limit" of PHP in the php.ini file or raise the memory limit at runtime'.PHP_EOL;
- $errorMsg .= 'using `%1$s -d memory_limit=512M` (replace 512M with the desired memory limit).'.PHP_EOL;
+ $errorMsg = PHP_EOL . 'The PHP_CodeSniffer "%1$s" command ran out of memory.' . PHP_EOL;
+ $errorMsg .= 'Either raise the "memory_limit" of PHP in the php.ini file or raise the memory limit at runtime' . PHP_EOL;
+ $errorMsg .= 'using `%1$s -d memory_limit=512M` (replace 512M with the desired memory limit).' . PHP_EOL;
$errorMsg = sprintf($errorMsg, $command);
$memoryError = 'Allowed memory size of';
$errorArray = [
diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php
index 60d85a8f58..14ce4297ea 100644
--- a/src/Sniffs/AbstractPatternSniff.php
+++ b/src/Sniffs/AbstractPatternSniff.php
@@ -269,7 +269,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
if ($pattern[$i]['type'] === 'token') {
if ($pattern[$i]['token'] === T_WHITESPACE) {
if ($tokens[$stackPtr]['code'] === T_WHITESPACE) {
- $found = $tokens[$stackPtr]['content'].$found;
+ $found = $tokens[$stackPtr]['content'] . $found;
}
// Only check the size of the whitespace if this is not
@@ -304,7 +304,7 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
($stackPtr - $prev - 1)
);
- $found = $tokens[$prev]['content'].$tokenContent.$found;
+ $found = $tokens[$prev]['content'] . $tokenContent . $found;
if (isset($pattern[($i - 1)]) === true
&& $pattern[($i - 1)]['type'] === 'skip'
@@ -337,12 +337,12 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
}
if ($to === 'parenthesis_opener') {
- $found = '{'.$found;
+ $found = '{' . $found;
} else {
- $found = '('.$found;
+ $found = '(' . $found;
}
- $found = '...'.$found;
+ $found = '...' . $found;
// Skip to the opening token.
$stackPtr = ($tokens[$next][$to] - 1);
@@ -368,13 +368,13 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
($stackPtr - $startComment + 1)
);
- $found = $tokenContent.$found;
+ $found = $tokenContent . $found;
$stackPtr = ($startComment - 1);
}
if ($tokens[$stackPtr]['code'] === T_WHITESPACE) {
if ($tokens[$stackPtr]['content'] !== $phpcsFile->eolChar) {
- $found = $tokens[$stackPtr]['content'].$found;
+ $found = $tokens[$stackPtr]['content'] . $found;
// This may just be an indent that comes after a newline
// so check the token before to make sure. If it is a newline, we
@@ -388,10 +388,10 @@ protected function processPattern(array $patternInfo, File $phpcsFile, int $stac
$stackPtr--;
}
} else {
- $found = 'EOL'.$found;
+ $found = 'EOL' . $found;
}
} else {
- $found = $tokens[$stackPtr]['content'].$found;
+ $found = $tokens[$stackPtr]['content'] . $found;
$hasError = true;
}//end if
@@ -915,7 +915,7 @@ private function createTokenPattern(string $str)
// Don't add a space after the closing php tag as it will add a new
// whitespace token.
- $tokenizer = new PHP('', null);
+ $tokenizer = new PHP('', null);
StatusWriter::resume();
// Remove the addFixableError($error, $arrayEnd, 'CloseBraceNotNewLine');
if ($fix === true) {
- $padding = $phpcsFile->eolChar.str_repeat(' ', $startIndent);
+ $padding = $phpcsFile->eolChar . str_repeat(' ', $startIndent);
$phpcsFile->fixer->addContentBefore($arrayEnd, $padding);
}
diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php
index 1192056e96..11d7761744 100644
--- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php
+++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php
@@ -78,7 +78,7 @@ public function process(File $phpcsFile, int $stackPtr)
$name = $phpcsFile->getDeclarationName($stackPtr);
if (empty($name) === false) {
if ($namespace !== '') {
- $name = $namespace.'\\'.$name;
+ $name = $namespace . '\\' . $name;
}
$compareName = strtolower($name);
diff --git a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php
index 8d348dd269..bb5e879467 100644
--- a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php
+++ b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php
@@ -46,7 +46,7 @@ public function process(File $phpcsFile, int $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$scopeIdentifier = $phpcsFile->findNext(T_STRING, ($stackPtr + 1));
- $errorData = [strtolower($tokens[$stackPtr]['content']).' '.$tokens[$scopeIdentifier]['content']];
+ $errorData = [strtolower($tokens[$stackPtr]['content']) . ' ' . $tokens[$scopeIdentifier]['content']];
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
// Parse error or live coding.
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php
index 258acd3858..618939d7f5 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php
@@ -89,7 +89,7 @@ public function process(File $phpcsFile, int $stackPtr)
// Get token identifier.
$name = strtoupper($token['content']);
$error = 'Empty %s statement detected';
- $phpcsFile->addError($error, $stackPtr, 'Detected'.ucfirst(strtolower($name)), [$name]);
+ $phpcsFile->addError($error, $stackPtr, 'Detected' . ucfirst(strtolower($name)), [$name]);
}//end process()
diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
index 4fd2d11299..f60cb15c34 100644
--- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
+++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
@@ -202,7 +202,7 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) {
$nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
if ($tokens[$nextToken]['code'] === T_STRING) {
- $varContent = '$'.$tokens[$nextToken]['content'];
+ $varContent = '$' . $tokens[$nextToken]['content'];
if (isset($params[$varContent]) === true) {
unset($params[$varContent]);
}
@@ -232,7 +232,7 @@ public function process(File $phpcsFile, int $stackPtr)
$varContent = '';
if ($stringToken[0] === T_DOLLAR_OPEN_CURLY_BRACES) {
- $varContent = '$'.$stringTokens[($stringPtr + 1)][1];
+ $varContent = '$' . $stringTokens[($stringPtr + 1)][1];
} else if ($stringToken[0] === T_VARIABLE) {
$varContent = $stringToken[1];
}
@@ -269,7 +269,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (isset($params[$methodParams[$i]['name']]) === true) {
$errorInfo[$methodParams[$i]['name']] = [
'position' => $params[$methodParams[$i]['name']],
- 'errorcode' => $errorCode.'BeforeLastUsed',
+ 'errorcode' => $errorCode . 'BeforeLastUsed',
'typehint' => $methodParams[$i]['type_hint'],
];
}
@@ -279,7 +279,7 @@ public function process(File $phpcsFile, int $stackPtr)
} else {
$errorInfo[$methodParams[$i]['name']] = [
'position' => $params[$methodParams[$i]['name']],
- 'errorcode' => $errorCode.'AfterLastUsed',
+ 'errorcode' => $errorCode . 'AfterLastUsed',
'typehint' => $methodParams[$i]['type_hint'],
];
}
diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php
index 32d840f6da..6a96c26d9f 100644
--- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php
+++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php
@@ -202,7 +202,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
$indent = str_repeat(' ', $tokens[$stackPtr]['column']);
- $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar.$indent.'*'.$phpcsFile->eolChar);
+ $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar . $indent . '*' . $phpcsFile->eolChar);
$phpcsFile->fixer->endChangeset();
}
}
@@ -293,7 +293,7 @@ public function process(File $phpcsFile, int $stackPtr)
}
$indent = str_repeat(' ', $tokens[$stackPtr]['column']);
- $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar.$indent.'*'.$phpcsFile->eolChar);
+ $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar . $indent . '*' . $phpcsFile->eolChar);
$phpcsFile->fixer->endChangeset();
}
}
diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
index d4ff889df0..3683956e21 100644
--- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
+++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
@@ -308,7 +308,7 @@ public function process(File $phpcsFile, int $stackPtr)
$addedContent = '';
}
- $addedContent .= $indent.'}';
+ $addedContent .= $indent . '}';
if ($next !== false && $tokens[$endToken]['code'] === T_COMMENT) {
$addedContent .= $phpcsFile->eolChar;
}
diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
index 81d7e35fd9..8f2ce181e6 100644
--- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
+++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php
@@ -343,7 +343,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null)
continue;
}
- $expectedText = $data['expected'].' space';
+ $expectedText = $data['expected'] . ' space';
if ($data['expected'] !== 1) {
$expectedText .= 's';
}
@@ -351,7 +351,7 @@ public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end = null)
if ($data['found'] === null) {
$foundText = 'a new line';
} else {
- $foundText = $data['found'].' space';
+ $foundText = $data['found'] . ' space';
if ($data['found'] !== 1) {
$foundText .= 's';
}
diff --git a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php
index fd7302a9a2..ac2048f605 100644
--- a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php
+++ b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php
@@ -149,7 +149,7 @@ protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $
$className = $phpcsFile->getDeclarationName($currScope);
}
- $errorData = [$className.'::'.$methodName];
+ $errorData = [$className . '::' . $methodName];
$methodNameLc = strtolower($methodName);
$classNameLc = strtolower($className);
@@ -173,7 +173,7 @@ protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $
}
// PHP4 destructors are allowed to break our rules.
- if ($methodNameLc === '_'.$classNameLc) {
+ if ($methodNameLc === '_' . $classNameLc) {
return;
}
diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php
index c3cf71d598..b6e053ca27 100644
--- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php
+++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php
@@ -138,8 +138,8 @@ public function process(File $phpcsFile, int $stackPtr)
$error = 'Constants must be uppercase; expected %s but found %s';
$data = [
- $prefix.strtoupper($constName),
- $prefix.$constName,
+ $prefix . strtoupper($constName),
+ $prefix . $constName,
];
$phpcsFile->addError($error, $constPtr, 'ConstantNotUpperCase', $data);
} else {
diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php
index f86e4983ee..061f9bc21e 100644
--- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php
+++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php
@@ -53,7 +53,7 @@ public function process(File $phpcsFile, int $stackPtr)
if (preg_match('`(