Skip to content

Commit 6d70d3b

Browse files
committed
CS: single space before/after concat operators
Includes removing the rule enforcing no space from the PHPCS native ruleset and replacing the Squiz operator spacing sniff with the PSR12 one, which will now handle enforcing of spaces around the concat operators (as well as spacing around boolean operators which was not being checked so far...).
1 parent a6afaed commit 6d70d3b

File tree

240 files changed

+2159
-2160
lines changed

Some content is hidden

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

240 files changed

+2159
-2160
lines changed

autoload.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public static function load(string $className)
7878
}
7979

8080
if (strpos(__DIR__, 'phar://') !== 0
81-
&& @file_exists(__DIR__.'/../../autoload.php') === true
81+
&& @file_exists(__DIR__ . '/../../autoload.php') === true
8282
) {
83-
self::$composerAutoloader = include __DIR__.'/../../autoload.php';
83+
self::$composerAutoloader = include __DIR__ . '/../../autoload.php';
8484
if (self::$composerAutoloader instanceof ClassLoader) {
8585
self::$composerAutoloader->unregister();
8686
self::$composerAutoloader->register();
@@ -99,16 +99,16 @@ public static function load(string $className)
9999

100100
if (substr($className, 0, 16) === 'PHP_CodeSniffer\\') {
101101
if (substr($className, 0, 22) === 'PHP_CodeSniffer\Tests\\') {
102-
$isInstalled = !is_dir(__DIR__.$ds.'tests');
102+
$isInstalled = !is_dir(__DIR__ . $ds . 'tests');
103103
if ($isInstalled === false) {
104-
$path = __DIR__.$ds.'tests';
104+
$path = __DIR__ . $ds . 'tests';
105105
} else {
106-
$path = '@test_dir@'.$ds.'PHP_CodeSniffer'.$ds.'CodeSniffer';
106+
$path = '@test_dir@' . $ds . 'PHP_CodeSniffer' . $ds . 'CodeSniffer';
107107
}
108108

109-
$path .= $ds.substr(str_replace('\\', $ds, $className), 22).'.php';
109+
$path .= $ds . substr(str_replace('\\', $ds, $className), 22) . '.php';
110110
} else {
111-
$path = __DIR__.$ds.'src'.$ds.substr(str_replace('\\', $ds, $className), 16).'.php';
111+
$path = __DIR__ . $ds . 'src' . $ds . substr(str_replace('\\', $ds, $className), 16) . '.php';
112112
}
113113
}
114114

@@ -125,7 +125,7 @@ public static function load(string $className)
125125
$className = substr($className, (strlen($nsPrefix) + 1));
126126
}
127127

128-
$path = $searchPath.$ds.str_replace('\\', $ds, $className).'.php';
128+
$path = $searchPath . $ds . str_replace('\\', $ds, $className) . '.php';
129129
if (is_file($path) === true) {
130130
break;
131131
}
@@ -342,5 +342,5 @@ public static function getLoadedFiles()
342342
// Register the autoloader before any existing autoloaders to ensure
343343
// it gets a chance to hear about every autoload request, and record
344344
// the file and class name for it.
345-
spl_autoload_register(__NAMESPACE__.'\Autoload::load', true, true);
345+
spl_autoload_register(__NAMESPACE__ . '\Autoload::load', true, true);
346346
}//end if

bin/phpcbf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*/
2222

2323
// Check if the PHP version and extensions comply with the minimum requirements before anything else.
24-
require_once dirname(__DIR__).'/requirements.php';
24+
require_once dirname(__DIR__) . '/requirements.php';
2525
PHP_CodeSniffer\checkRequirements();
2626

27-
require_once dirname(__DIR__).'/autoload.php';
27+
require_once dirname(__DIR__) . '/autoload.php';
2828

2929
$runner = new PHP_CodeSniffer\Runner();
3030
$exitCode = $runner->runPHPCBF();

bin/phpcs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*/
2222

2323
// Check if the PHP version and extensions comply with the minimum requirements before anything else.
24-
require_once dirname(__DIR__).'/requirements.php';
24+
require_once dirname(__DIR__) . '/requirements.php';
2525
PHP_CodeSniffer\checkRequirements();
2626

27-
require_once dirname(__DIR__).'/autoload.php';
27+
require_once dirname(__DIR__) . '/autoload.php';
2828

2929
$runner = new PHP_CodeSniffer\Runner();
3030
$exitCode = $runner->runPHPCS();

