Skip to content

Commit

Permalink
Updated Rector to commit fee8a47
Browse files Browse the repository at this point in the history
rectorphp/rector-src@fee8a47 [DeadCode] Add Scope check on RemoveParentCallWithoutParentRector (#1603)
  • Loading branch information
TomasVotruba committed Dec 31, 2021
1 parent b88b7fa commit e732d06
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -90,16 +91,13 @@ public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) {
return null;
}
if (!$node->class instanceof \PhpParser\Node\Name) {
if ($this->shouldSkip($node, $classLike)) {
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())) {
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if (!$scope instanceof \PHPStan\Analyser\Scope) {
return null;
}
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
$parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope);
if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) {
return $this->processNoParentReflection($node);
Expand All @@ -123,6 +121,16 @@ public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
$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);
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit7b25b43030d1b0f39f17634532dbba66::getLoader();
return ComposerAutoloaderInitc37daabab6bee634befe1d9811a217c4::getLoader();
26 changes: 17 additions & 9 deletions vendor/bin/easy-testing
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
26 changes: 17 additions & 9 deletions vendor/bin/neon-lint
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
26 changes: 17 additions & 9 deletions vendor/bin/php-parse
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
26 changes: 17 additions & 9 deletions vendor/bin/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
29 changes: 19 additions & 10 deletions vendor/bin/phpstan.phar
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
26 changes: 17 additions & 9 deletions vendor/bin/vendor-patches
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading

0 comments on commit e732d06

Please sign in to comment.