Updated Rector to commit 335d593e34bbc124a505bdb150eb971fb92a0e87

335d593e34 [TypeDeclaration] Handle return self on TypedPropertyFromStrictGetterMethodReturnTypeRector on php 8.0 feature enabled (#3088)
This commit is contained in:
Tomas Votruba 2022-11-23 10:02:01 +00:00
parent ed44a0660b
commit 8b12bd8a12
11 changed files with 35 additions and 26 deletions

View File

@ -27,6 +27,7 @@ use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType;
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType;
/**
* @implements PhpParserNodeMapperInterface<Name>
*/
@ -87,7 +88,7 @@ final class NameNodeMapper implements PhpParserNodeMapperInterface
return \in_array($name, $oldToNewClasses, \true);
}
/**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\StaticType|\PHPStan\Type\ObjectWithoutClassType
* @return \PHPStan\Type\MixedType|\PHPStan\Type\StaticType|\Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType|\PHPStan\Type\ObjectWithoutClassType
*/
private function createClassReferenceType(Name $name, string $reference)
{
@ -100,6 +101,9 @@ final class NameNodeMapper implements PhpParserNodeMapperInterface
if ($reference === ObjectReference::STATIC) {
return new StaticType($classReflection);
}
if ($reference === ObjectReference::SELF) {
return new SelfStaticType($classReflection);
}
if ($reference === ObjectReference::PARENT) {
$parentClassReflection = $classReflection->getParentClass();
if ($parentClassReflection instanceof ClassReflection) {

View File

@ -111,11 +111,11 @@ CODE_SAMPLE
}
return null;
}
private function isPositiveInteger(Expr $offset) : bool
private function isPositiveInteger(Expr $expr) : bool
{
if (!$offset instanceof LNumber) {
if (!$expr instanceof LNumber) {
return \false;
}
return $offset->value > 0;
return $expr->value > 0;
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '30afbb8da236ab0935851b91a7fb4b5cf26aa2e8';
public const PACKAGE_VERSION = '335d593e34bbc124a505bdb150eb971fb92a0e87';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-11-22 20:58:50';
public const RELEASE_DATE = '2022-11-23 16:56:40';
/**
* @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 ComposerAutoloaderInit2cf7a01cd822a1ecdffe4a5160e5f912::getLoader();
return ComposerAutoloaderInit8609f3dc399a99f2b9fae330021b993d::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit2cf7a01cd822a1ecdffe4a5160e5f912
class ComposerAutoloaderInit8609f3dc399a99f2b9fae330021b993d
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit2cf7a01cd822a1ecdffe4a5160e5f912
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit2cf7a01cd822a1ecdffe4a5160e5f912', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit8609f3dc399a99f2b9fae330021b993d', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2cf7a01cd822a1ecdffe4a5160e5f912', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit8609f3dc399a99f2b9fae330021b993d', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit8609f3dc399a99f2b9fae330021b993d::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit8609f3dc399a99f2b9fae330021b993d::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire2cf7a01cd822a1ecdffe4a5160e5f912($fileIdentifier, $file);
composerRequire8609f3dc399a99f2b9fae330021b993d($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit2cf7a01cd822a1ecdffe4a5160e5f912
* @param string $file
* @return void
*/
function composerRequire2cf7a01cd822a1ecdffe4a5160e5f912($fileIdentifier, $file)
function composerRequire8609f3dc399a99f2b9fae330021b993d($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 ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912
class ComposerStaticInit8609f3dc399a99f2b9fae330021b993d
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3036,9 +3036,9 @@ class ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2cf7a01cd822a1ecdffe4a5160e5f912::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit8609f3dc399a99f2b9fae330021b993d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8609f3dc399a99f2b9fae330021b993d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8609f3dc399a99f2b9fae330021b993d::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1853,12 +1853,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "d5a52d643513c66fc23270aa4748a564508ccc1d"
"reference": "98ed9d53fc187d30a1915d8a4578b96a808921f6"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/d5a52d643513c66fc23270aa4748a564508ccc1d",
"reference": "d5a52d643513c66fc23270aa4748a564508ccc1d",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/98ed9d53fc187d30a1915d8a4578b96a808921f6",
"reference": "98ed9d53fc187d30a1915d8a4578b96a808921f6",
"shasum": ""
},
"require": {
@ -1875,7 +1875,7 @@
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.6",
"rector\/rector-debugging": "dev-main",
"rector\/rector-src": "dev-main",
"rector\/rector-src": "dev-main#377713ae7044739b33a2186bbebbd253f7a0efdd",
"symplify\/easy-ci": "^11.1",
"symplify\/easy-coding-standard": "^11.1",
"symplify\/phpstan-extensions": "^11.1",
@ -1883,7 +1883,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-11-19T11:55:01+00:00",
"time": "2022-11-23T09:30:48+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/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main bf394ee'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main d5a52d6'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 769064f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 26c3b12'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main bf394ee'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 98ed9d5'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 769064f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 26c3b12'));
private function __construct()
{
}

View File

@ -14,7 +14,7 @@
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.6",
"rector\/rector-debugging": "dev-main",
"rector\/rector-src": "dev-main",
"rector\/rector-src": "dev-main#377713ae7044739b33a2186bbebbd253f7a0efdd",
"symplify\/easy-ci": "^11.1",
"symplify\/easy-coding-standard": "^11.1",
"symplify\/phpstan-extensions": "^11.1",

View File

@ -16,6 +16,7 @@ use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Interface_;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\Type\ObjectType;
use PHPStan\Type\ThisType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\UnionType;
@ -30,6 +31,7 @@ use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType;
use Rector\ValueObject\ClassMethodWillChangeReturnType;
/**
* @see https://wiki.php.net/rfc/internal_method_return_types#proposal
@ -218,6 +220,9 @@ final class PhpDocFromTypeDeclarationDecorator
private function isTypeMatch($typeNode, Type $requireType) : bool
{
$returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($typeNode);
if ($returnType instanceof SelfStaticType) {
$returnType = new ThisType($returnType->getClassReflection());
}
// cover nullable union types
if ($returnType instanceof UnionType) {
$returnType = TypeCombinator::removeNull($returnType);