From 4e96d5aab8aa863cdfd2a5829e6abfc9a49a8705 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Mon, 24 Nov 2025 09:30:28 +0100 Subject: [PATCH] Add support for `extension.neon` --- README.md | 13 ++++++++++--- composer.json | 14 ++++++++++++-- extension.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ .../config/configured_rule.neon | 3 +++ tests/test-extension.neon | 2 ++ 14 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 extension.neon create mode 100644 tests/test-extension.neon diff --git a/README.md b/README.md index 4af1f21..f9adeb3 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,18 @@ To install the PHPStan rules for Symfony UX, you can use Composer: composer require --dev kocal/phpstan-symfony-ux ``` -## Configuration +If you have [phpstan/extension-installer](https://github.com/phpstan/extension-installer) installed (which is the case by default), the extension will be automatically registered and you're ready to go. + +If you don't use the extension installer, you'll need to manually add the extension to your `phpstan.neon` or `phpstan.dist.neon` configuration file: + +```yaml +includes: + - vendor/kocal/phpstan-symfony-ux/extension.neon +``` -After installing the package, you need to configure PHPStan to use the rules. +## Configuration -Each rule can be enabled individually by adding it to your `phpstan.dist.neon` configuration file. +Each rule can be enabled individually by adding it to your `phpstan.neon` or `phpstan.dist.neon` configuration file. ## LiveComponent Rules diff --git a/composer.json b/composer.json index cddac6f..93cb215 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "kocal/phpstan-symfony-ux", "description": "PHPStan rules for Symfony UX", - "type": "library", + "type": "phpstan-extension", "license": "MIT", "authors": [ { @@ -40,8 +40,18 @@ "symfony/ux-twig-component": "^2.0", "symplify/easy-coding-standard": "^13.0" }, + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/extension.neon b/extension.neon new file mode 100644 index 0000000..df953a8 --- /dev/null +++ b/extension.neon @@ -0,0 +1,3 @@ +# This file is intentionally empty for backward compatibility purposes. +# Rules must be enabled individually in your phpstan.neon configuration. +# See README.md for available rules and their configuration. diff --git a/tests/Rules/LiveComponent/LiveActionMethodsShouldBePublicRule/config/configured_rule.neon b/tests/Rules/LiveComponent/LiveActionMethodsShouldBePublicRule/config/configured_rule.neon index 3f69b1c..6ca221c 100644 --- a/tests/Rules/LiveComponent/LiveActionMethodsShouldBePublicRule/config/configured_rule.neon +++ b/tests/Rules/LiveComponent/LiveActionMethodsShouldBePublicRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\LiveComponent\LiveActionMethodsShouldBePublicRule diff --git a/tests/Rules/TwigComponent/ClassMustBeFinalRule/config/configured_rule.neon b/tests/Rules/TwigComponent/ClassMustBeFinalRule/config/configured_rule.neon index 3e5d032..3854103 100644 --- a/tests/Rules/TwigComponent/ClassMustBeFinalRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/ClassMustBeFinalRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ClassMustBeFinalRule diff --git a/tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/config/configured_rule.neon b/tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/config/configured_rule.neon index 2287089..d959baf 100644 --- a/tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/ClassNameShouldNotEndWithComponentRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ClassNameShouldNotEndWithComponentRule diff --git a/tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/config/configured_rule.neon b/tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/config/configured_rule.neon index a4f0b31..b1296aa 100644 --- a/tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/ExposePublicPropsShouldBeFalseRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ExposePublicPropsShouldBeFalseRule diff --git a/tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/config/configured_rule.neon b/tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/config/configured_rule.neon index be4a372..95344f3 100644 --- a/tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/ForbiddenAttributesPropertyRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ForbiddenAttributesPropertyRule diff --git a/tests/Rules/TwigComponent/ForbiddenClassPropertyRule/config/configured_rule.neon b/tests/Rules/TwigComponent/ForbiddenClassPropertyRule/config/configured_rule.neon index b719d97..c7dbfd7 100644 --- a/tests/Rules/TwigComponent/ForbiddenClassPropertyRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/ForbiddenClassPropertyRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ForbiddenClassPropertyRule diff --git a/tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/config/configured_rule.neon b/tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/config/configured_rule.neon index d35fafb..51bb3ee 100644 --- a/tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule diff --git a/tests/Rules/TwigComponent/PostMountMethodSignatureRule/config/configured_rule.neon b/tests/Rules/TwigComponent/PostMountMethodSignatureRule/config/configured_rule.neon index 620095f..368959d 100644 --- a/tests/Rules/TwigComponent/PostMountMethodSignatureRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/PostMountMethodSignatureRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\PostMountMethodSignatureRule diff --git a/tests/Rules/TwigComponent/PreMountMethodSignatureRule/config/configured_rule.neon b/tests/Rules/TwigComponent/PreMountMethodSignatureRule/config/configured_rule.neon index defbfce..a83146f 100644 --- a/tests/Rules/TwigComponent/PreMountMethodSignatureRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/PreMountMethodSignatureRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\PreMountMethodSignatureRule diff --git a/tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/config/configured_rule.neon b/tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/config/configured_rule.neon index 2228da8..3ae94cc 100644 --- a/tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/config/configured_rule.neon +++ b/tests/Rules/TwigComponent/PublicPropertiesShouldBeCamelCaseRule/config/configured_rule.neon @@ -1,2 +1,5 @@ +includes: + - ../../../../test-extension.neon + rules: - Kocal\PHPStanSymfonyUX\Rules\TwigComponent\PublicPropertiesShouldBeCamelCaseRule diff --git a/tests/test-extension.neon b/tests/test-extension.neon new file mode 100644 index 0000000..6d4252f --- /dev/null +++ b/tests/test-extension.neon @@ -0,0 +1,2 @@ +includes: + - ../extension.neon