mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 92358f779952cca81bfd73fe3228e00135d6919b
92358f7799
[DeadCode] Fix remove dead stmt Rector (#65)
This commit is contained in:
parent
52befc0fb3
commit
568d9ef7f5
@ -19,6 +19,7 @@ use Rector\BetterPhpDocParser\PhpDocNodeTraverser\ChangedPhpDocNodeTraverserFact
|
||||
use Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix20210517\Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
||||
/**
|
||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter\PhpDocInfoPrinterTest
|
||||
@ -57,25 +58,21 @@ final class PhpDocInfoPrinter
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $tokenCount;
|
||||
private $tokenCount = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $currentTokenPosition;
|
||||
private $currentTokenPosition = 0;
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $tokens = [];
|
||||
/**
|
||||
* @var PhpDocNode
|
||||
*/
|
||||
private $phpDocNode;
|
||||
/**
|
||||
* @var PhpDocInfo
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo|null
|
||||
*/
|
||||
private $phpDocInfo;
|
||||
/**
|
||||
* @var PhpDocNodeTraverser
|
||||
* @var \Symplify\SimplePhpDocParser\PhpDocNodeTraverser
|
||||
*/
|
||||
private $changedPhpDocNodeTraverser;
|
||||
/**
|
||||
@ -129,15 +126,22 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
return (string) $phpDocInfo->getPhpDocNode();
|
||||
}
|
||||
$this->phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
$this->tokens = $phpDocInfo->getTokens();
|
||||
$this->tokenCount = $phpDocInfo->getTokenCount();
|
||||
$this->phpDocInfo = $phpDocInfo;
|
||||
$this->currentTokenPosition = 0;
|
||||
$phpDocString = $this->printPhpDocNode($this->phpDocNode);
|
||||
$phpDocString = $this->printPhpDocNode($phpDocNode);
|
||||
// hotfix of extra space with callable ()
|
||||
return \RectorPrefix20210517\Nette\Utils\Strings::replace($phpDocString, self::CALLABLE_REGEX, 'callable(');
|
||||
}
|
||||
public function getCurrentPhpDocInfo() : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
if ($this->phpDocInfo === null) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
return $this->phpDocInfo;
|
||||
}
|
||||
private function printPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : string
|
||||
{
|
||||
// no nodes were, so empty doc
|
||||
@ -200,7 +204,7 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
private function printEnd(string $output) : string
|
||||
{
|
||||
$lastTokenPosition = $this->phpDocNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION) ?: $this->currentTokenPosition;
|
||||
$lastTokenPosition = $this->getCurrentPhpDocInfo()->getPhpDocNode()->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION) ?: $this->currentTokenPosition;
|
||||
if ($lastTokenPosition === 0) {
|
||||
$lastTokenPosition = 1;
|
||||
}
|
||||
@ -210,7 +214,7 @@ final class PhpDocInfoPrinter
|
||||
{
|
||||
// skip removed nodes
|
||||
$positionJumpSet = [];
|
||||
$removedStartAndEnds = $this->removeNodesStartAndEndResolver->resolve($this->phpDocInfo->getOriginalPhpDocNode(), $this->phpDocNode, $this->tokens);
|
||||
$removedStartAndEnds = $this->removeNodesStartAndEndResolver->resolve($this->getCurrentPhpDocInfo()->getOriginalPhpDocNode(), $this->getCurrentPhpDocInfo()->getPhpDocNode(), $this->tokens);
|
||||
foreach ($removedStartAndEnds as $removedStartAndEnd) {
|
||||
$positionJumpSet[$removedStartAndEnd->getStart()] = $removedStartAndEnd->getEnd();
|
||||
}
|
||||
@ -247,7 +251,7 @@ final class PhpDocInfoPrinter
|
||||
return;
|
||||
}
|
||||
$startTokenPosition = $startAndEnd->getStart();
|
||||
$tokens = $this->phpDocInfo->getTokens();
|
||||
$tokens = $this->getCurrentPhpDocInfo()->getTokens();
|
||||
if (!isset($tokens[$startTokenPosition - 1])) {
|
||||
return;
|
||||
}
|
||||
@ -264,7 +268,7 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
private function standardPrintPhpDocChildNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : string
|
||||
{
|
||||
if ($this->phpDocInfo->isSingleLine()) {
|
||||
if ($this->getCurrentPhpDocInfo()->isSingleLine()) {
|
||||
return ' ' . $phpDocChildNode;
|
||||
}
|
||||
return self::NEWLINE_WITH_ASTERISK . $phpDocChildNode;
|
||||
|
@ -62,7 +62,7 @@ CODE_SAMPLE
|
||||
return \true;
|
||||
}
|
||||
if (!$node instanceof \PhpParser\Node\Expr\Assign) {
|
||||
return !(bool) $this->betterNodeFinder->find($node, function (\PhpParser\Node $n) use($arrayVariable) {
|
||||
return !(bool) $this->betterNodeFinder->find($node, function (\PhpParser\Node $n) use($arrayVariable) : bool {
|
||||
return $this->nodeComparator->areNodesEqual($arrayVariable, $n);
|
||||
});
|
||||
}
|
||||
|
@ -52,6 +52,9 @@ CODE_SAMPLE
|
||||
if ($livingCode === []) {
|
||||
return $this->removeNodeAndKeepComments($node);
|
||||
}
|
||||
if ($livingCode === [$node->expr]) {
|
||||
return null;
|
||||
}
|
||||
$firstExpr = \array_shift($livingCode);
|
||||
$node->expr = $firstExpr;
|
||||
$newNodes = [];
|
||||
|
@ -114,7 +114,7 @@ CODE_SAMPLE
|
||||
}
|
||||
private function createAnonymousClassName() : string
|
||||
{
|
||||
$fileInfo = $this->file->getSmartFileInfo();
|
||||
return self::ANONYMOUS_CLASS_PREFIX . \md5($fileInfo->getRealPath()) . '__' . \count($this->classes);
|
||||
$smartFileInfo = $this->file->getSmartFileInfo();
|
||||
return self::ANONYMOUS_CLASS_PREFIX . \md5($smartFileInfo->getRealPath()) . '__' . \count($this->classes);
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +82,9 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$fileInfo = $this->file->getSmartFileInfo();
|
||||
$smartFileInfo = $this->file->getSmartFileInfo();
|
||||
// this rule is parsing strings, so it heavy on performance; to lower it, we'll process only known opt-in files
|
||||
if (!$this->isRelevantFileInfo($fileInfo)) {
|
||||
if (!$this->isRelevantFileInfo($smartFileInfo)) {
|
||||
return null;
|
||||
}
|
||||
$stringKind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND);
|
||||
|
@ -40,7 +40,7 @@ final class ShowCommand extends \RectorPrefix20210517\Symfony\Component\Console\
|
||||
}
|
||||
private function reportLoadedRectors() : void
|
||||
{
|
||||
$rectors = \array_filter($this->rectors, function (\Rector\Core\Contract\Rector\RectorInterface $rector) {
|
||||
$rectors = \array_filter($this->rectors, function (\Rector\Core\Contract\Rector\RectorInterface $rector) : bool {
|
||||
return !$rector instanceof \Rector\PostRector\Contract\Rector\PostRectorInterface;
|
||||
});
|
||||
$rectorCount = \count($rectors);
|
||||
|
@ -14,12 +14,12 @@ final class DeprecationWarningCompilerPass implements \RectorPrefix20210517\Symf
|
||||
private const DEPRECATED_PARAMETERS = [\Rector\Core\Configuration\Option::SETS => 'Use $containerConfigurator->import(<set>); instead'];
|
||||
public function process(\RectorPrefix20210517\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void
|
||||
{
|
||||
$parametersBag = $containerBuilder->getParameterBag();
|
||||
$parameterBag = $containerBuilder->getParameterBag();
|
||||
foreach (self::DEPRECATED_PARAMETERS as $parameter => $message) {
|
||||
if (!$parametersBag->has($parameter)) {
|
||||
if (!$parameterBag->has($parameter)) {
|
||||
continue;
|
||||
}
|
||||
$setsParameters = $parametersBag->get($parameter);
|
||||
$setsParameters = $parameterBag->get($parameter);
|
||||
if ($setsParameters === []) {
|
||||
continue;
|
||||
}
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416::getLoader();
|
||||
return ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416
|
||||
class ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056', '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\ComposerStaticInit1303433c3afaeefd67209c1c96fe0416::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitcaa1db408a3d7bbf36b1b36017098056::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit1303433c3afaeefd67209c1c96fe0416::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitcaa1db408a3d7bbf36b1b36017098056::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1303433c3afaeefd67209c1c96fe0416($fileIdentifier, $file);
|
||||
composerRequirecaa1db408a3d7bbf36b1b36017098056($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire1303433c3afaeefd67209c1c96fe0416($fileIdentifier, $file)
|
||||
function composerRequirecaa1db408a3d7bbf36b1b36017098056($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1303433c3afaeefd67209c1c96fe0416
|
||||
class ComposerStaticInitcaa1db408a3d7bbf36b1b36017098056
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
@ -3454,9 +3454,9 @@ class ComposerStaticInit1303433c3afaeefd67209c1c96fe0416
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1303433c3afaeefd67209c1c96fe0416::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1303433c3afaeefd67209c1c96fe0416::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1303433c3afaeefd67209c1c96fe0416::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcaa1db408a3d7bbf36b1b36017098056::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcaa1db408a3d7bbf36b1b36017098056::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcaa1db408a3d7bbf36b1b36017098056::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
|
||||
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
|
||||
spl_autoload_call('RectorPrefix20210517\CheckoutEntityFactory');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416', false) && !interface_exists('ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416', false) && !trait_exists('ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416', false)) {
|
||||
spl_autoload_call('RectorPrefix20210517\ComposerAutoloaderInit1303433c3afaeefd67209c1c96fe0416');
|
||||
if (!class_exists('ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056', false) && !interface_exists('ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056', false) && !trait_exists('ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056', false)) {
|
||||
spl_autoload_call('RectorPrefix20210517\ComposerAutoloaderInitcaa1db408a3d7bbf36b1b36017098056');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210517\Doctrine\Inflector\Inflector');
|
||||
@ -95,9 +95,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20210517\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire1303433c3afaeefd67209c1c96fe0416')) {
|
||||
function composerRequire1303433c3afaeefd67209c1c96fe0416() {
|
||||
return \RectorPrefix20210517\composerRequire1303433c3afaeefd67209c1c96fe0416(...func_get_args());
|
||||
if (!function_exists('composerRequirecaa1db408a3d7bbf36b1b36017098056')) {
|
||||
function composerRequirecaa1db408a3d7bbf36b1b36017098056() {
|
||||
return \RectorPrefix20210517\composerRequirecaa1db408a3d7bbf36b1b36017098056(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user