Skip to content

Commit 9696ef6

Browse files
committed
Updated Rector to commit a6732a5b0e80868a6542c9bd5443f27750577e64
rectorphp/rector-src@a6732a5 [FamilyTree] Remove AstResolver on FamilyRelationsAnalyzer (#5117)
1 parent a40e240 commit 9696ef6

8 files changed

Lines changed: 28 additions & 32 deletions

File tree

packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpParser\Node\Stmt\Interface_;
99
use PHPStan\Reflection\ClassReflection;
1010
use PHPStan\Reflection\ReflectionProvider;
11-
use Rector\Core\PhpParser\AstResolver;
1211
use Rector\Core\Util\Reflection\PrivatesAccessor;
1312
use Rector\NodeNameResolver\NodeNameResolver;
1413
final class FamilyRelationsAnalyzer
@@ -28,17 +27,11 @@ final class FamilyRelationsAnalyzer
2827
* @var \Rector\NodeNameResolver\NodeNameResolver
2928
*/
3029
private $nodeNameResolver;
31-
/**
32-
* @readonly
33-
* @var \Rector\Core\PhpParser\AstResolver
34-
*/
35-
private $astResolver;
36-
public function __construct(ReflectionProvider $reflectionProvider, PrivatesAccessor $privatesAccessor, NodeNameResolver $nodeNameResolver, AstResolver $astResolver)
30+
public function __construct(ReflectionProvider $reflectionProvider, PrivatesAccessor $privatesAccessor, NodeNameResolver $nodeNameResolver)
3731
{
3832
$this->reflectionProvider = $reflectionProvider;
3933
$this->privatesAccessor = $privatesAccessor;
4034
$this->nodeNameResolver = $nodeNameResolver;
41-
$this->astResolver = $astResolver;
4235
}
4336
/**
4437
* @return ClassReflection[]
@@ -69,22 +62,24 @@ public function getClassLikeAncestorNames($classOrName) : array
6962
$ancestorNames = [];
7063
if ($classOrName instanceof Name) {
7164
$fullName = $this->nodeNameResolver->getName($classOrName);
72-
$classLike = $this->astResolver->resolveClassFromName($fullName);
73-
} else {
74-
$classLike = $classOrName;
65+
$classReflection = $this->reflectionProvider->getClass($fullName);
66+
$ancestors = \array_merge($classReflection->getParents(), $classReflection->getInterfaces());
67+
return \array_map(static function (ClassReflection $classReflection) : string {
68+
return $classReflection->getName();
69+
}, $ancestors);
7570
}
76-
if ($classLike instanceof Interface_) {
77-
foreach ($classLike->extends as $extendInterfaceName) {
71+
if ($classOrName instanceof Interface_) {
72+
foreach ($classOrName->extends as $extendInterfaceName) {
7873
$ancestorNames[] = $this->nodeNameResolver->getName($extendInterfaceName);
7974
$ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($extendInterfaceName));
8075
}
8176
}
82-
if ($classLike instanceof Class_) {
83-
if ($classLike->extends instanceof Name) {
84-
$ancestorNames[] = $this->nodeNameResolver->getName($classLike->extends);
85-
$ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($classLike->extends));
77+
if ($classOrName instanceof Class_) {
78+
if ($classOrName->extends instanceof Name) {
79+
$ancestorNames[] = $this->nodeNameResolver->getName($classOrName->extends);
80+
$ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($classOrName->extends));
8681
}
87-
foreach ($classLike->implements as $implement) {
82+
foreach ($classOrName->implements as $implement) {
8883
$ancestorNames[] = $this->nodeNameResolver->getName($implement);
8984
$ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($implement));
9085
}

rules/Php80/Rector/Class_/StringableForToStringRector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ public function refactor(Node $node) : ?Node
108108
// warning, classes that implements __toString() will return Stringable interface even if they don't implemen it
109109
// reflection cannot be used for real detection
110110
$classLikeAncestorNames = $this->familyRelationsAnalyzer->getClassLikeAncestorNames($node);
111-
if (\in_array(self::STRINGABLE, $classLikeAncestorNames, \true)) {
112-
return null;
113-
}
111+
$isAncestorHasStringable = \in_array(self::STRINGABLE, $classLikeAncestorNames, \true);
114112
$returnType = $this->returnTypeInferer->inferFunctionLike($toStringClassMethod);
115113
if (!$returnType->isString()->yes()) {
116114
$this->processNotStringType($toStringClassMethod);
117115
}
118-
// add interface
119-
$node->implements[] = new FullyQualified(self::STRINGABLE);
116+
if (!$isAncestorHasStringable) {
117+
// add interface
118+
$node->implements[] = new FullyQualified(self::STRINGABLE);
119+
}
120120
// add return type
121121
if ($toStringClassMethod->returnType === null) {
122122
$toStringClassMethod->returnType = new Identifier('string');

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
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 = 'a0f2f32c7970d925681fc4cec64efa1ee90b6ea8';
22+
public const PACKAGE_VERSION = 'a6732a5b0e80868a6542c9bd5443f27750577e64';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2023-10-05 12:35:58';
27+
public const RELEASE_DATE = '2023-10-05 14:30:52';
2828
/**
2929
* @var int
3030
*/

src/PhpParser/AstResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function __construct(SmartPhpParser $smartPhpParser, NodeScopeAndMetadata
9999
$this->methodReflectionResolver = $methodReflectionResolver;
100100
}
101101
/**
102+
* @api downgrade
102103
* @return \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Enum_|null
103104
*/
104105
public function resolveClassFromName(string $className)

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,12 +1879,12 @@
18791879
"source": {
18801880
"type": "git",
18811881
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
1882-
"reference": "24ea3ecd82cfab1d040bed6c0cd7a0cf69a11a85"
1882+
"reference": "873458ca73a73f9becd1680963a347bbcb8e5f43"
18831883
},
18841884
"dist": {
18851885
"type": "zip",
1886-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/24ea3ecd82cfab1d040bed6c0cd7a0cf69a11a85",
1887-
"reference": "24ea3ecd82cfab1d040bed6c0cd7a0cf69a11a85",
1886+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/873458ca73a73f9becd1680963a347bbcb8e5f43",
1887+
"reference": "873458ca73a73f9becd1680963a347bbcb8e5f43",
18881888
"shasum": ""
18891889
},
18901890
"require": {
@@ -1917,7 +1917,7 @@
19171917
"tomasvotruba\/unused-public": "^0.2",
19181918
"tracy\/tracy": "^2.10"
19191919
},
1920-
"time": "2023-10-01T11:40:39+00:00",
1920+
"time": "2023-10-05T05:47:32+00:00",
19211921
"default-branch": true,
19221922
"type": "rector-extension",
19231923
"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 a846e7f'), '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 850b492'), '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 383d079'), '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 24ea3ec'));
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 a846e7f'), '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 850b492'), '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 383d079'), '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 873458c'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-symfony/rules/Symfony42/Rector/MethodCall/ContainerGetToConstructorInjectionRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private function decorateCommandConstructor(Class_ $class) : void
132132
return;
133133
}
134134
// empty stmts? add parent::__construct() to setup command
135-
if (\count((array) $constuctClassMethod->stmts) === 0) {
135+
if ((array) $constuctClassMethod->stmts === []) {
136136
$parentConstructStaticCall = new StaticCall(new Name('parent'), '__construct');
137137
$constuctClassMethod->stmts[] = new Expression($parentConstructStaticCall);
138138
}

0 commit comments

Comments
 (0)