mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 4520aaaefc4480cdb15593184c0afa0646b0f291
4520aaaefc
[Php56] Skip AddDefaultValueForUndefinedVariableRector on has InlineHTML (#757)
This commit is contained in:
parent
4e2d5cfdcf
commit
0534ffdc06
@ -6,8 +6,8 @@ namespace Rector\PSR4\Rector\FileWithoutNamespace;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Declare_;
|
||||
use PhpParser\Node\Stmt\InlineHTML;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface;
|
||||
@ -28,10 +28,15 @@ final class NormalizeNamespaceByPSR4ComposerAutoloadRector extends \Rector\Core\
|
||||
* @var \Rector\PSR4\NodeManipulator\FullyQualifyStmtsAnalyzer
|
||||
*/
|
||||
private $fullyQualifyStmtsAnalyzer;
|
||||
public function __construct(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface $psr4AutoloadNamespaceMatcher, \Rector\PSR4\NodeManipulator\FullyQualifyStmtsAnalyzer $fullyQualifyStmtsAnalyzer)
|
||||
/**
|
||||
* @var \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer
|
||||
*/
|
||||
private $inlineHTMLAnalyzer;
|
||||
public function __construct(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface $psr4AutoloadNamespaceMatcher, \Rector\PSR4\NodeManipulator\FullyQualifyStmtsAnalyzer $fullyQualifyStmtsAnalyzer, \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer $inlineHTMLAnalyzer)
|
||||
{
|
||||
$this->psr4AutoloadNamespaceMatcher = $psr4AutoloadNamespaceMatcher;
|
||||
$this->fullyQualifyStmtsAnalyzer = $fullyQualifyStmtsAnalyzer;
|
||||
$this->inlineHTMLAnalyzer = $inlineHTMLAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -75,7 +80,7 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if ($this->shouldSkip($node)) {
|
||||
if ($this->inlineHTMLAnalyzer->hasInlineHTML($node)) {
|
||||
return null;
|
||||
}
|
||||
$expectedNamespace = $this->psr4AutoloadNamespaceMatcher->getExpectedNamespace($this->file, $node);
|
||||
@ -94,10 +99,6 @@ CODE_SAMPLE
|
||||
$this->fullyQualifyStmtsAnalyzer->process($node->stmts);
|
||||
return $node;
|
||||
}
|
||||
private function shouldSkip(\PhpParser\Node $node) : bool
|
||||
{
|
||||
return (bool) $this->betterNodeFinder->findFirstInstanceOf($node, \PhpParser\Node\Stmt\InlineHTML::class);
|
||||
}
|
||||
private function refactorFileWithoutNamespace(\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $fileWithoutNamespace, string $expectedNamespace) : \PhpParser\Node\Stmt\Namespace_
|
||||
{
|
||||
$nodes = $fileWithoutNamespace->stmts;
|
||||
|
@ -13,6 +13,7 @@ use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Php56\NodeAnalyzer\UndefinedVariableResolver;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
@ -33,9 +34,14 @@ final class AddDefaultValueForUndefinedVariableRector extends \Rector\Core\Recto
|
||||
* @var \Rector\Php56\NodeAnalyzer\UndefinedVariableResolver
|
||||
*/
|
||||
private $undefinedVariableResolver;
|
||||
public function __construct(\Rector\Php56\NodeAnalyzer\UndefinedVariableResolver $undefinedVariableResolver)
|
||||
/**
|
||||
* @var \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer
|
||||
*/
|
||||
private $inlineHTMLAnalyzer;
|
||||
public function __construct(\Rector\Php56\NodeAnalyzer\UndefinedVariableResolver $undefinedVariableResolver, \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer $inlineHTMLAnalyzer)
|
||||
{
|
||||
$this->undefinedVariableResolver = $undefinedVariableResolver;
|
||||
$this->inlineHTMLAnalyzer = $inlineHTMLAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -78,6 +84,9 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if ($this->inlineHTMLAnalyzer->hasInlineHTML($node)) {
|
||||
return null;
|
||||
}
|
||||
$undefinedVariableNames = $this->undefinedVariableResolver->resolve($node);
|
||||
// avoids adding same variable multiple tiemes
|
||||
$alreadyAddedVariableNames = (array) $node->getAttribute(self::ALREADY_ADDED_VARIABLE_NAMES);
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '991ea06c15009442d0a59d8503440681260ae612';
|
||||
public const PACKAGE_VERSION = '4520aaaefc4480cdb15593184c0afa0646b0f291';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-08-25 14:36:51';
|
||||
public const RELEASE_DATE = '2021-08-25 10:17:21';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210825\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
27
src/NodeAnalyzer/InlineHTMLAnalyzer.php
Normal file
27
src/NodeAnalyzer/InlineHTMLAnalyzer.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\InlineHTML;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
final class InlineHTMLAnalyzer
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder)
|
||||
{
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
public function hasInlineHTML(\PhpParser\Node $node) : bool
|
||||
{
|
||||
if ($node instanceof \PhpParser\Node\FunctionLike) {
|
||||
return (bool) $this->betterNodeFinder->findInstanceOf((array) $node->getStmts(), \PhpParser\Node\Stmt\InlineHTML::class);
|
||||
}
|
||||
return (bool) $this->betterNodeFinder->findInstanceOf($node, \PhpParser\Node\Stmt\InlineHTML::class);
|
||||
}
|
||||
}
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4::getLoader();
|
||||
return ComposerAutoloaderInit909e5eb18836043926829d912184c2d8::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1836,6 +1836,7 @@ return array(
|
||||
'Rector\\Core\\NodeAnalyzer\\CompactFuncCallAnalyzer' => $baseDir . '/src/NodeAnalyzer/CompactFuncCallAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\ConstFetchAnalyzer' => $baseDir . '/src/NodeAnalyzer/ConstFetchAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\EnumAnalyzer' => $baseDir . '/src/NodeAnalyzer/EnumAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\InlineHTMLAnalyzer' => $baseDir . '/src/NodeAnalyzer/InlineHTMLAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\ParamAnalyzer' => $baseDir . '/src/NodeAnalyzer/ParamAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\PromotedPropertyParamCleaner' => $baseDir . '/src/NodeAnalyzer/PromotedPropertyParamCleaner.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\PropertyFetchAnalyzer' => $baseDir . '/src/NodeAnalyzer/PropertyFetchAnalyzer.php',
|
||||
|
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 ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4
|
||||
class ComposerAutoloaderInit909e5eb18836043926829d912184c2d8
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit909e5eb18836043926829d912184c2d8', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit909e5eb18836043926829d912184c2d8', '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\ComposerStaticInit31e327da48d5e779488d59181d32eec4::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit909e5eb18836043926829d912184c2d8::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,19 +42,19 @@ class ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit31e327da48d5e779488d59181d32eec4::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit909e5eb18836043926829d912184c2d8::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire31e327da48d5e779488d59181d32eec4($fileIdentifier, $file);
|
||||
composerRequire909e5eb18836043926829d912184c2d8($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire31e327da48d5e779488d59181d32eec4($fileIdentifier, $file)
|
||||
function composerRequire909e5eb18836043926829d912184c2d8($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit31e327da48d5e779488d59181d32eec4
|
||||
class ComposerStaticInit909e5eb18836043926829d912184c2d8
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
@ -2196,6 +2196,7 @@ class ComposerStaticInit31e327da48d5e779488d59181d32eec4
|
||||
'Rector\\Core\\NodeAnalyzer\\CompactFuncCallAnalyzer' => __DIR__ . '/../..' . '/src/NodeAnalyzer/CompactFuncCallAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\ConstFetchAnalyzer' => __DIR__ . '/../..' . '/src/NodeAnalyzer/ConstFetchAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\EnumAnalyzer' => __DIR__ . '/../..' . '/src/NodeAnalyzer/EnumAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\InlineHTMLAnalyzer' => __DIR__ . '/../..' . '/src/NodeAnalyzer/InlineHTMLAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\ParamAnalyzer' => __DIR__ . '/../..' . '/src/NodeAnalyzer/ParamAnalyzer.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\PromotedPropertyParamCleaner' => __DIR__ . '/../..' . '/src/NodeAnalyzer/PromotedPropertyParamCleaner.php',
|
||||
'Rector\\Core\\NodeAnalyzer\\PropertyFetchAnalyzer' => __DIR__ . '/../..' . '/src/NodeAnalyzer/PropertyFetchAnalyzer.php',
|
||||
@ -3856,9 +3857,9 @@ class ComposerStaticInit31e327da48d5e779488d59181d32eec4
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit31e327da48d5e779488d59181d32eec4::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit31e327da48d5e779488d59181d32eec4::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit31e327da48d5e779488d59181d32eec4::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit909e5eb18836043926829d912184c2d8::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit909e5eb18836043926829d912184c2d8::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit909e5eb18836043926829d912184c2d8::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -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('RectorPrefix20210825\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4', false) && !interface_exists('ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4', false) && !trait_exists('ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4', false)) {
|
||||
spl_autoload_call('RectorPrefix20210825\ComposerAutoloaderInit31e327da48d5e779488d59181d32eec4');
|
||||
if (!class_exists('ComposerAutoloaderInit909e5eb18836043926829d912184c2d8', false) && !interface_exists('ComposerAutoloaderInit909e5eb18836043926829d912184c2d8', false) && !trait_exists('ComposerAutoloaderInit909e5eb18836043926829d912184c2d8', false)) {
|
||||
spl_autoload_call('RectorPrefix20210825\ComposerAutoloaderInit909e5eb18836043926829d912184c2d8');
|
||||
}
|
||||
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('RectorPrefix20210825\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20210825\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire31e327da48d5e779488d59181d32eec4')) {
|
||||
function composerRequire31e327da48d5e779488d59181d32eec4() {
|
||||
return \RectorPrefix20210825\composerRequire31e327da48d5e779488d59181d32eec4(...func_get_args());
|
||||
if (!function_exists('composerRequire909e5eb18836043926829d912184c2d8')) {
|
||||
function composerRequire909e5eb18836043926829d912184c2d8() {
|
||||
return \RectorPrefix20210825\composerRequire909e5eb18836043926829d912184c2d8(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user