Skip to content

Commit

Permalink
Updated Rector to commit fa25356b127eb08d83ad24e399eafbaf70d62d96
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 22, 2024
1 parent 881f945 commit 0673f04
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 49 deletions.
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1869,12 +1869,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "b1f6212c6c49f90f29d26e83dae2471451887a06"
"reference": "4c17cfda8deff946d4014babfb5bdba0bce06325"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/b1f6212c6c49f90f29d26e83dae2471451887a06",
"reference": "b1f6212c6c49f90f29d26e83dae2471451887a06",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/4c17cfda8deff946d4014babfb5bdba0bce06325",
"reference": "4c17cfda8deff946d4014babfb5bdba0bce06325",
"shasum": ""
},
"require": {
Expand Down Expand Up @@ -1904,7 +1904,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-06-22T16:46:47+00:00",
"time": "2024-06-22T17:47:40+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/rector/extension-installer/src/GeneratedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main c3c91df'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main a16ded4'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 8e85127'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b1f6212'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main c3c91df'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main a16ded4'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 8e85127'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 4c17cfd'));
private function __construct()
{
}
Expand Down
11 changes: 9 additions & 2 deletions vendor/rector/rector-symfony/config/sets/symfony/symfony64.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
declare (strict_types=1);
namespace RectorPrefix202406;

use PHPStan\Type\ObjectWithoutClassType;
use PHPStan\Type\StringType;
use PHPStan\Type\UnionType;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Class_\RenameAttributeRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Symfony\Symfony64\Rector\Class_\ChangeRouteAttributeFromAnnotationSubnamespaceRector;
use Rector\Renaming\ValueObject\RenameAttribute;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
// @see https://github.com/symfony/symfony/blob/6.4/UPGRADE-6.4.md
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Symfony\\Component\\HttpKernel\\UriSigner' => 'Symfony\\Component\\HttpFoundation\\UriSigner', 'Symfony\\Component\\HttpKernel\\Debug\\FileLinkFormatter' => 'Symfony\\Component\\ErrorHandler\\ErrorRenderer\\FileLinkFormatter']);
$rectorConfig->rule(ChangeRouteAttributeFromAnnotationSubnamespaceRector::class);
$rectorConfig->ruleWithConfiguration(RenameAttributeRector::class, [new RenameAttribute('Symfony\\Component\\Routing\\Annotation\\Route', 'Symfony\\Component\\Routing\\Attribute\\Route')]);
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Symfony\\Component\\Form\\DataTransformerInterface', 'transform', new UnionType([new StringType(), new \PHPStan\Type\NullType()])), new AddReturnTypeDeclaration('Symfony\\Component\\Form\\DataTransformerInterface', 'reverseTransform', new UnionType([new StringType(), new ObjectWithoutClassType()]))]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
namespace RectorPrefix202406;

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Class_\RenameAttributeRector;
use Rector\Renaming\ValueObject\RenameAttribute;
// @see https://github.com/symfony/symfony/blob/7.0/UPGRADE-7.0.md
return static function (RectorConfig $rectorConfig) : void {
// @todo next
// @see https://github.com/symfony/symfony/blob/7.0/UPGRADE-7.0.md#dependencyinjection
$rectorConfig->ruleWithConfiguration(RenameAttributeRector::class, [new RenameAttribute('Symfony\\Component\\DependencyInjection\\Attribute\\MapDecorated', 'Symfony\\Component\\DependencyInjection\\Attribute\\AutowireDecorated')]);
};
13 changes: 13 additions & 0 deletions vendor/rector/rector-symfony/config/sets/symfony/symfony71.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare (strict_types=1);
namespace RectorPrefix202406;

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Class_\RenameAttributeRector;
use Rector\Renaming\ValueObject\RenameAttribute;
// @see https://github.com/symfony/symfony/blob/7.1/UPGRADE-7.1.md
return static function (RectorConfig $rectorConfig) : void {
// @see https://github.com/symfony/symfony/blob/7.1/UPGRADE-7.1.md#dependencyinjection
$rectorConfig->ruleWithConfiguration(RenameAttributeRector::class, [new RenameAttribute('Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator', 'Symfony\\Component\\DependencyInjection\\Attribute\\AutowireIterator'), new RenameAttribute('Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator', 'Symfony\\Component\\DependencyInjection\\Attribute\\AutowireLocator')]);
};
40 changes: 23 additions & 17 deletions vendor/rector/rector-symfony/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,6 @@ Rename `type` option to `entry_type` in CollectionType

<br>

## ChangeRouteAttributeFromAnnotationSubnamespaceRector

Replace `Symfony\Component\Routing\Annotation\Route` by `Symfony\Component\Routing\Attribute\Route` when the class use #Route[] attribute

- class: [`Rector\Symfony\Symfony64\Rector\Class_\ChangeRouteAttributeFromAnnotationSubnamespaceRector`](../rules/Symfony64/Rector/Class_/ChangeRouteAttributeFromAnnotationSubnamespaceRector.php)

```diff
-#[\Symfony\Component\Routing\Annotation\Route("/foo")]
+#[\Symfony\Component\Routing\Attribute\Route('/foo')]
public function create(Request $request): Response
{
return new Response();
}
```

<br>

## ChangeStringCollectionOptionToConstantRector

Change type in CollectionType from alias string to class reference
Expand Down Expand Up @@ -1425,6 +1408,29 @@ Change RouteCollectionBuilder to RoutingConfiguratorRector

<br>

## SecurityAttributeToIsGrantedAttributeRector

Replaces #[Security] framework-bundle attribute with Symfony native #[IsGranted] one

- class: [`Rector\Symfony\Symfony62\Rector\Class_\SecurityAttributeToIsGrantedAttributeRector`](../rules/Symfony62/Rector/Class_/SecurityAttributeToIsGrantedAttributeRector.php)

```diff
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
+use Symfony\Component\ExpressionLanguage\Expression;
+use Symfony\Component\Security\Http\Attribute\IsGranted;

class PostController extends Controller
{
- #[Security("is_granted('ROLE_ADMIN') and is_granted('ROLE_FRIENDLY_USER')")]
+ #[IsGranted(new Expression("is_granted('ROLE_ADMIN') and is_granted('ROLE_FRIENDLY_USER')"))]
public function index()
{
}
}
```

<br>

## ServiceArgsToServiceNamedArgRector

Converts order-dependent arguments `args()` to named `arg()` call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
namespace Rector\Symfony\Symfony64\Rector\Class_;

use PhpParser\Node;
use PhpParser\Node\Attribute;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Symfony\Tests\Symfony64\Rector\Class_\ChangeRouteAttributeFromAnnotationSubnamespaceRector
* @deprecated This rule is deprecated since Rector 1.1.2. Use @see RenameAttributeRector rule instead.
*/
final class ChangeRouteAttributeFromAnnotationSubnamespaceRector extends AbstractRector
{
private const ANNOTATION_ROUTE = 'Symfony\\Component\\Routing\\Annotation\\Route';
private const ATTRIBUTE_ROUTE = 'Symfony\\Component\\Routing\\Attribute\\Route';
/**
* @var bool
*/
private $hasWarned = \false;
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Replace Symfony\\Component\\Routing\\Annotation\\Route by Symfony\\Component\\Routing\\Attribute\\Route when the class use #Route[] attribute', [new CodeSample(<<<'CODE_SAMPLE'
Expand Down Expand Up @@ -45,25 +45,12 @@ public function getNodeTypes() : array
*/
public function refactor(Node $node) : ?Node
{
$hasChanged = \false;
foreach ($node->attrGroups as $attributeGroup) {
foreach ($attributeGroup->attrs as $attribute) {
if ($this->isSymfonyRouteAttribute($attribute)) {
$attribute->name = new FullyQualified(self::ATTRIBUTE_ROUTE);
$hasChanged = \true;
}
}
}
if ($hasChanged) {
return $node;
if ($this->hasWarned) {
return null;
}
\trigger_error(\sprintf('The "%s" rule was deprecated. Use RenameAttributeRector rule instead', self::class));
\sleep(3);
$this->hasWarned = \true;
return null;
}
private function isSymfonyRouteAttribute(Attribute $attribute) : bool
{
if ($attribute->name === null) {
return \false;
}
return (string) $attribute->name === self::ANNOTATION_ROUTE;
}
}
4 changes: 4 additions & 0 deletions vendor/rector/rector-symfony/src/Set/SymfonySetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ final class SymfonySetList implements SetListInterface
* @var string
*/
public const SYMFONY_64 = __DIR__ . '/../../config/sets/symfony/symfony64.php';
/**
* @var string
*/
public const SYMFONY_71 = __DIR__ . '/../../config/sets/symfony/symfony71.php';
/**
* @var string
*/
Expand Down

0 comments on commit 0673f04

Please sign in to comment.