phpcs.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,13 @@
6161
<rule ref="Squiz.Operators.ComparisonOperatorUsage"/>
6262
<rule ref="Squiz.PHP.DisallowInlineIf"/>
6363
<rule ref="Squiz.Scope.MethodScope"/>
64-
<rule ref="Squiz.Strings.ConcatenationSpacing"/>
6564
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
6665
<rule ref="Generic.Strings.UnnecessaryHeredoc"/>
6766
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
6867
<rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
6968
<rule ref="Squiz.WhiteSpace.FunctionSpacing"/>
7069
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
71-
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
70+
<rule ref="PSR12.Operators.OperatorSpacing"/>
7271
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
7372
<rule ref="Generic.Arrays.DisallowLongArraySyntax">
7473
<!-- Files involved in the requirements check should stay compatible with PHP 5.3. -->

requirements.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function checkRequirements()
3434

3535
// Check the PHP version.
3636
if (PHP_VERSION_ID < 70200) {
37-
$error = 'ERROR: PHP_CodeSniffer requires PHP version 7.2.0 or greater.'.PHP_EOL;
37+
$error = 'ERROR: PHP_CodeSniffer requires PHP version 7.2.0 or greater.' . PHP_EOL;
3838
fwrite(STDERR, $error);
3939
exit($exitCode);
4040
}
@@ -55,17 +55,17 @@ function checkRequirements()
5555
if (empty($missingExtensions) === false) {
5656
$last = array_pop($requiredExtensions);
5757
$required = implode(', ', $requiredExtensions);
58-
$required .= ' and '.$last;
58+
$required .= ' and ' . $last;
5959

6060
if (count($missingExtensions) === 1) {
6161
$missing = $missingExtensions[0];
6262
} else {
6363
$last = array_pop($missingExtensions);
6464
$missing = implode(', ', $missingExtensions);
65-
$missing .= ' and '.$last;
65+
$missing .= ' and ' . $last;
6666
}
6767

68-
$error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.'.PHP_EOL;
68+
$error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.' . PHP_EOL;
6969
fwrite(STDERR, sprintf($error, $required, $missing));
7070
exit($exitCode);
7171
}

scripts/build-phar.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
error_reporting(E_ALL);
2424

2525
if (ini_get('phar.readonly') === '1') {
26-
echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL;
26+
echo 'Unable to build, phar.readonly in php.ini is set to read only.' . PHP_EOL;
2727
exit(1);
2828
}
2929

30-
require_once dirname(__DIR__).'/autoload.php';
31-
require_once dirname(__DIR__).'/src/Util/Tokens.php';
30+
require_once dirname(__DIR__) . '/autoload.php';
31+
require_once dirname(__DIR__) . '/src/Util/Tokens.php';
3232

3333
if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
3434
define('PHP_CODESNIFFER_VERBOSITY', 0);
@@ -54,13 +54,13 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
5454
$tokenizer = new PHP($contents, $config, "\n");
5555
$tokens = $tokenizer->getTokens();
5656
} catch (TokenizerException $e) {
57-
throw new RuntimeException('Failed to tokenize file '.$fullpath);
57+
throw new RuntimeException('Failed to tokenize file ' . $fullpath);
5858
}
5959

6060
$stripped = '';
6161
foreach ($tokens as $token) {
6262
if ($token['code'] === T_ATTRIBUTE_END || $token['code'] === T_OPEN_TAG) {
63-
$stripped .= $token['content']."\n";
63+
$stripped .= $token['content'] . "\n";
6464
continue;
6565
}
6666

@@ -87,13 +87,13 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
8787
];
8888

