diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 1b65e17..d6e65e7 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -25,7 +25,6 @@ jobs:
- "lowest"
- "highest"
php-version:
- - "8.3"
- "8.4"
- "8.5"
operating-system:
diff --git a/.php-cs-fixer-rules.php b/.php-cs-fixer-rules.php
index 10e6ccb..d94a627 100644
--- a/.php-cs-fixer-rules.php
+++ b/.php-cs-fixer-rules.php
@@ -3,13 +3,19 @@
/**
* Shared PHP-CS-Fixer rules for PER projects.
* @see https://localheinz.com/articles/2023/03/10/sharing-configurations-for-php-cs-fixer-across-projects/
- * How to use:
- * $rules = require __DIR__.'/vendor/interaction-design-foundation/php-cs-fixer-rules.php';
+ *
+ * Prefer the autoloaded API: \IxDFCodingStandard\PhpCsFixer\Rules::get() (or Config::create()).
+ * This raw file is the no-autoloader fallback; require it directly when needed:
+ * $rules = require __DIR__.'/vendor/interaction-design-foundation/coding-standard/.php-cs-fixer-rules.php';
* $config->setRules($rules);
*/
return [
// Basic PER Coding Style 3.0 ruleset plus our overrides for it, see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/ruleSets/PER-CS3x0.rst
'@PER-CS3x0' => true, // https://www.php-fig.org/per/coding-style/
+ // Auto-modernize syntax to the target PHP/PHPUnit version. Renovate bumps PHP-CS-Fixer, so new migration rules arrive for free.
+ '@PHP8x4Migration' => true,
+ '@PHP8x4Migration:risky' => true,
+ '@PHPUnit10x0Migration:risky' => true,
'new_with_parentheses' => ['anonymous_class' => true], // It will be changed in PHP-CS-Fixer v4.0 (but we want to enforce it), see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/8148
// overrides for PER-CS2.0/PER-CS3.0
'concat_space' => ['spacing' => 'none'], // make strings shorter "'hello' . $name . '!'" => "'hello'.$name.'!'"
@@ -71,6 +77,7 @@
'normalize_index_brace' => true,
'nullable_type_declaration' => ['syntax' => 'question_mark'],
'nullable_type_declaration_for_default_null_value' => true,
+ 'numeric_literal_separator' => ['strategy' => 'use_separator', 'override_existing' => false],
'object_operator_without_whitespace' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
/*
diff --git a/IxDFCodingStandard/PhpCsFixer/Config.php b/IxDFCodingStandard/PhpCsFixer/Config.php
index 7af4490..02d7cc5 100644
--- a/IxDFCodingStandard/PhpCsFixer/Config.php
+++ b/IxDFCodingStandard/PhpCsFixer/Config.php
@@ -9,6 +9,7 @@
/**
* Pre-configured PHP-CS-Fixer config factory for IxDF projects.
* @see README.md for usage examples
+ * @api
*/
final class Config
{
diff --git a/IxDFCodingStandard/PhpCsFixer/Rules.php b/IxDFCodingStandard/PhpCsFixer/Rules.php
index f398324..c6658c4 100644
--- a/IxDFCodingStandard/PhpCsFixer/Rules.php
+++ b/IxDFCodingStandard/PhpCsFixer/Rules.php
@@ -5,6 +5,7 @@
/**
* Shared PHP-CS-Fixer rules for IxDF projects.
* @see https://mlocati.github.io/php-cs-fixer-configurator/
+ * @api
*/
final class Rules
{
diff --git a/IxDFCodingStandard/ruleset.xml b/IxDFCodingStandard/ruleset.xml
index 9aa8c43..9774b8f 100644
--- a/IxDFCodingStandard/ruleset.xml
+++ b/IxDFCodingStandard/ruleset.xml
@@ -13,52 +13,18 @@
-
-
-
- error
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
@@ -68,8 +34,6 @@
-
-
@@ -86,8 +50,6 @@
-
-
@@ -107,8 +69,6 @@
-
-
@@ -163,18 +123,12 @@
-
-
-
-
-
-
@@ -188,8 +142,6 @@
-
-
@@ -220,7 +172,6 @@
-
@@ -248,18 +199,13 @@
-
-
-
-
-
@@ -301,7 +247,6 @@
-
@@ -311,7 +256,6 @@
-
@@ -321,7 +265,6 @@
6
-
@@ -330,7 +273,6 @@
-
@@ -345,9 +287,6 @@
-
-
-
@@ -359,7 +298,6 @@
-
@@ -396,6 +334,8 @@
+
+
@@ -416,8 +356,6 @@
-
-
@@ -486,43 +424,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 5
-
diff --git a/README.md b/README.md
index 3f188c2..b4e4d0e 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,10 @@
# IxDF Coding Standard
-An opinionated coding standard for PHP/Laravel projects. Provides two independent tools — use either one or both together:
+An opinionated coding standard for PHP/Laravel projects. The two tools play different roles and are meant to run together:
-- **PHP_CodeSniffer** — custom sniffs for strict types and Laravel conventions
-- **PHP-CS-Fixer** — shared config with 80+ rules based on PER-CS 3.0
+- **PHP-CS-Fixer** (primary) — shared config based on the [latest PER Coding Style](https://www.php-fig.org/per/coding-style/) (currently PER-CS 3.0), plus formatting and modernization rules. It owns all code formatting and auto-fixes it.
+- **PHP_CodeSniffer** (supplementary) — adds the structural and semantic checks PHP-CS-Fixer cannot enforce (strict types, Laravel conventions, naming, complexity). Formatting rules already covered by PHP-CS-Fixer are intentionally **not** duplicated here, so PHP_CodeSniffer is not a complete standard on its own.
## Installation
@@ -16,21 +16,6 @@ An opinionated coding standard for PHP/Laravel projects. Provides two independen
composer require --dev interaction-design-foundation/coding-standard
```
-## PHP_CodeSniffer
-
-Create `phpcs.xml` in your project root:
-```xml
-
-
-
- app
- config
- database
- routes
- tests
-
-```
-
## PHP-CS-Fixer
Create `.php-cs-fixer.php` in your project root:
@@ -43,18 +28,17 @@ use IxDFCodingStandard\PhpCsFixer\Config;
return Config::create(__DIR__);
```
-With rule overrides:
+`Config::create()` ships a sensible default Finder and enables parallel runs, risky rules, and caching. Two optional arguments let you adjust it:
```php
+// Override individual rules.
return Config::create(__DIR__, ruleOverrides: [
'final_public_method_for_abstract_class' => false,
]);
```
-With a custom Finder:
-
```php
-use IxDFCodingStandard\PhpCsFixer\Config;
+// Provide your own Finder.
use PhpCsFixer\Finder;
$finder = Finder::create()->in(__DIR__)->name('*.php');
@@ -62,27 +46,48 @@ $finder = Finder::create()->in(__DIR__)->name('*.php');
return Config::create(__DIR__, finder: $finder);
```
-If you only need the rules array:
+Need only the rules array (e.g. to compose your own config)?
+
```php
$rules = \IxDFCodingStandard\PhpCsFixer\Rules::get();
```
-## Usage
+Run it:
```shell
-vendor/bin/phpcs # check with PHP_CodeSniffer
-vendor/bin/phpcbf # fix with PHP_CodeSniffer
-vendor/bin/php-cs-fixer fix --dry-run --diff # check with PHP-CS-Fixer
-vendor/bin/php-cs-fixer fix # fix with PHP-CS-Fixer
+vendor/bin/php-cs-fixer fix --dry-run --diff # check
+vendor/bin/php-cs-fixer fix # fix
```
-### Composer scripts (recommended)
+## PHP_CodeSniffer
-Add to your `composer.json`:
+Create `phpcs.xml` in your project root:
+
+```xml
+
+
+
+ app
+ config
+ database
+ routes
+ tests
+
+```
+
+Run it:
+
+```shell
+vendor/bin/phpcs # check
+vendor/bin/phpcbf # fix
+```
+
+## Composer scripts (recommended)
+
+Wire both tools into `composer.json` so the whole team runs them the same way:
```json
"scripts": {
- "cs": "@cs:fix",
"cs:check": ["@php-cs-fixer:dry", "@phpcs"],
"cs:fix": ["@php-cs-fixer", "@phpcbf"],
"phpcs": "phpcs -p -s --colors --report-full --report-summary",
@@ -92,11 +97,7 @@ Add to your `composer.json`:
}
```
-Then run:
-
```shell
-composer cs:check # run both tools in check mode
-composer cs:fix # run both tools in fix mode
-composer phpcs # PHP_CodeSniffer only
-composer php-cs-fixer # PHP-CS-Fixer only
+composer cs:check # check with both tools
+composer cs:fix # fix with both tools
```
diff --git a/composer.json b/composer.json
index 68bfff3..2406556 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"license": "MIT",
"type": "phpcodesniffer-standard",
"require": {
- "php": "^8.3",
+ "php": "^8.4",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"friendsofphp/php-cs-fixer": "^3.89",
"slevomat/coding-standard": "^8.29",
diff --git a/tests/PhpCsFixer/RulesTest.php b/tests/PhpCsFixer/RulesTest.php
new file mode 100644
index 0000000..c00bdc4
--- /dev/null
+++ b/tests/PhpCsFixer/RulesTest.php
@@ -0,0 +1,27 @@
+getRules());
+ self::assertTrue($config->getRiskyAllowed());
+ }
+}