Updated Rector to commit 47ad54dfc8

47ad54dfc8 [DowngradePhp72] Skip implements built in interface method on DowngradeParameterTypeWideningRector (#766)
This commit is contained in:
Tomas Votruba 2021-08-26 08:02:58 +00:00
parent 870f7748a6
commit e24c6f3de1
10 changed files with 79 additions and 23 deletions

View File

@ -0,0 +1,45 @@
<?php
declare (strict_types=1);
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
{
/**
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer
*/
private $classChildAnalyzer;
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->classChildAnalyzer = $classChildAnalyzer;
}
public function isImplementsBuiltInInterface(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool
{
if (!$classReflection->isClass()) {
return \false;
}
$methodName = $this->nodeNameResolver->getName($classMethod);
if ($this->classChildAnalyzer->hasChildClassMethod($classReflection, $methodName)) {
return \false;
}
foreach ($classReflection->getInterfaces() as $interfaceReflection) {
if (!$interfaceReflection->isBuiltIn()) {
continue;
}
if (!$interfaceReflection->hasMethod($methodName)) {
continue;
}
return \true;
}
return \false;
}
}

View File

@ -10,6 +10,7 @@ use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\DowngradePhp72\NodeAnalyzer\BuiltInMethodAnalyzer;
use Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer;
@ -52,11 +53,16 @@ final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\Abs
* @var \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer
*/
private $autowiredClassMethodOrPropertyAnalyzer;
public function __construct(\Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer)
/**
* @var \Rector\DowngradePhp72\NodeAnalyzer\BuiltInMethodAnalyzer
*/
private $builtInMethodAnalyzer;
public function __construct(\Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, \Rector\DowngradePhp72\NodeAnalyzer\BuiltInMethodAnalyzer $builtInMethodAnalyzer)
{
$this->nativeParamToPhpDocDecorator = $nativeParamToPhpDocDecorator;
$this->reflectionProvider = $reflectionProvider;
$this->autowiredClassMethodOrPropertyAnalyzer = $autowiredClassMethodOrPropertyAnalyzer;
$this->builtInMethodAnalyzer = $builtInMethodAnalyzer;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
@ -127,6 +133,9 @@ CODE_SAMPLE
if ($this->shouldSkipClassMethod($node)) {
return null;
}
if ($this->builtInMethodAnalyzer->isImplementsBuiltInInterface($classReflection, $node)) {
return null;
}
// Downgrade every scalar parameter, just to be sure
foreach (\array_keys($node->params) as $paramPosition) {
$this->removeParamTypeFromMethod($node, $paramPosition);

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '5b5b94b00237846b27d680a477736c275457da82';
public const PACKAGE_VERSION = '47ad54dfc8bbeed5880ba95c0424dd41a01d209b';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-26 09:48:49';
public const RELEASE_DATE = '2021-08-26 09:51:06';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210826\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 ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe::getLoader();
return ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061::getLoader();

View File

@ -2141,6 +2141,7 @@ return array(
'Rector\\DowngradePhp71\\Rector\\TryCatch\\DowngradePipeToMultiCatchExceptionRector' => $baseDir . '/rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php',
'Rector\\DowngradePhp71\\TypeDeclaration\\PhpDocFromTypeDeclarationDecorator' => $baseDir . '/rules/DowngradePhp71/TypeDeclaration/PhpDocFromTypeDeclarationDecorator.php',
'Rector\\DowngradePhp72\\Contract\\Rector\\DowngradeTypeRectorInterface' => $baseDir . '/rules/DowngradePhp72/Contract/Rector/DowngradeTypeRectorInterface.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\BuiltInMethodAnalyzer' => $baseDir . '/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\FunctionExistsFunCallAnalyzer' => $baseDir . '/rules/DowngradePhp72/NodeAnalyzer/FunctionExistsFunCallAnalyzer.php',
'Rector\\DowngradePhp72\\PhpDoc\\NativeParamToPhpDocDecorator' => $baseDir . '/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php',
'Rector\\DowngradePhp72\\Rector\\ClassMethod\\DowngradeParameterTypeWideningRector' => $baseDir . '/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe
class ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061', '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\ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit748e079cf6a075bf8e8448288f686061::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit748e079cf6a075bf8e8448288f686061::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire52c049d66bc4cbfe8159e70817b4b1fe($fileIdentifier, $file);
composerRequire748e079cf6a075bf8e8448288f686061($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire52c049d66bc4cbfe8159e70817b4b1fe($fileIdentifier, $file)
function composerRequire748e079cf6a075bf8e8448288f686061($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe
class ComposerStaticInit748e079cf6a075bf8e8448288f686061
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -2501,6 +2501,7 @@ class ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe
'Rector\\DowngradePhp71\\Rector\\TryCatch\\DowngradePipeToMultiCatchExceptionRector' => __DIR__ . '/../..' . '/rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php',
'Rector\\DowngradePhp71\\TypeDeclaration\\PhpDocFromTypeDeclarationDecorator' => __DIR__ . '/../..' . '/rules/DowngradePhp71/TypeDeclaration/PhpDocFromTypeDeclarationDecorator.php',
'Rector\\DowngradePhp72\\Contract\\Rector\\DowngradeTypeRectorInterface' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Contract/Rector/DowngradeTypeRectorInterface.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\BuiltInMethodAnalyzer' => __DIR__ . '/../..' . '/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\FunctionExistsFunCallAnalyzer' => __DIR__ . '/../..' . '/rules/DowngradePhp72/NodeAnalyzer/FunctionExistsFunCallAnalyzer.php',
'Rector\\DowngradePhp72\\PhpDoc\\NativeParamToPhpDocDecorator' => __DIR__ . '/../..' . '/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php',
'Rector\\DowngradePhp72\\Rector\\ClassMethod\\DowngradeParameterTypeWideningRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php',
@ -3857,9 +3858,9 @@ class ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit52c049d66bc4cbfe8159e70817b4b1fe::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit748e079cf6a075bf8e8448288f686061::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit748e079cf6a075bf8e8448288f686061::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit748e079cf6a075bf8e8448288f686061::$classMap;
}, null, ClassLoader::class);
}

View File

@ -27,7 +27,7 @@ class TokenStream implements \Iterator, \ArrayAccess
* @param int $lookAhead
* @return TokenInterface
*/
public function current($lookAhead = 0) : \RectorPrefix20210826\Helmich\TypoScriptParser\Tokenizer\TokenInterface
public function current(int $lookAhead = 0) : \RectorPrefix20210826\Helmich\TypoScriptParser\Tokenizer\TokenInterface
{
return $this[$this->index + $lookAhead];
}
@ -35,7 +35,7 @@ class TokenStream implements \Iterator, \ArrayAccess
* @param int $increment
* @return void
*/
public function next($increment = 1) : void
public function next(int $increment = 1) : void
{
if ($this->index < \count($this->tokens)) {
$this->index += $increment;

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('RectorPrefix20210826\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe', false) && !interface_exists('ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe', false) && !trait_exists('ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe', false)) {
spl_autoload_call('RectorPrefix20210826\ComposerAutoloaderInit52c049d66bc4cbfe8159e70817b4b1fe');
if (!class_exists('ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061', false) && !interface_exists('ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061', false) && !trait_exists('ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061', false)) {
spl_autoload_call('RectorPrefix20210826\ComposerAutoloaderInit748e079cf6a075bf8e8448288f686061');
}
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('RectorPrefix20210826\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3311,9 +3311,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210826\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire52c049d66bc4cbfe8159e70817b4b1fe')) {
function composerRequire52c049d66bc4cbfe8159e70817b4b1fe() {
return \RectorPrefix20210826\composerRequire52c049d66bc4cbfe8159e70817b4b1fe(...func_get_args());
if (!function_exists('composerRequire748e079cf6a075bf8e8448288f686061')) {
function composerRequire748e079cf6a075bf8e8448288f686061() {
return \RectorPrefix20210826\composerRequire748e079cf6a075bf8e8448288f686061(...func_get_args());
}
}
if (!function_exists('parseArgs')) {

View File

@ -554,7 +554,7 @@ class Process implements \IteratorAggregate
*
* @return \Generator
*/
public function getIterator($flags = 0)
public function getIterator(int $flags = 0)
{
$this->readPipesForOutput(__FUNCTION__, \false);
$clearOutput = !(self::ITER_KEEP_OUTPUT & $flags);