diff --git a/config/sets/symfony/symfony5/symfony51.php b/config/sets/symfony/symfony5/symfony51.php index a85f399f..327d036a 100644 --- a/config/sets/symfony/symfony5/symfony51.php +++ b/config/sets/symfony/symfony5/symfony51.php @@ -16,5 +16,4 @@ $rectorConfig->import(__DIR__ . '/symfony51/symfony51-inflector.php'); $rectorConfig->import(__DIR__ . '/symfony51/symfony51-notifier.php'); $rectorConfig->import(__DIR__ . '/symfony51/symfony51-security-http.php'); - }; diff --git a/config/sets/symfony/symfony5/symfony51/symfony51-http-foundation.php b/config/sets/symfony/symfony5/symfony51/symfony51-http-foundation.php index b173120a..37a651e1 100644 --- a/config/sets/symfony/symfony5/symfony51/symfony51-http-foundation.php +++ b/config/sets/symfony/symfony5/symfony51/symfony51-http-foundation.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector; +use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue; use Rector\Config\RectorConfig; use Rector\Transform\Rector\StaticCall\StaticCallToNewRector; use Rector\Transform\ValueObject\StaticCallToNew; @@ -13,4 +15,27 @@ new StaticCallToNew('Symfony\Component\HttpFoundation\RedirectResponse', 'create'), new StaticCallToNew('Symfony\Component\HttpFoundation\StreamedResponse', 'create'), ]); + $rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [ + new ReplaceArgumentDefaultValue( + 'Symfony\Component\HttpFoundation\Cookie', + 'withSameSite', + 0, + 'none', + 'Symfony\Component\HttpFoundation\Cookie::SAMESITE_NONE' + ), + new ReplaceArgumentDefaultValue( + 'Symfony\Component\HttpFoundation\Cookie', + 'withSameSite', + 0, + 'lax', + 'Symfony\Component\HttpFoundation\Cookie::SAMESITE_LAX' + ), + new ReplaceArgumentDefaultValue( + 'Symfony\Component\HttpFoundation\Cookie', + 'withSameSite', + 0, + 'strict', + 'Symfony\Component\HttpFoundation\Cookie::SAMESITE_STRICT' + ), + ]); }; diff --git a/tests/Set/Symfony51/Fixture/replace_cookie_with_same_site_parameter_value.php.inc b/tests/Set/Symfony51/Fixture/replace_cookie_with_same_site_parameter_value.php.inc new file mode 100644 index 00000000..17ced89b --- /dev/null +++ b/tests/Set/Symfony51/Fixture/replace_cookie_with_same_site_parameter_value.php.inc @@ -0,0 +1,38 @@ +withSameSite('none'); + + return $cookie; + } +} + +?> + +----- +withSameSite(\Symfony\Component\HttpFoundation\Cookie::SAMESITE_NONE); + + return $cookie; + } +} + +?> diff --git a/tests/Set/Symfony51/Symfony51Test.php b/tests/Set/Symfony51/Symfony51Test.php new file mode 100644 index 00000000..50dc16df --- /dev/null +++ b/tests/Set/Symfony51/Symfony51Test.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/symfony51.php'; + } +} diff --git a/tests/Set/Symfony51/config/symfony51.php b/tests/Set/Symfony51/config/symfony51.php new file mode 100644 index 00000000..8aaa831f --- /dev/null +++ b/tests/Set/Symfony51/config/symfony51.php @@ -0,0 +1,10 @@ +sets([SymfonySetList::SYMFONY_51]); +};