diff --git a/README.md b/README.md
index aca020a..4f193fd 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,51 @@ includes:
## LiveComponent Rules
+### AsLiveComponentArgumentsMustBeValidRule
+
+Enforces that the `#[AsLiveComponent]` attribute arguments have a supported value:
+- `method` must be `get` or `post`, in any case. Before `symfony/ux-live-component` 3.0 only lowercase works, so `GET` throws at runtime without being reported by this rule.
+- `fetchCredentials` (introduced in `symfony/ux-live-component` 2.33) must be `same-origin`, `include` or `omit`
+
+Symfony UX throws an `UnexpectedValueException` when the attribute is instantiated with another value; this rule reports it during static analysis instead.
+
+```yaml
+rules:
+ - Kocal\PHPStanSymfonyUX\Rules\LiveComponent\AsLiveComponentArgumentsMustBeValidRule
+```
+
+```php
+// src/Twig/Components/SearchResults.php
+namespace App\Twig\Components;
+
+use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
+
+#[AsLiveComponent(method: 'put', fetchCredentials: 'same_origin')]
+final class SearchResults
+{
+}
+```
+
+:x:
+
+
+
+```php
+// src/Twig/Components/SearchResults.php
+namespace App\Twig\Components;
+
+use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
+
+#[AsLiveComponent(method: 'get', fetchCredentials: 'include')]
+final class SearchResults
+{
+}
+```
+
+:+1:
+
+
+
### LiveActionMethodsVisibilityRule
Enforces that all methods annotated with `#[LiveAction]` in LiveComponents must be declared as public.
diff --git a/rules.neon b/rules.neon
index c7f8ee3..78ddd93 100644
--- a/rules.neon
+++ b/rules.neon
@@ -1,4 +1,5 @@
rules:
+ - Kocal\PHPStanSymfonyUX\Rules\LiveComponent\AsLiveComponentArgumentsMustBeValidRule
- Kocal\PHPStanSymfonyUX\Rules\LiveComponent\LiveActionMethodsVisibilityRule
- Kocal\PHPStanSymfonyUX\Rules\LiveComponent\LiveListenerMethodsVisibilityRule
- Kocal\PHPStanSymfonyUX\Rules\LiveComponent\LivePropHydrationMethodsRule
diff --git a/src/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule.php b/src/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule.php
new file mode 100644
index 0000000..a59c1fa
--- /dev/null
+++ b/src/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule.php
@@ -0,0 +1,95 @@
+
+ */
+final class AsLiveComponentArgumentsMustBeValidRule implements Rule
+{
+ private const METHODS = ['get', 'post'];
+
+ private const FETCH_CREDENTIALS = ['same-origin', 'include', 'omit'];
+
+ public function getNodeType(): string
+ {
+ return Class_::class;
+ }
+
+ public function processNode(Node $node, Scope $scope): array
+ {
+ if (! $attribute = AttributeFinder::findAttribute($node, AsLiveComponent::class)) {
+ return [];
+ }
+
+ $errors = [];
+ $positionOffset = $this->isDeprecatedCsrfPassedPositionally($attribute, $scope) ? 1 : 0;
+
+ if ($methodArg = $this->findArgument($attribute, 'method', 6 + $positionOffset)) {
+ foreach ($scope->getType($methodArg->value)->getConstantStrings() as $method) {
+ if (in_array(strtolower($method->getValue()), self::METHODS, true)) {
+ continue;
+ }
+
+ $errors[] = RuleErrorBuilder::message(
+ sprintf('The "method" parameter of the #[AsLiveComponent] attribute must be "get" or "post", got "%s".', $method->getValue())
+ )
+ ->identifier('symfonyUX.liveComponent.asLiveComponentMethodMustBeValid')
+ ->line($methodArg->getLine())
+ ->tip('Set the "method" parameter to "get" or "post".')
+ ->build();
+ }
+ }
+
+ if ($fetchCredentialsArg = $this->findArgument($attribute, 'fetchCredentials', 8 + $positionOffset)) {
+ foreach ($scope->getType($fetchCredentialsArg->value)->getConstantStrings() as $fetchCredentials) {
+ if (in_array($fetchCredentials->getValue(), self::FETCH_CREDENTIALS, true)) {
+ continue;
+ }
+
+ $errors[] = RuleErrorBuilder::message(
+ sprintf('The "fetchCredentials" parameter of the #[AsLiveComponent] attribute must be "same-origin", "include" or "omit", got "%s".', $fetchCredentials->getValue())
+ )
+ ->identifier('symfonyUX.liveComponent.asLiveComponentFetchCredentialsMustBeValid')
+ ->line($fetchCredentialsArg->getLine())
+ ->tip('Set the "fetchCredentials" parameter to "same-origin", "include" or "omit", or remove it to use the "live_component.fetch_credentials" configuration.')
+ ->build();
+ }
+ }
+
+ return $errors;
+ }
+
+ private function findArgument(Node\Attribute $attribute, string $name, int $position): ?Node\Arg
+ {
+ foreach ($attribute->args as $index => $arg) {
+ $isWantedArg = $arg->name === null
+ ? $index === $position
+ : $arg->name->toString() === $name;
+
+ if ($isWantedArg) {
+ return $arg;
+ }
+ }
+
+ return null;
+ }
+
+ // symfony/ux-live-component 2.x still accepts the deprecated "csrf" boolean as 6th argument, shifting the next ones
+ private function isDeprecatedCsrfPassedPositionally(Node\Attribute $attribute, Scope $scope): bool
+ {
+ $arg = $attribute->args[5] ?? null;
+
+ return $arg !== null && $arg->name === null && $scope->getType($arg->value)->isBoolean()->yes();
+ }
+}
diff --git a/tests/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule/AsLiveComponentArgumentsMustBeValidRuleTest.php b/tests/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule/AsLiveComponentArgumentsMustBeValidRuleTest.php
new file mode 100644
index 0000000..b4d96c9
--- /dev/null
+++ b/tests/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule/AsLiveComponentArgumentsMustBeValidRuleTest.php
@@ -0,0 +1,94 @@
+
+ */
+final class AsLiveComponentArgumentsMustBeValidRuleTest extends RuleTestCase
+{
+ public function testInvalidMethod(): void
+ {
+ $this->analyse(
+ [__DIR__ . '/Fixture/InvalidMethod.php'],
+ [
+ [
+ 'The "method" parameter of the #[AsLiveComponent] attribute must be "get" or "post", got "put".',
+ 9,
+ 'Set the "method" parameter to "get" or "post".',
+ ],
+ ]
+ );
+ }
+
+ public function testInvalidFetchCredentials(): void
+ {
+ $this->analyse(
+ [__DIR__ . '/Fixture/InvalidFetchCredentials.php'],
+ [
+ [
+ 'The "fetchCredentials" parameter of the #[AsLiveComponent] attribute must be "same-origin", "include" or "omit", got "same_origin".',
+ 9,
+ 'Set the "fetchCredentials" parameter to "same-origin", "include" or "omit", or remove it to use the "live_component.fetch_credentials" configuration.',
+ ],
+ ]
+ );
+ }
+
+ public function testInvalidPositionalArguments(): void
+ {
+ $this->analyse(
+ [__DIR__ . '/Fixture/InvalidPositionalArguments.php'],
+ [
+ [
+ 'The "method" parameter of the #[AsLiveComponent] attribute must be "get" or "post", got "PATCH".',
+ 9,
+ 'Set the "method" parameter to "get" or "post".',
+ ],
+ [
+ 'The "fetchCredentials" parameter of the #[AsLiveComponent] attribute must be "same-origin", "include" or "omit", got "all".',
+ 9,
+ 'Set the "fetchCredentials" parameter to "same-origin", "include" or "omit", or remove it to use the "live_component.fetch_credentials" configuration.',
+ ],
+ ]
+ );
+ }
+
+ public function testInvalidPositionalArgumentsWithDeprecatedCsrf(): void
+ {
+ $this->analyse(
+ [__DIR__ . '/Fixture/InvalidPositionalArgumentsWithDeprecatedCsrf.php'],
+ [
+ [
+ 'The "method" parameter of the #[AsLiveComponent] attribute must be "get" or "post", got "patch".',
+ 9,
+ 'Set the "method" parameter to "get" or "post".',
+ ],
+ ]
+ );
+ }
+
+ public function testNoViolations(): void
+ {
+ $this->analyse([__DIR__ . '/Fixture/NotAComponent.php'], []);
+ $this->analyse([__DIR__ . '/Fixture/ValidLiveComponent.php'], []);
+ $this->analyse([__DIR__ . '/Fixture/ValidPositionalArguments.php'], []);
+ $this->analyse([__DIR__ . '/Fixture/ValidPositionalArgumentsWithDeprecatedCsrf.php'], []);
+ }
+
+ public static function getAdditionalConfigFiles(): array
+ {
+ return [__DIR__ . '/config/configured_rule.neon'];
+ }
+
+ protected function getRule(): Rule
+ {
+ return self::getContainer()->getByType(AsLiveComponentArgumentsMustBeValidRule::class);
+ }
+}
diff --git a/tests/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule/Fixture/InvalidFetchCredentials.php b/tests/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule/Fixture/InvalidFetchCredentials.php
new file mode 100644
index 0000000..a3aec30
--- /dev/null
+++ b/tests/Rules/LiveComponent/AsLiveComponentArgumentsMustBeValidRule/Fixture/InvalidFetchCredentials.php
@@ -0,0 +1,12 @@
+