Updated Rector to commit 881d0b7e85f96a03c96fe9bb0ebad2fda8a71b8f

881d0b7e85 [PHPStanStaticTypeMapper] Handle crash on DowngradeMixedTypeDeclarationRector for PHPStan\Type\ConditionalType (#4625)
This commit is contained in:
Tomas Votruba 2023-07-31 14:21:36 +00:00
parent 47e256a9ad
commit 78e7a43276
6 changed files with 79 additions and 12 deletions

View File

@ -0,0 +1,65 @@
<?php
declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PHPStan\Type\ObjectType;
use PHPStan\Reflection\ClassReflection;
use RectorPrefix202307\Nette\Utils\Strings;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\ConditionalType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
use RectorPrefix202307\Symfony\Contracts\Service\Attribute\Required;
use PHPStan\Type\TypeTraverser;
/**
* @implements TypeMapperInterface<ConditionalType>
*/
final class ConditionalTypeMapper implements TypeMapperInterface
{
/**
* @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper
*/
private $phpStanStaticTypeMapper;
/**
* @required
*/
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void
{
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
}
/**
* @return class-string<Type>
*/
public function getNodeClass() : string
{
return ConditionalType::class;
}
/**
* @param ConditionalType $type
*/
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
{
$type = TypeTraverser::map($type, static function (Type $type, callable $traverse) : Type {
if ($type instanceof ObjectType && !$type->getClassReflection() instanceof ClassReflection) {
$newClassName = (string) Strings::after($type->getClassName(), '\\', -1);
return $traverse(new ObjectType($newClassName));
}
return $traverse($type);
});
return $type->toPhpDocNode();
}
/**
* @param ConditionalType $type
* @param TypeKind::* $typeKind
*/
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
{
$type = TypeCombinator::union($type->getIf(), $type->getElse());
return $this->phpStanStaticTypeMapper->mapToPhpParserNode($type, $typeKind);
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '23c2f89cba29b52393b90c6ccc2264440380016c';
public const PACKAGE_VERSION = '881d0b7e85f96a03c96fe9bb0ebad2fda8a71b8f';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-31 13:09:30';
public const RELEASE_DATE = '2023-07-31 16:17:58';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitc21ee7f21a523ce7dfc27e490441d5c1::getLoader();
return ComposerAutoloaderInit9026055d70d51525ed8a486d5388f036::getLoader();

View File

@ -2029,6 +2029,7 @@ return array(
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ClassStringTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/ClassStringTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ClosureTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ConditionalTypeForParameterMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/ConditionalTypeForParameterMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ConditionalTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/ConditionalTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\FloatTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\GenericClassStringTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/GenericClassStringTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasMethodTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitc21ee7f21a523ce7dfc27e490441d5c1
class ComposerAutoloaderInit9026055d70d51525ed8a486d5388f036
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitc21ee7f21a523ce7dfc27e490441d5c1
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitc21ee7f21a523ce7dfc27e490441d5c1', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit9026055d70d51525ed8a486d5388f036', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitc21ee7f21a523ce7dfc27e490441d5c1', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit9026055d70d51525ed8a486d5388f036', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit9026055d70d51525ed8a486d5388f036::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit9026055d70d51525ed8a486d5388f036::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1
class ComposerStaticInit9026055d70d51525ed8a486d5388f036
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2283,6 +2283,7 @@ class ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ClassStringTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/ClassStringTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ClosureTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ConditionalTypeForParameterMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/ConditionalTypeForParameterMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ConditionalTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/ConditionalTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\FloatTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\GenericClassStringTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/GenericClassStringTypeMapper.php',
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\HasMethodTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php',
@ -3024,9 +3025,9 @@ class ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc21ee7f21a523ce7dfc27e490441d5c1::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit9026055d70d51525ed8a486d5388f036::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9026055d70d51525ed8a486d5388f036::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9026055d70d51525ed8a486d5388f036::$classMap;
}, null, ClassLoader::class);
}