Updated Rector to commit fee8a47d1a627b01bfba2d85293c84692715506a

fee8a47d1a [DeadCode] Add Scope check on RemoveParentCallWithoutParentRector (#1603)
This commit is contained in:
Tomas Votruba 2021-12-31 12:16:48 +00:00
parent b88b7fa079
commit e732d06e52
13 changed files with 155 additions and 90 deletions

View File

@ -11,6 +11,7 @@ use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\Enum\ObjectReference;
@ -90,16 +91,13 @@ CODE_SAMPLE
if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) {
return null;
}
if (!$node->class instanceof \PhpParser\Node\Name) {
return null;
}
if (!$this->isName($node->class, \Rector\Core\Enum\ObjectReference::PARENT()->getValue())) {
return null;
}
if ($classLike->extends instanceof \PhpParser\Node\Name\FullyQualified && !$this->reflectionProvider->hasClass($classLike->extends->toString())) {
if ($this->shouldSkip($node, $classLike)) {
return null;
}
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if (!$scope instanceof \PHPStan\Analyser\Scope) {
return null;
}
$parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope);
if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) {
return $this->processNoParentReflection($node);
@ -123,6 +121,16 @@ CODE_SAMPLE
$this->removeNode($node);
return null;
}
private function shouldSkip(\PhpParser\Node\Expr\StaticCall $staticCall, \PhpParser\Node\Stmt\Class_ $class) : bool
{
if (!$staticCall->class instanceof \PhpParser\Node\Name) {
return \true;
}
if (!$this->isName($staticCall->class, \Rector\Core\Enum\ObjectReference::PARENT()->getValue())) {
return \true;
}
return $class->extends instanceof \PhpParser\Node\Name\FullyQualified && !$this->reflectionProvider->hasClass($class->extends->toString());
}
private function processNoParentReflection(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\ConstFetch
{
$parent = $staticCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'eac5313f26a57e418ef66e55028319b339065d49';
public const PACKAGE_VERSION = 'fee8a47d1a627b01bfba2d85293c84692715506a';
/**
* @var string
*/
public const RELEASE_DATE = '2021-12-31 11:27:55';
public const RELEASE_DATE = '2021-12-31 19:05:06';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211231\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 ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66::getLoader();
return ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4::getLoader();

View File

@ -21,15 +21,15 @@ if (\PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 21);
$opened_path = \realpath($opened_path) ?: $opened_path;
$this->handle = \fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 17);
$this->realpath = \realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = \fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
\stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
public function stream_read($count)
@ -63,16 +63,24 @@ if (\PHP_VERSION_ID < 80000) {
}
public function stream_stat()
{
return \fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return \true;
}
public function url_stat($path, $flags)
{
$path = \substr($path, 17);
if (\file_exists($path)) {
return \stat($path);
}
return \false;
}
}
}
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('composer-bin-proxy', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "composer-bin-proxy://" . __DIR__ . '/..' . '/symplify/easy-testing/bin/easy-testing';
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "phpvfscomposer://" . __DIR__ . '/..' . '/symplify/easy-testing/bin/easy-testing';
exit(0);
}
}

26
vendor/bin/neon-lint vendored
View File

@ -21,15 +21,15 @@ if (\PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 21);
$opened_path = \realpath($opened_path) ?: $opened_path;
$this->handle = \fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 17);
$this->realpath = \realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = \fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
\stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
public function stream_read($count)
@ -63,16 +63,24 @@ if (\PHP_VERSION_ID < 80000) {
}
public function stream_stat()
{
return \fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return \true;
}
public function url_stat($path, $flags)
{
$path = \substr($path, 17);
if (\file_exists($path)) {
return \stat($path);
}
return \false;
}
}
}
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('composer-bin-proxy', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "composer-bin-proxy://" . __DIR__ . '/..' . '/nette/neon/bin/neon-lint';
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "phpvfscomposer://" . __DIR__ . '/..' . '/nette/neon/bin/neon-lint';
exit(0);
}
}

26
vendor/bin/php-parse vendored
View File

@ -21,15 +21,15 @@ if (\PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 21);
$opened_path = \realpath($opened_path) ?: $opened_path;
$this->handle = \fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 17);
$this->realpath = \realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = \fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
\stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
public function stream_read($count)
@ -63,16 +63,24 @@ if (\PHP_VERSION_ID < 80000) {
}
public function stream_stat()
{
return \fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return \true;
}
public function url_stat($path, $flags)
{
$path = \substr($path, 17);
if (\file_exists($path)) {
return \stat($path);
}
return \false;
}
}
}
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('composer-bin-proxy', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "composer-bin-proxy://" . __DIR__ . '/..' . '/nikic/php-parser/bin/php-parse';
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "phpvfscomposer://" . __DIR__ . '/..' . '/nikic/php-parser/bin/php-parse';
exit(0);
}
}

26
vendor/bin/phpstan vendored
View File

@ -21,15 +21,15 @@ if (\PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 21);
$opened_path = \realpath($opened_path) ?: $opened_path;
$this->handle = \fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 17);
$this->realpath = \realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = \fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
\stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
public function stream_read($count)
@ -63,16 +63,24 @@ if (\PHP_VERSION_ID < 80000) {
}
public function stream_stat()
{
return \fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return \true;
}
public function url_stat($path, $flags)
{
$path = \substr($path, 17);
if (\file_exists($path)) {
return \stat($path);
}
return \false;
}
}
}
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('composer-bin-proxy', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "composer-bin-proxy://" . __DIR__ . '/..' . '/phpstan/phpstan/phpstan';
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "phpvfscomposer://" . __DIR__ . '/..' . '/phpstan/phpstan/phpstan';
exit(0);
}
}

