Updated Rector to commit 36e81c09e13f947d116c091e09867e4ea9937ff6

36e81c09e1 [TypeDeclaration] Do not add void on possibly overriden protected class method (#1921)
This commit is contained in:
Tomas Votruba 2022-03-11 13:23:05 +00:00
parent b61a2f6afa
commit a7d159a260
6 changed files with 54 additions and 20 deletions

View File

@ -8,12 +8,15 @@ use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\NeverType;
use PHPStan\Type\VoidType;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver;
use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@ -93,7 +96,7 @@ CODE_SAMPLE
if ($node->returnType !== null) {
return null;
}
if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && ($node->isMagic() || $node->isAbstract())) {
if ($this->shouldSkipClassMethod($node)) {
return null;
}
if (!$this->silentVoidResolver->hasExclusiveVoid($node)) {
@ -133,4 +136,35 @@ CODE_SAMPLE
}
$this->phpDocTypeChanger->changeReturnType($phpDocInfo, new \PHPStan\Type\VoidType());
}
/**
* @param \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
*/
private function shouldSkipClassMethod($functionLike) : bool
{
if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) {
return \false;
}
if ($functionLike->isMagic()) {
return \true;
}
if ($functionLike->isAbstract()) {
return \true;
}
if ($functionLike->isProtected()) {
return !$this->isInsideFinalClass($functionLike);
}
return \false;
}
private function isInsideFinalClass(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool
{
$scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if (!$scope instanceof \PHPStan\Analyser\Scope) {
return \false;
}
$classReflection = $scope->getClassReflection();
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
return \false;
}
return $classReflection->isFinal();
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '07df2bc028742c7b9586601f837f4214690edb5d';
public const PACKAGE_VERSION = '36e81c09e13f947d116c091e09867e4ea9937ff6';
/**
* @var string
*/
public const RELEASE_DATE = '2022-03-11 09:53:07';
public const RELEASE_DATE = '2022-03-11 13:15:13';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20220311\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870::getLoader();
return ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870
class ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7f69124eb861b1207943f179d31fe870::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit6eba15c6be1438645da358292e0e0cce::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,12 +42,12 @@ class ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit7f69124eb861b1207943f179d31fe870::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit6eba15c6be1438645da358292e0e0cce::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire7f69124eb861b1207943f179d31fe870($fileIdentifier, $file);
composerRequire6eba15c6be1438645da358292e0e0cce($fileIdentifier, $file);
}
return $loader;
@ -59,7 +59,7 @@ class ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870
* @param string $file
* @return void
*/
function composerRequire7f69124eb861b1207943f179d31fe870($fileIdentifier, $file)
function composerRequire6eba15c6be1438645da358292e0e0cce($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 ComposerStaticInit7f69124eb861b1207943f179d31fe870
class ComposerStaticInit6eba15c6be1438645da358292e0e0cce
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3838,9 +3838,9 @@ class ComposerStaticInit7f69124eb861b1207943f179d31fe870
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7f69124eb861b1207943f179d31fe870::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7f69124eb861b1207943f179d31fe870::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7f69124eb861b1207943f179d31fe870::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit6eba15c6be1438645da358292e0e0cce::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6eba15c6be1438645da358292e0e0cce::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit6eba15c6be1438645da358292e0e0cce::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220311\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870', false) && !interface_exists('ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870', false) && !trait_exists('ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870', false)) {
spl_autoload_call('RectorPrefix20220311\ComposerAutoloaderInit7f69124eb861b1207943f179d31fe870');
if (!class_exists('ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce', false) && !interface_exists('ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce', false) && !trait_exists('ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce', false)) {
spl_autoload_call('RectorPrefix20220311\ComposerAutoloaderInit6eba15c6be1438645da358292e0e0cce');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220311\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220311\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire7f69124eb861b1207943f179d31fe870')) {
function composerRequire7f69124eb861b1207943f179d31fe870() {
return \RectorPrefix20220311\composerRequire7f69124eb861b1207943f179d31fe870(...func_get_args());
if (!function_exists('composerRequire6eba15c6be1438645da358292e0e0cce')) {
function composerRequire6eba15c6be1438645da358292e0e0cce() {
return \RectorPrefix20220311\composerRequire6eba15c6be1438645da358292e0e0cce(...func_get_args());
}
}
if (!function_exists('scanPath')) {