8989
foreach ($scripts as $script) {
90-
echo "Building $script phar".PHP_EOL;
90+
echo "Building $script phar" . PHP_EOL;
9191

92-
$pharName = $script.'.phar';
93-
$pharFile = getcwd().'/'.$pharName;
94-
echo "\t=> $pharFile".PHP_EOL;
92+
$pharName = $script . '.phar';
93+
$pharFile = getcwd() . '/' . $pharName;
94+
echo "\t=> $pharFile" . PHP_EOL;
9595
if (file_exists($pharFile) === true) {
96-
echo "\t** file exists, removing **".PHP_EOL;
96+
echo "\t** file exists, removing **" . PHP_EOL;
9797
unlink($pharFile);
9898
}
9999

@@ -105,7 +105,7 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
105105

106106
echo "\t=> adding files... ";
107107

108-
$srcDir = realpath(__DIR__.'/../src');
108+
$srcDir = realpath(__DIR__ . '/../src');
109109
$srcDirLen = strlen($srcDir);
110110

111111
$rdi = new RecursiveDirectoryIterator($srcDir, RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
@@ -123,11 +123,11 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
123123
}
124124

125125
$fullpath = $file->getPathname();
126-
if (strpos($fullpath, DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR) !== false) {
126+
if (strpos($fullpath, DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR) !== false) {
127127
continue;
128128
}
129129

130-
$path = 'src'.substr($fullpath, $srcDirLen);
130+
$path = 'src' . substr($fullpath, $srcDirLen);
131131

132132
if (substr($filename, -4) === '.xml') {
133133
$phar->addFile($fullpath, $path);
@@ -140,39 +140,39 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
140140
}//end foreach
141141

142142
// Add requirements check.
143-
$phar->addFromString('requirements.php', stripWhitespaceAndComments(realpath(__DIR__.'/../requirements.php'), $config));
143+
$phar->addFromString('requirements.php', stripWhitespaceAndComments(realpath(__DIR__ . '/../requirements.php'), $config));
144144

145145
// Add autoloader.
146-
$phar->addFromString('autoload.php', stripWhitespaceAndComments(realpath(__DIR__.'/../autoload.php'), $config));
146+
$phar->addFromString('autoload.php', stripWhitespaceAndComments(realpath(__DIR__ . '/../autoload.php'), $config));
147147

148148
// Add licence file.
149-
$phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt');
149+
$phar->addFile(realpath(__DIR__ . '/../licence.txt'), 'licence.txt');
150150

151-
echo 'done'.PHP_EOL;
152-
echo "\t Added ".$fileCount.' files'.PHP_EOL;
151+
echo 'done' . PHP_EOL;
152+
echo "\t Added " . $fileCount . ' files' . PHP_EOL;
153153

154154
/*
155155
Add the stub.
156156
*/
157157

158158
echo "\t=> adding stub... ";
159-
$stub = '#!/usr/bin/env php'."\n";
160-
$stub .= '<?php'."\n";
161-
$stub .= 'Phar::mapPhar(\''.$pharName.'\');'."\n";
162-
$stub .= 'require_once "phar://'.$pharName.'/requirements.php";'."\n";
163-
$stub .= 'PHP_CodeSniffer\checkRequirements();'."\n";
164-
$stub .= 'require_once "phar://'.$pharName.'/autoload.php";'."\n";
165-
$stub .= '$runner = new PHP_CodeSniffer\Runner();'."\n";
166-
$stub .= '$exitCode = $runner->run'.$script.'();'."\n";
167-
$stub .= 'exit($exitCode);'."\n";
159+
$stub = '#!/usr/bin/env php' . "\n";
160+
$stub .= '<?php' . "\n";
161+
$stub .= 'Phar::mapPhar(\'' . $pharName . '\');' . "\n";
162+
$stub .= 'require_once "phar://' . $pharName . '/requirements.php";' . "\n";
163+
$stub .= 'PHP_CodeSniffer\checkRequirements();' . "\n";
164+
$stub .= 'require_once "phar://' . $pharName . '/autoload.php";' . "\n";
165+
$stub .= '$runner = new PHP_CodeSniffer\Runner();' . "\n";
166+
$stub .= '$exitCode = $runner->run' . $script . '();' . "\n";
167+
$stub .= 'exit($exitCode);' . "\n";
168168
$stub .= '__HALT_COMPILER();';
169169
$phar->setStub($stub);
170170

171-
echo 'done'.PHP_EOL;
171+
echo 'done' . PHP_EOL;
172172
}//end foreach
173173

174174
Timing::printRunTime();
175175

176176
echo PHP_EOL;
177-
echo 'Filesize generated phpcs.phar file: '.number_format(filesize(dirname(__DIR__).'/phpcs.phar'), 0, ',', '.').' bytes'.PHP_EOL;
178-
echo 'Filesize generated phpcs.phar file: '.number_format(filesize(dirname(__DIR__).'/phpcbf.phar'), 0, ',', '.').' bytes'.PHP_EOL;
177+
echo 'Filesize generated phpcs.phar file: ' . number_format(filesize(dirname(__DIR__) . '/phpcs.phar'), 0, ',', '.') . ' bytes' . PHP_EOL;
178+
echo 'Filesize generated phpcs.phar file: ' . number_format(filesize(dirname(__DIR__) . '/phpcbf.phar'), 0, ',', '.') . ' bytes' . PHP_EOL;

scripts/get-requirements-check-matrix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
error_reporting(E_ALL);
1515

16-
require_once __DIR__.'/BuildRequirementsCheckMatrix.php';
16+
require_once __DIR__ . '/BuildRequirementsCheckMatrix.php';
1717

1818
echo json_encode(['include' => (new PHP_CodeSniffer\BuildRequirementsCheckMatrix())->getBuilds()]);

0 commit comments

Comments
 (0)