View File

@ -24,18 +24,17 @@ if (PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 21);
$opened_path = realpath($opened_path) ?: $opened_path;
$this->handle = fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 17);
$this->realpath = realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
@ -79,18 +78,28 @@ if (PHP_VERSION_ID < 80000) {
public function stream_stat()
{
return fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return true;
}
public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}
return false;
}
}
}
if (function_exists('stream_wrapper_register') && stream_wrapper_register('composer-bin-proxy', 'Composer\BinProxyWrapper')) {
include("composer-bin-proxy://" . __DIR__ . '/..'.'/phpstan/phpstan/phpstan.phar');
if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
include("phpvfscomposer://" . __DIR__ . '/..'.'/phpstan/phpstan/phpstan.phar');
exit(0);
}
}

View File

@ -21,15 +21,15 @@ if (\PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 21);
$opened_path = \realpath($opened_path) ?: $opened_path;
$this->handle = \fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 17);
$this->realpath = \realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = \fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
\stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
public function stream_read($count)
@ -63,16 +63,24 @@ if (\PHP_VERSION_ID < 80000) {
}
public function stream_stat()
{
return \fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return \true;
}
public function url_stat($path, $flags)
{
$path = \substr($path, 17);
if (\file_exists($path)) {
return \stat($path);
}
return \false;
}
}
}
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('composer-bin-proxy', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "composer-bin-proxy://" . __DIR__ . '/..' . '/symplify/vendor-patches/bin/vendor-patches';
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "phpvfscomposer://" . __DIR__ . '/..' . '/symplify/vendor-patches/bin/vendor-patches';
exit(0);
}
}

26
vendor/bin/yaml-lint vendored
View File

@ -21,15 +21,15 @@ if (\PHP_VERSION_ID < 80000) {
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 21);
$opened_path = \realpath($opened_path) ?: $opened_path;
$this->handle = \fopen($opened_path, $mode);
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = \substr($path, 17);
$this->realpath = \realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = \fopen($this->realpath, $mode);
$this->position = 0;
// remove all traces of this stream wrapper once it has been used
\stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle;
}
public function stream_read($count)
@ -63,16 +63,24 @@ if (\PHP_VERSION_ID < 80000) {
}
public function stream_stat()
{
return \fstat($this->handle);
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return \true;
}
public function url_stat($path, $flags)
{
$path = \substr($path, 17);
if (\file_exists($path)) {
return \stat($path);
}
return \false;
}
}
}
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('composer-bin-proxy', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "composer-bin-proxy://" . __DIR__ . '/..' . '/symfony/yaml/Resources/bin/yaml-lint';
if (\function_exists('stream_wrapper_register') && \stream_wrapper_register('phpvfscomposer', 'RectorPrefix20211231\\Composer\\BinProxyWrapper')) {
include "phpvfscomposer://" . __DIR__ . '/..' . '/symfony/yaml/Resources/bin/yaml-lint';
exit(0);
}
}

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66
class ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4', '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\ComposerStaticInit7b25b43030d1b0f39f17634532dbba66::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitc37daabab6bee634befe1d9811a217c4::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,12 +42,12 @@ class ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit7b25b43030d1b0f39f17634532dbba66::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitc37daabab6bee634befe1d9811a217c4::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire7b25b43030d1b0f39f17634532dbba66($fileIdentifier, $file);
composerRequirec37daabab6bee634befe1d9811a217c4($fileIdentifier, $file);
}
return $loader;
@ -59,7 +59,7 @@ class ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66
* @param string $file
* @return void
*/
function composerRequire7b25b43030d1b0f39f17634532dbba66($fileIdentifier, $file)
function composerRequirec37daabab6bee634befe1d9811a217c4($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 ComposerStaticInit7b25b43030d1b0f39f17634532dbba66
class ComposerStaticInitc37daabab6bee634befe1d9811a217c4
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3845,9 +3845,9 @@ class ComposerStaticInit7b25b43030d1b0f39f17634532dbba66
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7b25b43030d1b0f39f17634532dbba66::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7b25b43030d1b0f39f17634532dbba66::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7b25b43030d1b0f39f17634532dbba66::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitc37daabab6bee634befe1d9811a217c4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc37daabab6bee634befe1d9811a217c4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc37daabab6bee634befe1d9811a217c4::$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('RectorPrefix20211231\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66', false) && !interface_exists('ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66', false) && !trait_exists('ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66', false)) {
spl_autoload_call('RectorPrefix20211231\ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66');
if (!class_exists('ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4', false) && !interface_exists('ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4', false) && !trait_exists('ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4', false)) {
spl_autoload_call('RectorPrefix20211231\ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4');
}
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('RectorPrefix20211231\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -78,9 +78,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211231\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire7b25b43030d1b0f39f17634532dbba66')) {
function composerRequire7b25b43030d1b0f39f17634532dbba66() {
return \RectorPrefix20211231\composerRequire7b25b43030d1b0f39f17634532dbba66(...func_get_args());
if (!function_exists('composerRequirec37daabab6bee634befe1d9811a217c4')) {
function composerRequirec37daabab6bee634befe1d9811a217c4() {
return \RectorPrefix20211231\composerRequirec37daabab6bee634befe1d9811a217c4(...func_get_args());
}
}
if (!function_exists('scanPath')) {