Skip to content

Commit 61ab247

Browse files
committed
PHPCS 4.0 compat
1 parent 1282222 commit 61ab247

File tree

8 files changed

+129
-121
lines changed

8 files changed

+129
-121
lines changed

Proton/Sniffs/Spacing/ArrowFunctionSpacingSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public function process(File $phpcsFile, $stackPtr): void
2424
{
2525
$tokens = $phpcsFile->getTokens();
2626

27-
if ($tokens[$stackPtr]['code'] === T_FN && $tokens[$stackPtr + 1]['code'] !== T_WHITESPACE) {
27+
if ($tokens[$stackPtr]['code'] === T_FN && $tokens[$stackPtr + 1]['code'] !== T_OPEN_PARENTHESIS) {
2828
$phpcsFile->addError(
29-
'The fn arrow function token should always be followed by a space.',
29+
'The fn keyword MUST NOT be succeeded by a space.',
3030
$stackPtr,
3131
'Found',
3232
);

Proton/ruleset.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0"?>
2-
<ruleset name="Proton">
2+
<ruleset
3+
name="Proton"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd"
6+
>
37
<description>
48
Proton PHP Coding Standard
59
</description>
@@ -123,7 +127,6 @@
123127

124128
<!-- # Slevomat Coding Standard -->
125129
<!-- https://github.com/slevomat/coding-standard -->
126-
<config name="installed_paths" value="../../slevomat/coding-standard"/>
127130

128131
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
129132
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
@@ -133,6 +136,7 @@
133136
<property name="ignoreComplexTernaryConditions" value="1"/>
134137
</properties>
135138
</rule>
139+
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
136140
<!-- Require usage of constructor property promotion -->
137141
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
138142
<!-- Forbid uses of multiple traits separated by comma -->

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"scripts": {
1414
"test-fix": "phpcs --standard=phpcs.xml --report=diff tests > tests/out.diff && diff tests/out.diff tests/expected.diff",
1515
"test-print": "phpcs --standard=phpcs.xml --report=summary tests",
16-
"test": "phpcs --standard=phpcs.xml --report=csv tests | sort -r | cut -f 2,3,4,6 -d ',' > tests/out.csv && diff tests/expected_csv.txt tests/out.csv"
16+
"test": "phpcs --standard=phpcs.xml --report=csv tests/ | cut -f 1,2,3,4,6 -d ',' | sort -r > tests/out.csv && diff -u tests/expected_csv.txt tests/out.csv"
1717
},
1818
"require": {
1919
"php": "^8.0",
20-
"slevomat/coding-standard": "^8.0",
21-
"squizlabs/php_codesniffer": "^3.7"
20+
"slevomat/coding-standard": "^8.24",
21+
"squizlabs/php_codesniffer": "^4.0"
2222
},
2323
"license": "MIT",
2424
"config": {

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Proton PHP Coding Standard
55
</description>
66

7-
<config name="installed_paths" value="Proton"/>
7+
<arg name="basepath" value="." />
88

99
<rule ref="Proton"/>
1010

tests/correct/ClassOk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(array $config)
3737

3838
phpinfo2();
3939

40-
call_user_func(fn () => {});
40+
call_user_func(fn() => {});
4141
}
4242

4343
public function ping(Request $request): mixed

tests/expected_csv.txt

Lines changed: 115 additions & 111 deletions
Large diffs are not rendered by default.

tests/wrong/Class1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct()
2828
$this->test = new class() {
2929
};
3030

31-
call_user_func(fn() => {});
31+
call_user_func(fn () => {});
3232
}
3333

3434
private function unused() {
File renamed without changes.

0 commit comments

Comments
 (0)