Skip to content

Commit 3b6d9f5

Browse files
committed
Updated Rector to commit 3be6fd7636ee24d82606f6166f94d8372fee800d
rectorphp/rector-src@3be6fd7 Clean up repetitive recursive call and flag on ArrayKeyFirstLastRector (#6889)
1 parent 85fffd8 commit 3b6d9f5

File tree

7 files changed

+31
-22
lines changed

7 files changed

+31
-22
lines changed

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,12 +1866,12 @@
18661866
"source": {
18671867
"type": "git",
18681868
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
1869-
"reference": "2867ceffdc0deb13e0a129ab3eb300ad304df96f"
1869+
"reference": "9cb58c14bf2ec834b72bcceaf0dc1de9d920bc05"
18701870
},
18711871
"dist": {
18721872
"type": "zip",
1873-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/2867ceffdc0deb13e0a129ab3eb300ad304df96f",
1874-
"reference": "2867ceffdc0deb13e0a129ab3eb300ad304df96f",
1873+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/9cb58c14bf2ec834b72bcceaf0dc1de9d920bc05",
1874+
"reference": "9cb58c14bf2ec834b72bcceaf0dc1de9d920bc05",
18751875
"shasum": ""
18761876
},
18771877
"require": {
@@ -1900,7 +1900,7 @@
19001900
"tomasvotruba\/unused-public": "^2.0",
19011901
"tracy\/tracy": "^2.10"
19021902
},
1903-
"time": "2025-05-09T07:59:03+00:00",
1903+
"time": "2025-05-09T12:54:05+00:00",
19041904
"default-branch": true,
19051905
"type": "rector-extension",
19061906
"extra": {

vendor/composer/installed.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
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 020b7c1'), '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 2b141c8'), '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 462d1a9'), '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 2867cef'));
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 020b7c1'), '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 2b141c8'), '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 462d1a9'), '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 9cb58c1'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-symfony/rules/Symfony73/GetMethodToAsTwigAttributeTransformer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PhpParser\Node\Stmt\ClassMethod;
1515
use PhpParser\Node\Stmt\Return_;
1616
use PHPStan\Reflection\ReflectionProvider;
17+
use PHPStan\Type\ObjectType;
1718
use Rector\Symfony\Symfony73\NodeAnalyzer\LocalArrayMethodCallableMatcher;
1819
use Rector\Symfony\Symfony73\NodeRemover\ReturnEmptyArrayMethodRemover;
1920
/**
@@ -39,7 +40,7 @@ public function __construct(LocalArrayMethodCallableMatcher $localArrayMethodCal
3940
$this->returnEmptyArrayMethodRemover = $returnEmptyArrayMethodRemover;
4041
$this->reflectionProvider = $reflectionProvider;
4142
}
42-
public function transformClassGetMethodToAttributeMarker(Class_ $class, string $methodName, string $attributeClass) : bool
43+
public function transformClassGetMethodToAttributeMarker(Class_ $class, string $methodName, string $attributeClass, ObjectType $objectType) : bool
4344
{
4445
// check if attribute even exists
4546
if (!$this->reflectionProvider->hasClass($attributeClass)) {
@@ -63,13 +64,16 @@ public function transformClassGetMethodToAttributeMarker(Class_ $class, string $
6364
if (!$arrayItem->value instanceof New_) {
6465
continue;
6566
}
67+
if ($arrayItem->value->isFirstClassCallable()) {
68+
continue;
69+
}
6670
$new = $arrayItem->value;
6771
if (\count($new->getArgs()) !== 2) {
6872
continue;
6973
}
7074
$secondArg = $new->getArgs()[1];
7175
if ($this->isLocalCallable($secondArg->value)) {
72-
$localMethodName = $this->localArrayMethodCallableMatcher->match($secondArg->value);
76+
$localMethodName = $this->localArrayMethodCallableMatcher->match($secondArg->value, $objectType);
7377
if (!\is_string($localMethodName)) {
7478
continue;
7579
}

vendor/rector/rector-symfony/rules/Symfony73/NodeAnalyzer/LocalArrayMethodCallableMatcher.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,33 @@
66
use PhpParser\Node\Expr;
77
use PhpParser\Node\Expr\Array_;
88
use PhpParser\Node\Expr\MethodCall;
9-
use PhpParser\Node\Expr\Variable;
109
use PhpParser\Node\Identifier;
1110
use PhpParser\Node\Scalar\String_;
11+
use PHPStan\Type\ObjectType;
12+
use Rector\NodeTypeResolver\NodeTypeResolver;
1213
final class LocalArrayMethodCallableMatcher
1314
{
14-
public function match(Expr $expr) : ?string
15+
/**
16+
* @readonly
17+
*/
18+
private NodeTypeResolver $nodeTypeResolver;
19+
public function __construct(NodeTypeResolver $nodeTypeResolver)
20+
{
21+
$this->nodeTypeResolver = $nodeTypeResolver;
22+
}
23+
public function match(Expr $expr, ObjectType $objectType) : ?string
1524
{
1625
if ($expr instanceof MethodCall) {
1726
if (!$expr->name instanceof Identifier) {
1827
return null;
1928
}
29+
if (!$this->nodeTypeResolver->isObjectType($expr->var, $objectType)) {
30+
return null;
31+
}
2032
return $expr->name->toString();
2133
}
2234
if ($expr instanceof Array_) {
23-
$firstItem = $expr->items[0];
24-
if (!$firstItem->value instanceof Variable) {
25-
return null;
26-
}
27-
$methodName = $firstItem->value->name;
28-
if (!\is_string($methodName)) {
29-
return null;
30-
}
31-
if ($methodName !== 'this') {
35+
if (!$this->nodeTypeResolver->isObjectType($expr->items[0]->value, $objectType)) {
3236
return null;
3337
}
3438
$secondItem = $expr->items[1];

vendor/rector/rector-symfony/rules/Symfony73/Rector/Class_/GetFiltersToAsTwigFilterAttributeRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function refactor(Node $node) : ?Class_
7777
if (!$this->isObjectType($node, $twigExtensionObjectType)) {
7878
return null;
7979
}
80-
$hasChanged = $this->getMethodToAsTwigAttributeTransformer->transformClassGetMethodToAttributeMarker($node, 'getFilters', TwigClass::AS_TWIG_FILTER_ATTRIBUTE);
80+
$hasChanged = $this->getMethodToAsTwigAttributeTransformer->transformClassGetMethodToAttributeMarker($node, 'getFilters', TwigClass::AS_TWIG_FILTER_ATTRIBUTE, $twigExtensionObjectType);
8181
if ($hasChanged) {
8282
return $node;
8383
}

vendor/rector/rector-symfony/rules/Symfony73/Rector/Class_/GetFunctionsToAsTwigFunctionAttributeRector.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ public function refactor(Node $node) : ?Class_
7373
if ($node->isAbstract() || $node->isAnonymous()) {
7474
return null;
7575
}
76-
if (!$this->isObjectType($node, new ObjectType(TwigClass::TWIG_EXTENSION))) {
76+
$twigExtensionObjectType = new ObjectType(TwigClass::TWIG_EXTENSION);
77+
if (!$this->isObjectType($node, $twigExtensionObjectType)) {
7778
return null;
7879
}
79-
$hasChanged = $this->getMethodToAsTwigAttributeTransformer->transformClassGetMethodToAttributeMarker($node, 'getFunctions', TwigClass::AS_TWIG_FUNCTION_ATTRIBUTE);
80+
$hasChanged = $this->getMethodToAsTwigAttributeTransformer->transformClassGetMethodToAttributeMarker($node, 'getFunctions', TwigClass::AS_TWIG_FUNCTION_ATTRIBUTE, $twigExtensionObjectType);
8081
if (!$hasChanged) {
8182
return null;
8283
}

0 commit comments

Comments
 (0)