Updated Rector to commit 5e7ecb623ad7fe78a660fe3d2275166492ebdb40

5e7ecb623a [stabilize] Remove child classes from MixedTypeRector as not reliable (#5537)
This commit is contained in:
Tomas Votruba 2024-01-31 22:01:40 +00:00
parent b33dd4eba3
commit c49de5a16c
10 changed files with 12 additions and 62 deletions

View File

@ -120,9 +120,6 @@ CODE_SAMPLE
return \false;
}
$methodName = $this->nodeNameResolver->getName($classMethod);
if ($this->classChildAnalyzer->hasChildClassMethod($classReflection, $methodName)) {
return \true;
}
return $this->classChildAnalyzer->hasParentClassMethod($classReflection, $methodName);
}
/**

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '8b7c8c7d4f7ed05b36f595c01c632494193ba4bc';
public const PACKAGE_VERSION = '5e7ecb623ad7fe78a660fe3d2275166492ebdb40';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-01-31 21:41:35';
public const RELEASE_DATE = '2024-01-31 21:59:22';
/**
* @var int
*/

View File

@ -8,36 +8,8 @@ use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Reflection\Php\PhpMethodReflection;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
final class ClassChildAnalyzer
{
/**
* @readonly
* @var \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer
*/
private $familyRelationsAnalyzer;
public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer)
{
$this->familyRelationsAnalyzer = $familyRelationsAnalyzer;
}
public function hasChildClassMethod(ClassReflection $classReflection, string $methodName) : bool
{
$childrenClassReflections = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection);
foreach ($childrenClassReflections as $childClassReflection) {
if (!$childClassReflection->hasNativeMethod($methodName)) {
continue;
}
$constructorReflectionMethod = $childClassReflection->getNativeMethod($methodName);
if (!$constructorReflectionMethod instanceof PhpMethodReflection) {
continue;
}
$methodDeclaringClassReflection = $constructorReflectionMethod->getDeclaringClass();
if ($methodDeclaringClassReflection->getName() === $childClassReflection->getName()) {
return \true;
}
}
return \false;
}
public function hasParentClassMethod(ClassReflection $classReflection, string $methodName) : bool
{
return $this->resolveParentClassMethods($classReflection, $methodName) !== [];

View File

@ -35,6 +35,7 @@ final class FamilyRelationsAnalyzer
}
/**
* @return ClassReflection[]
* @deprecated as not reliable
*/
public function getChildrenOfClassReflection(ClassReflection $desiredClassReflection) : array
{

View File

@ -6,7 +6,6 @@ namespace Rector\NodeManipulator;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\ObjectType;
use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer;
use Rector\NodeNameResolver\NodeNameResolver;
final class ClassManipulator
{
@ -20,16 +19,10 @@ final class ClassManipulator
* @var \PHPStan\Reflection\ReflectionProvider
*/
private $reflectionProvider;
/**
* @readonly
* @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer
*/
private $classChildAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, ClassChildAnalyzer $classChildAnalyzer)
public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->reflectionProvider = $reflectionProvider;
$this->classChildAnalyzer = $classChildAnalyzer;
}
public function hasParentMethodOrInterface(ObjectType $objectType, string $oldMethod, string $newMethod) : bool
{
@ -42,9 +35,6 @@ final class ClassManipulator
if (!$ancestorClassReflection->hasMethod($oldMethod)) {
continue;
}
if ($this->classChildAnalyzer->hasChildClassMethod($ancestorClassReflection, $newMethod)) {
continue;
}
return \true;
}
return \false;

View File

@ -1742,12 +1742,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "44d177b2c25bbe3435262f2a45c8d4d1fa247265"
"reference": "8d1aab27edc3409cd976ddf109ac4933ec33ad5b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/44d177b2c25bbe3435262f2a45c8d4d1fa247265",
"reference": "44d177b2c25bbe3435262f2a45c8d4d1fa247265",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/8d1aab27edc3409cd976ddf109ac4933ec33ad5b",
"reference": "8d1aab27edc3409cd976ddf109ac4933ec33ad5b",
"shasum": ""
},
"require": {
@ -1769,7 +1769,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-01-23T10:44:34+00:00",
"time": "2024-01-31T21:56:19+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
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 f6b9b1d'), '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 44d177b'), '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 f091938'), '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 989040e'));
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 f6b9b1d'), '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 8d1aab2'), '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 f091938'), '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 989040e'));
private function __construct()
{
}

View File

@ -5,7 +5,6 @@ namespace Rector\DowngradePhp72\NodeAnalyzer;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Reflection\ClassReflection;
use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer;
use Rector\NodeNameResolver\NodeNameResolver;
final class BuiltInMethodAnalyzer
{
@ -14,15 +13,9 @@ final class BuiltInMethodAnalyzer
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer
*/
private $classChildAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, ClassChildAnalyzer $classChildAnalyzer)
public function __construct(NodeNameResolver $nodeNameResolver)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->classChildAnalyzer = $classChildAnalyzer;
}
public function isImplementsBuiltInInterface(ClassReflection $classReflection, ClassMethod $classMethod) : bool
{
@ -30,9 +23,6 @@ final class BuiltInMethodAnalyzer
return \false;
}
$methodName = $this->nodeNameResolver->getName($classMethod);
if ($this->classChildAnalyzer->hasChildClassMethod($classReflection, $methodName)) {
return \false;
}
foreach ($classReflection->getInterfaces() as $interfaceReflection) {
if (!$interfaceReflection->isBuiltin()) {
continue;

View File

@ -14,7 +14,7 @@ $loader = (static function () {
// Restore the backup and ensure the excluded files are properly marked as loaded
$GLOBALS['__composer_autoload_files'] = \array_merge(
$existingComposerAutoloadFiles,
\array_fill_keys(['5928a00fa978807cf85d90ec3f4b0147', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a'], true)
\array_fill_keys(['0e6d7bf4a5811bfa5cf40c5ccd6fae6a', '5928a00fa978807cf85d90ec3f4b0147'], true)
);
return $loader;