Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/sets/symfony/symfony5/symfony51.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'
),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Rector\Symfony\Tests\Set\Symfony51\Fixture;

use Symfony\Component\HttpFoundation\Cookie;

class ReplaceCookieWithSameSiteParameterValue
{
public function run()
{
$cookie = Cookie::create('name');
$cookie->withSameSite('none');

return $cookie;
}
}

?>

-----
<?php

namespace Rector\Symfony\Tests\Set\Symfony51\Fixture;

use Symfony\Component\HttpFoundation\Cookie;

class ReplaceCookieWithSameSiteParameterValue
{
public function run()
{
$cookie = Cookie::create('name');
$cookie->withSameSite(\Symfony\Component\HttpFoundation\Cookie::SAMESITE_NONE);

return $cookie;
}
}

?>
28 changes: 28 additions & 0 deletions tests/Set/Symfony51/Symfony51Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\Set\Symfony51;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class Symfony51Test extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/symfony51.php';
}
}
10 changes: 10 additions & 0 deletions tests/Set/Symfony51/config/symfony51.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([SymfonySetList::SYMFONY_51]);
};