Skip to content

Commit

Permalink
Updated Rector to commit 6c86d9ac707d711ea6ffb521ff2c6223578b68f9
Browse files Browse the repository at this point in the history
rectorphp/rector-src@6c86d9a [DX] Add symfony configs set
  • Loading branch information
TomasVotruba committed Jun 22, 2024
1 parent 70f7201 commit 405b40b
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '4d9e287130a8a6576766c8e7159ddd2d658255e3';
public const PACKAGE_VERSION = '6c86d9ac707d711ea6ffb521ff2c6223578b68f9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-22 15:31:41';
public const RELEASE_DATE = '2024-06-23 00:43:23';
/**
* @var int
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ public function withPreparedSets(
bool $phpunitCodeQuality = \false,
bool $doctrineCodeQuality = \false,
bool $symfonyCodeQuality = \false,
bool $symfonyConfigs = \false,
// composer based
bool $twig = \false,
bool $phpunit = \false
Expand Down Expand Up @@ -545,6 +546,9 @@ public function withPreparedSets(
if ($symfonyCodeQuality) {
$this->sets[] = SymfonySetList::SYMFONY_CODE_QUALITY;
}
if ($symfonyConfigs) {
$this->sets[] = SymfonySetList::CONFIGS;
}
// @experimental 2024-06
if ($twig) {
$this->setGroups[] = SetGroup::TWIG;
Expand Down
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": "16671ca557c196268bc62689eb12d4033b96e44f"
"reference": "e2d72633eb1d69b5f5b30ea475797ffec60cc359"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/16671ca557c196268bc62689eb12d4033b96e44f",
"reference": "16671ca557c196268bc62689eb12d4033b96e44f",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/e2d72633eb1d69b5f5b30ea475797ffec60cc359",
"reference": "e2d72633eb1d69b5f5b30ea475797ffec60cc359",
"shasum": ""
},
"require": {
Expand Down Expand Up @@ -1904,7 +1904,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-06-22T14:35:51+00:00",
"time": "2024-06-22T15:42:57+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 16671ca'));
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 e2d7263'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector;
use Rector\Symfony\CodeQuality\Rector\MethodCall\AssertSameResponseCodeWithDebugContentsRector;
use Rector\Symfony\CodeQuality\Rector\MethodCall\LiteralGetToRequestClassConstantRector;
use Rector\Symfony\Symfony26\Rector\MethodCall\RedirectToRouteRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([
RedirectToRouteRector::class,
EventListenerToEventSubscriberRector::class,
ResponseReturnTypeControllerActionRector::class,
// int and string literals to const fetches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
use Rector\Symfony\Symfony40\Rector\ConstFetch\ConstraintUrlOptionRector;
use Rector\Symfony\Symfony40\Rector\MethodCall\ContainerBuilderCompileEnvArgumentRector;
use Rector\Symfony\Symfony40\Rector\MethodCall\FormIsValidRector;
use Rector\Symfony\Symfony40\Rector\MethodCall\ProcessBuilderGetProcessRector;
use Rector\Symfony\Symfony40\Rector\MethodCall\VarDumperTestTraitMethodArgsRector;
use Rector\Symfony\Symfony40\Rector\StaticCall\ProcessBuilderInstanceRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([ConstraintUrlOptionRector::class, FormIsValidRector::class, VarDumperTestTraitMethodArgsRector::class, ContainerBuilderCompileEnvArgumentRector::class, ProcessBuilderInstanceRector::class, ProcessBuilderGetProcessRector::class]);
$rectorConfig->rules([ConstraintUrlOptionRector::class, FormIsValidRector::class, VarDumperTestTraitMethodArgsRector::class, ContainerBuilderCompileEnvArgumentRector::class]);
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Symfony\\Component\\Validator\\Tests\\Constraints\\AbstractConstraintValidatorTest' => 'Symfony\\Component\\Validator\\Test\\ConstraintValidatorTestCase', 'Symfony\\Component\\Process\\ProcessBuilder' => 'Symfony\\Component\\Process\\Process']);
};
53 changes: 9 additions & 44 deletions vendor/rector/rector-symfony/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 85 Rules Overview
# 83 Rules Overview

## ActionSuffixRemoverRector

Expand Down Expand Up @@ -178,14 +178,12 @@ Replace `Symfony\Component\Routing\Annotation\Route` by `Symfony\Component\Routi
- class: [`Rector\Symfony\Symfony64\Rector\Class_\ChangeRouteAttributeFromAnnotationSubnamespaceRector`](../rules/Symfony64/Rector/Class_/ChangeRouteAttributeFromAnnotationSubnamespaceRector.php)

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

<br>
Expand Down Expand Up @@ -274,10 +272,7 @@ Add `Symfony\Component\Console\Attribute\AsCommand` to Symfony Commands and remo
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;

+#[AsCommand(
+ name: 'sunshine',
+ description: 'some description'
+)]
+#[AsCommand(name: 'sunshine', description: 'some description')]
final class SunshineCommand extends Command
{
- public static $defaultName = 'sunshine';
Expand Down Expand Up @@ -462,14 +457,13 @@ Downgrade Symfony Command Attribute
```diff
#[AsCommand(name: 'app:create-user', description: 'some description')]
class CreateUserCommand extends Command
-{}
+{
{
+ protected function configure(): void
+ {
+ $this->setName('app:create-user');
+ $this->setDescription('some description');
+ }
+}
}
```

<br>
Expand Down Expand Up @@ -1134,35 +1128,6 @@ Replaces deprecated `Yaml::parse()` of file argument with file contents

<br>

## ProcessBuilderGetProcessRector

Removes `$processBuilder->getProcess()` calls to `$processBuilder` in Process in Symfony, because ProcessBuilder was removed. This is part of multi-step Rector and has very narrow focus.

- class: [`Rector\Symfony\Symfony40\Rector\MethodCall\ProcessBuilderGetProcessRector`](../rules/Symfony40/Rector/MethodCall/ProcessBuilderGetProcessRector.php)

```diff
$processBuilder = new Symfony\Component\Process\ProcessBuilder;
-$process = $processBuilder->getProcess();
-$commamdLine = $processBuilder->getProcess()->getCommandLine();
+$process = $processBuilder;
+$commamdLine = $processBuilder->getCommandLine();
```

<br>

## ProcessBuilderInstanceRector

Turns `ProcessBuilder::instance()` to new ProcessBuilder in Process in Symfony. Part of multi-step Rector.

- class: [`Rector\Symfony\Symfony40\Rector\StaticCall\ProcessBuilderInstanceRector`](../rules/Symfony40/Rector/StaticCall/ProcessBuilderInstanceRector.php)

```diff
-$processBuilder = Symfony\Component\Process\ProcessBuilder::instance($args);
+$processBuilder = new Symfony\Component\Process\ProcessBuilder($args);
```

<br>

## PropertyAccessorCreationBooleanToFlagsRector

Changes first argument of `PropertyAccessor::__construct()` to flags from boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function getRuleDefinition() : RuleDefinition
return new RuleDefinition('Downgrade Symfony Command Attribute', [new CodeSample(<<<'CODE_SAMPLE'
#[AsCommand(name: 'app:create-user', description: 'some description')]
class CreateUserCommand extends Command
{}
{
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
#[AsCommand(name: 'app:create-user', description: 'some description')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@

use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Type\ObjectType;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Symfony\Tests\Symfony40\Rector\MethodCall\ProcessBuilderGetProcessRector\ProcessBuilderGetProcessRectorTest
* @deprecated This rule is deprecated since Rector 1.1.2, as it can create invalid code.
* This needs a manual change
*
* @see https://github.com/pact-foundation/pact-php/pull/61/files.
*/
final class ProcessBuilderGetProcessRector extends AbstractRector
{
/**
* @var bool
*/
private $hasWarned = \false;
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Removes `$processBuilder->getProcess()` calls to $processBuilder in Process in Symfony, because ProcessBuilder was removed. This is part of multi-step Rector and has very narrow focus.', [new CodeSample(<<<'CODE_SAMPLE'
Expand All @@ -40,12 +46,12 @@ public function getNodeTypes() : array
*/
public function refactor(Node $node) : ?Node
{
if (!$this->isName($node->name, 'getProcess')) {
return null;
}
if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Process\\ProcessBuilder'))) {
if ($this->hasWarned) {
return null;
}
return $node->var;
\trigger_error(\sprintf('The "%s" rule was deprecated, as it cannot change fluent code builder in a reliable way.', self::class));
\sleep(3);
$this->hasWarned = \true;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
namespace Rector\Symfony\Symfony40\Rector\StaticCall;

use PhpParser\Node;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Symfony\Tests\Symfony40\Rector\StaticCall\ProcessBuilderInstanceRector\ProcessBuilderInstanceRectorTest
* @deprecated This rule is deprecated since Rector 1.1.2, as it can create invalid code.
* This needs a manual change
*
* @see https://github.com/pact-foundation/pact-php/pull/61/files.
*/
final class ProcessBuilderInstanceRector extends AbstractRector
{
/**
* @var bool
*/
private $hasWarned = \false;
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Turns `ProcessBuilder::instance()` to new ProcessBuilder in Process in Symfony. Part of multi-step Rector.', [new CodeSample('$processBuilder = Symfony\\Component\\Process\\ProcessBuilder::instance($args);', '$processBuilder = new Symfony\\Component\\Process\\ProcessBuilder($args);')]);
Expand All @@ -31,15 +36,12 @@ public function getNodeTypes() : array
*/
public function refactor(Node $node) : ?Node
{
if (!$node->class instanceof Name) {
return null;
}
if (!$this->isName($node->class, 'Symfony\\Component\\Process\\ProcessBuilder')) {
return null;
}
if (!$this->isName($node->name, 'create')) {
if ($this->hasWarned) {
return null;
}
return new New_($node->class, $node->args);
\trigger_error(\sprintf('The "%s" rule was deprecated, as it cannot change fluent code builder in a reliable way.', self::class));
\sleep(3);
$this->hasWarned = \true;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ final class SunshineCommand extends Command
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
#[AsCommand(
name: 'sunshine',
description: 'some description'
)]
#[AsCommand(name: 'sunshine', description: 'some description')]
final class SunshineCommand extends Command
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@ final class ChangeRouteAttributeFromAnnotationSubnamespaceRector extends Abstrac
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'
/**
* #[\Symfony\Component\Routing\Annotation\Route("/foo")]
*/
public function create(Request $request): Response
{
return new Response();
}
#[\Symfony\Component\Routing\Annotation\Route("/foo")]
public function create(Request $request): Response
{
return new Response();
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
#[\Symfony\Component\Routing\Attribute\Route('/foo')]
public function create(Request $request): Response
{
return new Response();
}
#[\Symfony\Component\Routing\Attribute\Route('/foo')]
public function create(Request $request): Response
{
return new Response();
}
CODE_SAMPLE
)]);
}
Expand All @@ -47,14 +45,18 @@ 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);
return $node;
$hasChanged = \true;
}
}
}
if ($hasChanged) {
return $node;
}
return null;
}
private function isSymfonyRouteAttribute(Attribute $attribute) : bool
Expand Down

0 comments on commit 405b40b

Please sign in to comment.