diff --git a/Eventjet/ruleset.xml b/Eventjet/ruleset.xml
index 920d2f9..ca4b4aa 100644
--- a/Eventjet/ruleset.xml
+++ b/Eventjet/ruleset.xml
@@ -80,8 +80,12 @@
-
-
+
+
+ 0
+
@@ -148,8 +152,14 @@
-
-
+
+
+
+
@@ -303,4 +313,18 @@
0
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/composer.json b/composer.json
index e57d3ec..7773f81 100644
--- a/composer.json
+++ b/composer.json
@@ -16,8 +16,8 @@
"require": {
"php": "^8.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6 || ^0.7 || ^1.0",
- "friendsofphp/php-cs-fixer": "^3.32",
- "slevomat/coding-standard": "^8.4",
+ "friendsofphp/php-cs-fixer": "^3.65",
+ "slevomat/coding-standard": "^8.16",
"squizlabs/php_codesniffer": "^3.6.1",
"webimpress/coding-standard": "^1.1"
},
diff --git a/php-cs-fixer-rules.php b/php-cs-fixer-rules.php
index f89b42b..8ed1b35 100644
--- a/php-cs-fixer-rules.php
+++ b/php-cs-fixer-rules.php
@@ -23,6 +23,20 @@
'function_declaration' => [
'closure_fn_spacing' => 'none',
],
+ 'general_phpdoc_annotation_remove' => [
+ 'annotations' => [
+ 'api',
+ 'author',
+ 'category',
+ 'copyright',
+ 'created',
+ 'license',
+ 'package',
+ 'since',
+ 'subpackage',
+ 'version',
+ ],
+ ],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
@@ -31,19 +45,25 @@
'heredoc_indentation' => [
'indentation' => 'start_plus_one',
],
+ 'lambda_not_used_import' => true,
'native_constant_invocation' => [
'scope' => 'namespaced',
'strict' => true,
],
+ 'native_function_casing' => true,
'native_function_invocation' => [
'include' => ['@all'],
'scope' => 'namespaced',
'strict' => true,
],
+ 'native_type_declaration_casing' => true,
'new_with_parentheses' => [
'named_class' => true,
'anonymous_class' => false,
],
+ 'no_alias_functions' => [
+ 'sets' => ['@internal'],
+ ],
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
@@ -59,12 +79,30 @@
],
],
'no_multiline_whitespace_around_double_arrow' => true,
+ 'no_php4_constructor' => true,
+ 'no_singleline_whitespace_before_semicolons' => true,
+ 'no_spaces_around_offset' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
// Psalm wants us to have an explicit type annotation whenever we assign `mixed` to a variable.
'allow_mixed' => true,
],
'no_trailing_comma_in_singleline' => true,
+ 'no_unneeded_control_parentheses' => [
+ 'statements' => [
+ 'break',
+ 'clone',
+ 'continue',
+ 'echo_print',
+ 'negative_instanceof',
+ 'others',
+ 'return',
+ 'switch_case',
+ 'yield',
+ 'yield_from',
+ ],
+ ],
+ 'no_unneeded_final_method' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_concat_operator' => true,
@@ -73,8 +111,17 @@
'imports_order' => ['class', 'function', 'const'],
'sort_algorithm' => 'alpha',
],
+ 'phpdoc_scalar' => true,
'phpdoc_trim' => true,
+ // Wrong-order inline `@var` is lint territory — PHPStan and Psalm both
+ // fail to bind the type. Auto-canonicalizing it on the CS side hides the
+ // mistake from SA feedback instead of letting the user see and fix it,
+ // so keep this rule explicitly off (paired with the InvalidFormat exclude
+ // in Eventjet/ruleset.xml).
+ 'phpdoc_var_annotation_correct_order' => false,
'php_unit_data_provider_static' => true,
+ 'self_accessor' => true,
+ 'simplified_if_return' => true,
'single_quote' => true,
'single_space_around_construct' => true,
// Loose comparison is lint territory — PHPStan and Psalm both flag it. Kept
diff --git a/php-cs-fixer-strict-rules.php b/php-cs-fixer-strict-rules.php
index 8916b48..866fba9 100644
--- a/php-cs-fixer-strict-rules.php
+++ b/php-cs-fixer-strict-rules.php
@@ -39,7 +39,6 @@
'sort_algorithm' => 'none',
'null_adjustment' => 'always_last',
],
- 'self_accessor' => true,
'static_lambda' => true,
'trailing_comma_in_multiline' => [
'elements' => [
diff --git a/tests/RulesTest.php b/tests/RulesTest.php
index a79c3c1..245ec17 100644
--- a/tests/RulesTest.php
+++ b/tests/RulesTest.php
@@ -32,6 +32,20 @@ final class RulesTest extends TestCase
['HeredocNotIndented.php', 'phpcs'],
// PHP CS Fixer has no rule for multiple classes per file
['multiple-classes-per-file.php', 'php-cs-fixer'],
+ // PHP CS Fixer has no equivalent sniff
+ ['bracketed-namespace.php', 'php-cs-fixer'],
+ ['deprecated-function.php', 'php-cs-fixer'],
+ ['text-before-open-tag.php', 'php-cs-fixer'],
+ ['catch-exception.php', 'php-cs-fixer'],
+ ['assignment-in-condition.php', 'php-cs-fixer'],
+ ['dead-catch.php', 'php-cs-fixer'],
+ ['snake-case-variable.php', 'php-cs-fixer'],
+ ['forbidden-class-comment.php', 'php-cs-fixer'],
+ ['multiple-namespaces.php', 'php-cs-fixer'],
+ // PHPCS has no equivalent sniff
+ ['blank-line-after-phpdoc.php', 'phpcs'],
+ ['trailing-comma-singleline.php', 'phpcs'],
+ ['multiline-double-arrow.php', 'phpcs'],
];
private static function phpCsFixerCommand(string $file): string
diff --git a/tests/check-sa-overlap.sh b/tests/check-sa-overlap.sh
index dd31eb0..d2b3590 100755
--- a/tests/check-sa-overlap.sh
+++ b/tests/check-sa-overlap.sh
@@ -25,7 +25,9 @@ fi
cd "$(dirname "$0")/.."
EXPECTED_REL=(
+ tests/fixtures/valid/inline-doc-comment.php
tests/fixtures/valid/loose-comparison.php
+ tests/fixtures/valid/ThisInStatic.php
)
for f in "${EXPECTED_REL[@]}"; do
diff --git a/tests/fixtures/invalid/array-bracket-spacing.php b/tests/fixtures/invalid/array-bracket-spacing.php
new file mode 100644
index 0000000..2afc667
--- /dev/null
+++ b/tests/fixtures/invalid/array-bracket-spacing.php
@@ -0,0 +1,6 @@
+ 1];
+$bar = $foo[ 'a' ];
diff --git a/tests/fixtures/invalid/array-not-trimmed.php b/tests/fixtures/invalid/array-not-trimmed.php
new file mode 100644
index 0000000..79efe5c
--- /dev/null
+++ b/tests/fixtures/invalid/array-not-trimmed.php
@@ -0,0 +1,5 @@
+getMessage();
+}
diff --git a/tests/fixtures/invalid/control-signature.php b/tests/fixtures/invalid/control-signature.php
new file mode 100644
index 0000000..153c4f2
--- /dev/null
+++ b/tests/fixtures/invalid/control-signature.php
@@ -0,0 +1,10 @@
+getMessage();
+} catch (RuntimeException $e) {
+ echo $e->getMessage();
+}
diff --git a/tests/fixtures/invalid/deprecated-function.php b/tests/fixtures/invalid/deprecated-function.php
new file mode 100644
index 0000000..aebc1c9
--- /dev/null
+++ b/tests/fixtures/invalid/deprecated-function.php
@@ -0,0 +1,7 @@
+ */
+function generator(): iterable
+{
+ yield(1);
+}
+
+foreach (generator() as $value) {
+ echo $value;
+}
diff --git a/tests/fixtures/invalid/multiline-double-arrow.php b/tests/fixtures/invalid/multiline-double-arrow.php
new file mode 100644
index 0000000..46b9e3d
--- /dev/null
+++ b/tests/fixtures/invalid/multiline-double-arrow.php
@@ -0,0 +1,8 @@
+ 1,
+];
diff --git a/tests/fixtures/invalid/multiple-namespaces.php b/tests/fixtures/invalid/multiple-namespaces.php
new file mode 100644
index 0000000..4627ce4
--- /dev/null
+++ b/tests/fixtures/invalid/multiple-namespaces.php
@@ -0,0 +1,15 @@
+ 0) {
+ return $value * 2;
+ } else {
+ return 0;
+ }
+}
diff --git a/tests/fixtures/invalid/no-space-around-equals.php b/tests/fixtures/invalid/no-space-around-equals.php
new file mode 100644
index 0000000..b6cc543
--- /dev/null
+++ b/tests/fixtures/invalid/no-space-around-equals.php
@@ -0,0 +1,5 @@
+
+ */
+ public function provideValues(): iterable
+ {
+ yield [1];
+ }
+}
diff --git a/tests/fixtures/invalid/nullable-type-for-null-default.php b/tests/fixtures/invalid/nullable-type-for-null-default.php
new file mode 100644
index 0000000..dbcd1d1
--- /dev/null
+++ b/tests/fixtures/invalid/nullable-type-for-null-default.php
@@ -0,0 +1,8 @@
+bar = 1;
diff --git a/tests/fixtures/invalid/space-before-semicolon.php b/tests/fixtures/invalid/space-before-semicolon.php
new file mode 100644
index 0000000..7ed9502
--- /dev/null
+++ b/tests/fixtures/invalid/space-before-semicolon.php
@@ -0,0 +1,5 @@
+ 0) {
+ return 1;
+ } elseif ($value < 0) {
+ return -1;
+ }
+ return 0;
+}
diff --git a/tests/fixtures/invalid/text-before-open-tag.php b/tests/fixtures/invalid/text-before-open-tag.php
new file mode 100644
index 0000000..c79e54f
--- /dev/null
+++ b/tests/fixtures/invalid/text-before-open-tag.php
@@ -0,0 +1,6 @@
+text
+ 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
diff --git a/tests/fixtures/invalid/useless-if-with-return.php b/tests/fixtures/invalid/useless-if-with-return.php
new file mode 100644
index 0000000..e4ba109
--- /dev/null
+++ b/tests/fixtures/invalid/useless-if-with-return.php
@@ -0,0 +1,11 @@
+ 0) {
+ return true;
+ }
+ return false;
+}
diff --git a/tests/fixtures/invalid/useless-parentheses.php b/tests/fixtures/invalid/useless-parentheses.php
new file mode 100644
index 0000000..71ba622
--- /dev/null
+++ b/tests/fixtures/invalid/useless-parentheses.php
@@ -0,0 +1,8 @@
+bar;
+ }
+}
diff --git a/tests/fixtures/valid/inline-doc-comment.php b/tests/fixtures/valid/inline-doc-comment.php
new file mode 100644
index 0000000..2a5672a
--- /dev/null
+++ b/tests/fixtures/valid/inline-doc-comment.php
@@ -0,0 +1,15 @@
+