Skip to content

Commit

Permalink
Updated Rector to commit 436f0bc52f8fbd648b2fca69ecb5f7700aebdb99
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jul 1, 2024
1 parent 23b3490 commit 2203e98
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 24 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 = '1561c90c6b9ef040532a34afa1c2f581ad5dfbc1';
public const PACKAGE_VERSION = '436f0bc52f8fbd648b2fca69ecb5f7700aebdb99';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-07-01 10:15:34';
public const RELEASE_DATE = '2024-07-01 12:43:09';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ChangesReporting/Output/ConsoleOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ private function createSuccessMessage(ProcessResult $processResult, Configuratio
if ($changeCount === 0) {
return 'Rector is done!';
}
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');
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');
}
}
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1867,12 +1867,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "b785e83846b0baeb9c59170de1a9584898854055"
"reference": "cff0563bfb621f24e68e4ee1c871efe7a670b057"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/b785e83846b0baeb9c59170de1a9584898854055",
"reference": "b785e83846b0baeb9c59170de1a9584898854055",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/cff0563bfb621f24e68e4ee1c871efe7a670b057",
"reference": "cff0563bfb621f24e68e4ee1c871efe7a670b057",
"shasum": ""
},
"require": {
Expand Down Expand Up @@ -1901,7 +1901,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-06-30T21:02:53+00:00",
"time": "2024-07-01T09:19:56+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 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'));
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'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ final class CommandConfigureToAttributeRector extends AbstractRector implements
* @var \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory
*/
private $phpAttributeGroupFactory;
/**
* @readonly
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
*/
private $phpAttributeAnalyzer;
/**
* @readonly
* @var \PHPStan\Reflection\ReflectionProvider
Expand All @@ -49,10 +44,9 @@ final class CommandConfigureToAttributeRector extends AbstractRector implements
* @var array<string, string>
*/
private const METHODS_TO_ATTRIBUTE_NAMES = ['setName' => 'name', 'setDescription' => 'description', 'setAliases' => 'aliases', 'setHidden' => 'hidden'];
public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer, ReflectionProvider $reflectionProvider)
public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory, ReflectionProvider $reflectionProvider)
{
$this->phpAttributeGroupFactory = $phpAttributeGroupFactory;
$this->phpAttributeAnalyzer = $phpAttributeAnalyzer;
$this->reflectionProvider = $reflectionProvider;
}
public function provideMinPhpVersion() : int
Expand Down Expand Up @@ -103,30 +97,47 @@ public function refactor(Node $node) : ?Node
if (!$this->reflectionProvider->hasClass(SymfonyAnnotation::AS_COMMAND)) {
return null;
}
// already converted
if ($this->phpAttributeAnalyzer->hasPhpAttribute($node, SymfonyAnnotation::AS_COMMAND)) {
return null;
}
$configureClassMethod = $node->getMethod('configure');
if (!$configureClassMethod instanceof ClassMethod) {
return null;
}
$asCommandAttribute = $this->phpAttributeGroupFactory->createFromClass(SymfonyAnnotation::AS_COMMAND);
// handle existing attribute
$asCommandAttribute = null;
$attributeArgs = [];
foreach ($node->attrGroups as $attrGroup) {
foreach ($attrGroup->attrs as $attribute) {
if (!$this->nodeNameResolver->isName($attribute->name, SymfonyAnnotation::AS_COMMAND)) {
continue;
}
$asCommandAttribute = $attribute;
foreach ($asCommandAttribute->args as $arg) {
if ($arg->name === null) {
// when the existing attribute does not use named arguments, we cannot upgrade
return null;
}
$attributeArgs[$arg->name->toString()] = $arg;
}
break 2;
}
}
if ($asCommandAttribute === null) {
$asCommandAttributeGroup = $this->phpAttributeGroupFactory->createFromClass(SymfonyAnnotation::AS_COMMAND);
$asCommandAttribute = $asCommandAttributeGroup->attrs[0];
$node->attrGroups[] = $asCommandAttributeGroup;
}
foreach (self::METHODS_TO_ATTRIBUTE_NAMES as $methodName => $attributeName) {
$resolvedExpr = $this->findAndRemoveMethodExpr($configureClassMethod, $methodName);
if ($resolvedExpr instanceof Expr) {
$attributeArgs[] = $this->createNamedArg($attributeName, $resolvedExpr);
$attributeArgs[$attributeName] = $this->createNamedArg($attributeName, $resolvedExpr);
}
}
$asCommandAttribute->attrs[0]->args = $attributeArgs;
$asCommandAttribute->args = $attributeArgs;
// remove left overs
foreach ((array) $configureClassMethod->stmts as $key => $stmt) {
if ($this->isExpressionVariableThis($stmt)) {
unset($configureClassMethod->stmts[$key]);
}
}
$node->attrGroups[] = $asCommandAttribute;
return $node;
}
private function createNamedArg(string $name, Expr $expr) : Arg
Expand Down

0 comments on commit 2203e98

Please sign in to comment.