Skip to content

[SYMFONY 4.4] replace Link argument values with constants #812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"symfony/security-core": "^6.4",
"symfony/security-http": "^6.4",
"symfony/validator": "^6.4",
"symfony/web-link": "^6.4",
"symplify/phpstan-rules": "^14.6",
"symplify/vendor-patches": "^11.3",
"tomasvotruba/class-leak": "^2.0",
Expand Down
110 changes: 110 additions & 0 deletions config/sets/symfony/symfony4/symfony44.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,121 @@

declare(strict_types=1);

use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue;
use Rector\Config\RectorConfig;

// https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.4.md

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'alternate',
'Symfony\Component\WebLink\Link::REL_ALTERNATE'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'author',
'Symfony\Component\WebLink\Link::REL_AUTHOR'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'help',
'Symfony\Component\WebLink\Link::REL_HELP'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'icon',
'Symfony\Component\WebLink\Link::REL_ICON'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'license',
'Symfony\Component\WebLink\Link::REL_LICENSE'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'search',
'Symfony\Component\WebLink\Link::REL_SEARCH'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'stylesheet',
'Symfony\Component\WebLink\Link::REL_STYLESHEET'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'next',
'Symfony\Component\WebLink\Link::REL_NEXT'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'prev',
'Symfony\Component\WebLink\Link::REL_PREV'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'preload',
'Symfony\Component\WebLink\Link::REL_PRELOAD'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'dns-prefetch',
'Symfony\Component\WebLink\Link::REL_DNS_PREFETCH'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'preconnect',
'Symfony\Component\WebLink\Link::REL_PRECONNECT'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'prefetch',
'Symfony\Component\WebLink\Link::REL_PREFETCH'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'prerender',
'Symfony\Component\WebLink\Link::REL_PRERENDER'
),
new ReplaceArgumentDefaultValue(
'Symfony\Component\WebLink\Link',
'__construct',
0,
'mercure',
'Symfony\Component\WebLink\Link::REL_MERCURE'
),
]);

$rectorConfig->import(__DIR__ . '/symfony44/symfony44-dependency-injection.php');
$rectorConfig->import(__DIR__ . '/symfony44/symfony44-console.php');
$rectorConfig->import(__DIR__ . '/symfony44/symfony44-http-kernel.php');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

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

use Symfony\Component\WebLink\Link;

class ReplaceNewLinkParameterValue
{
public function run()
{
return new Link('preload');
}
}

?>
-----
<?php

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

use Symfony\Component\WebLink\Link;

class ReplaceNewLinkParameterValue
{
public function run()
{
return new Link(\Symfony\Component\WebLink\Link::REL_PRELOAD);
}
}

?>
Loading