Skip to content

Commit 2203e98

Browse files
committed
Updated Rector to commit 436f0bc52f8fbd648b2fca69ecb5f7700aebdb99
rectorphp/rector-src@436f0bc Grammar fix (#6097)
1 parent 23b3490 commit 2203e98

File tree

6 files changed

+35
-24
lines changed

6 files changed

+35
-24
lines changed

src/Application/VersionResolver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '1561c90c6b9ef040532a34afa1c2f581ad5dfbc1';
22+
public const PACKAGE_VERSION = '436f0bc52f8fbd648b2fca69ecb5f7700aebdb99';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2024-07-01 10:15:34';
27+
public const RELEASE_DATE = '2024-07-01 12:43:09';
2828
/**
2929
* @var int
3030
*/

src/ChangesReporting/Output/ConsoleOutputFormatter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ private function createSuccessMessage(ProcessResult $processResult, Configuratio
108108
if ($changeCount === 0) {
109109
return 'Rector is done!';
110110
}
111-
return \sprintf('%d file%s %s by Rector', $changeCount, $changeCount > 1 ? 's' : '', $configuration->isDryRun() ? 'would have changed (dry-run)' : ($changeCount === 1 ? 'has' : 'have') . ' been changed');
111+
return \sprintf('%d file%s %s by Rector', $changeCount, $changeCount > 1 ? 's' : '', $configuration->isDryRun() ? 'would have been changed (dry-run)' : ($changeCount === 1 ? 'has' : 'have') . ' been changed');
112112
}
113113
}

vendor/composer/installed.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1867,12 +1867,12 @@
18671867
"source": {
18681868
"type": "git",
18691869
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
1870-
"reference": "b785e83846b0baeb9c59170de1a9584898854055"
1870+
"reference": "cff0563bfb621f24e68e4ee1c871efe7a670b057"
18711871
},
18721872
"dist": {
18731873
"type": "zip",
1874-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/b785e83846b0baeb9c59170de1a9584898854055",
1875-
"reference": "b785e83846b0baeb9c59170de1a9584898854055",
1874+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/cff0563bfb621f24e68e4ee1c871efe7a670b057",
1875+
"reference": "cff0563bfb621f24e68e4ee1c871efe7a670b057",
18761876
"shasum": ""
18771877
},
18781878
"require": {
@@ -1901,7 +1901,7 @@
19011901
"tomasvotruba\/class-leak": "^0.2",
19021902
"tracy\/tracy": "^2.10"
19031903
},
1904-
"time": "2024-06-30T21:02:53+00:00",
1904+
"time": "2024-07-01T09:19:56+00:00",
19051905
"default-branch": true,
19061906
"type": "rector-extension",
19071907
"extra": {

vendor/composer/installed.php

+1-1
Large diffs are not rendered by default.

vendor/rector/extension-installer/src/GeneratedConfig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class GeneratedConfig
1111
{
12-
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 8c5d6ee'), '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 c053b97'), '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 887a20a'), '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 b785e83'));
12+
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 8c5d6ee'), '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 c053b97'), '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 887a20a'), '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 cff0563'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-symfony/rules/Symfony61/Rector/Class_/CommandConfigureToAttributeRector.php

+26-15
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ final class CommandConfigureToAttributeRector extends AbstractRector implements
3535
* @var \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory
3636
*/
3737
private $phpAttributeGroupFactory;
38-
/**
39-
* @readonly
40-
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
41-
*/
42-
private $phpAttributeAnalyzer;
4338
/**
4439
* @readonly
4540
* @var \PHPStan\Reflection\ReflectionProvider
@@ -49,10 +44,9 @@ final class CommandConfigureToAttributeRector extends AbstractRector implements
4944
* @var array<string, string>
5045
*/
5146
private const METHODS_TO_ATTRIBUTE_NAMES = ['setName' => 'name', 'setDescription' => 'description', 'setAliases' => 'aliases', 'setHidden' => 'hidden'];
52-
public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer, ReflectionProvider $reflectionProvider)
47+
public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory, ReflectionProvider $reflectionProvider)
5348
{
5449
$this->phpAttributeGroupFactory = $phpAttributeGroupFactory;
55-
$this->phpAttributeAnalyzer = $phpAttributeAnalyzer;
5650
$this->reflectionProvider = $reflectionProvider;
5751
}
5852
public function provideMinPhpVersion() : int
@@ -103,30 +97,47 @@ public function refactor(Node $node) : ?Node
10397
if (!$this->reflectionProvider->hasClass(SymfonyAnnotation::AS_COMMAND)) {
10498
return null;
10599
}
106-
// already converted
107-
if ($this->phpAttributeAnalyzer->hasPhpAttribute($node, SymfonyAnnotation::AS_COMMAND)) {
108-
return null;
109-
}
110100
$configureClassMethod = $node->getMethod('configure');
111101
if (!$configureClassMethod instanceof ClassMethod) {
112102
return null;
113103
}
114-
$asCommandAttribute = $this->phpAttributeGroupFactory->createFromClass(SymfonyAnnotation::AS_COMMAND);
104+
// handle existing attribute
105+
$asCommandAttribute = null;
115106
$attributeArgs = [];
107+
foreach ($node->attrGroups as $attrGroup) {
108+
foreach ($attrGroup->attrs as $attribute) {
109+
if (!$this->nodeNameResolver->isName($attribute->name, SymfonyAnnotation::AS_COMMAND)) {
110+
continue;
111+
}
112+
$asCommandAttribute = $attribute;
113+
foreach ($asCommandAttribute->args as $arg) {
114+
if ($arg->name === null) {
115+
// when the existing attribute does not use named arguments, we cannot upgrade
116+
return null;
117+
}
118+
$attributeArgs[$arg->name->toString()] = $arg;
119+
}
120+
break 2;
121+
}
122+
}
123+
if ($asCommandAttribute === null) {
124+
$asCommandAttributeGroup = $this->phpAttributeGroupFactory->createFromClass(SymfonyAnnotation::AS_COMMAND);
125+
$asCommandAttribute = $asCommandAttributeGroup->attrs[0];
126+
$node->attrGroups[] = $asCommandAttributeGroup;
127+
}
116128
foreach (self::METHODS_TO_ATTRIBUTE_NAMES as $methodName => $attributeName) {
117129
$resolvedExpr = $this->findAndRemoveMethodExpr($configureClassMethod, $methodName);
118130
if ($resolvedExpr instanceof Expr) {
119-
$attributeArgs[] = $this->createNamedArg($attributeName, $resolvedExpr);
131+
$attributeArgs[$attributeName] = $this->createNamedArg($attributeName, $resolvedExpr);
120132
}
121133
}
122-
$asCommandAttribute->attrs[0]->args = $attributeArgs;
134+
$asCommandAttribute->args = $attributeArgs;
123135
// remove left overs
124136
foreach ((array) $configureClassMethod->stmts as $key => $stmt) {
125137
if ($this->isExpressionVariableThis($stmt)) {
126138
unset($configureClassMethod->stmts[$key]);
127139
}
128140
}
129-
$node->attrGroups[] = $asCommandAttribute;
130141
return $node;
131142
}
132143
private function createNamedArg(string $name, Expr $expr) : Arg

0 commit comments

Comments
 (0)