mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit e077d7c3fb9cc4204857a80d587f23a75ddf6665
e077d7c3fb
[DowngradePhp72] Handle variable exists on DowngradeStreamIsattyRector (#1997)
This commit is contained in:
parent
d991c5d3c9
commit
22b0d1cc15
@ -7,6 +7,7 @@ use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector;
|
||||
use Rector\DowngradePhp81\Rector\ClassConst\DowngradeFinalizePublicClassConstantRector;
|
||||
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector;
|
||||
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector;
|
||||
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector;
|
||||
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector;
|
||||
@ -26,4 +27,5 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
||||
$services->set(\Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector::class);
|
||||
$services->set(\Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector::class);
|
||||
$services->set(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector::class);
|
||||
};
|
||||
|
@ -13,6 +13,8 @@ use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Parser\InlineCodeParser;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
@ -32,10 +34,16 @@ final class DowngradeStreamIsattyRector extends \Rector\Core\Rector\AbstractRect
|
||||
* @var \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer
|
||||
*/
|
||||
private $functionExistsFunCallAnalyzer;
|
||||
public function __construct(\Rector\Core\PhpParser\Parser\InlineCodeParser $inlineCodeParser, \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\VariableNaming
|
||||
*/
|
||||
private $variableNaming;
|
||||
public function __construct(\Rector\Core\PhpParser\Parser\InlineCodeParser $inlineCodeParser, \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer, \Rector\Naming\Naming\VariableNaming $variableNaming)
|
||||
{
|
||||
$this->inlineCodeParser = $inlineCodeParser;
|
||||
$this->functionExistsFunCallAnalyzer = $functionExistsFunCallAnalyzer;
|
||||
$this->variableNaming = $variableNaming;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -97,9 +105,11 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$function = $this->createClosure();
|
||||
$assign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable('streamIsatty'), $function);
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
$variable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('streamIsatty', $scope));
|
||||
$assign = new \PhpParser\Node\Expr\Assign($variable, $function);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
|
||||
return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Expr\Variable('streamIsatty'), $node->args);
|
||||
return new \PhpParser\Node\Expr\FuncCall($variable, $node->args);
|
||||
}
|
||||
private function createClosure() : \PhpParser\Node\Expr\Closure
|
||||
{
|
||||
|
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\DowngradePhp81\Rector\FuncCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Parser\InlineCodeParser;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://wiki.php.net/rfc/is_list
|
||||
*
|
||||
* @see \Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector\DowngradeArrayIsListRectorTest
|
||||
*/
|
||||
final class DowngradeArrayIsListRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Parser\InlineCodeParser
|
||||
*/
|
||||
private $inlineCodeParser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer
|
||||
*/
|
||||
private $functionExistsFunCallAnalyzer;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\VariableNaming
|
||||
*/
|
||||
private $variableNaming;
|
||||
public function __construct(\Rector\Core\PhpParser\Parser\InlineCodeParser $inlineCodeParser, \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer, \Rector\Naming\Naming\VariableNaming $variableNaming)
|
||||
{
|
||||
$this->inlineCodeParser = $inlineCodeParser;
|
||||
$this->functionExistsFunCallAnalyzer = $functionExistsFunCallAnalyzer;
|
||||
$this->variableNaming = $variableNaming;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace array_is_list() function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
array_is_list([1 => 'apple', 'orange']);
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
if (function_exists('array_is_list')) {
|
||||
return array_is_list($array);
|
||||
}
|
||||
if ($array === []) {
|
||||
return true;
|
||||
}
|
||||
$current_key = 0;
|
||||
foreach ($array as $key => $noop) {
|
||||
if ($key !== $current_key) {
|
||||
return false;
|
||||
}
|
||||
++$current_key;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
$arrayIsList([1 => 'apple', 'orange']);
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Expr\FuncCall::class];
|
||||
}
|
||||
/**
|
||||
* @param FuncCall $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\FuncCall
|
||||
{
|
||||
if ($this->shouldSkip($node)) {
|
||||
return null;
|
||||
}
|
||||
$currentStmt = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStmt instanceof \PhpParser\Node\Stmt) {
|
||||
return null;
|
||||
}
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
$variable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('arrayIsList', $scope));
|
||||
$function = $this->createClosure();
|
||||
$expression = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, $function));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $currentStmt);
|
||||
return new \PhpParser\Node\Expr\FuncCall($variable, $node->args);
|
||||
}
|
||||
private function createClosure() : \PhpParser\Node\Expr\Closure
|
||||
{
|
||||
$stmts = $this->inlineCodeParser->parse(__DIR__ . '/../../snippet/array_is_list_closure.php.inc');
|
||||
/** @var Expression $expression */
|
||||
$expression = $stmts[0];
|
||||
$expr = $expression->expr;
|
||||
if (!$expr instanceof \PhpParser\Node\Expr\Closure) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
return $expr;
|
||||
}
|
||||
private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool
|
||||
{
|
||||
if (!$this->nodeNameResolver->isName($funcCall, 'array_is_list')) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->functionExistsFunCallAnalyzer->detect($funcCall, 'array_is_list')) {
|
||||
return \true;
|
||||
}
|
||||
$args = $funcCall->getArgs();
|
||||
return \count($args) !== 1;
|
||||
}
|
||||
}
|
18
rules/DowngradePhp81/snippet/array_is_list_closure.php.inc
Normal file
18
rules/DowngradePhp81/snippet/array_is_list_closure.php.inc
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
function (array $array) : bool {
|
||||
if (function_exists('array_is_list')) {
|
||||
return array_is_list($array);
|
||||
}
|
||||
if ($array === []) {
|
||||
return true;
|
||||
}
|
||||
$current_key = 0;
|
||||
foreach ($array as $key => $noop) {
|
||||
if ($key !== $current_key) {
|
||||
return false;
|
||||
}
|
||||
++$current_key;
|
||||
}
|
||||
return true;
|
||||
};
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '3b40197e1ea13da1b4acd86ea3d73e567c58f6a8';
|
||||
public const PACKAGE_VERSION = 'e077d7c3fb9cc4204857a80d587f23a75ddf6665';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-04-02 10:33:08';
|
||||
public const RELEASE_DATE = '2022-04-02 15:09:17';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220402\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit42105b12e820559d567df4e84540b182::getLoader();
|
||||
return ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2071,6 +2071,7 @@ return array(
|
||||
'Rector\\DowngradePhp81\\NodeManipulator\\ObjectToResourceReturn' => $baseDir . '/rules/DowngradePhp81/NodeManipulator/ObjectToResourceReturn.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\Array_\\DowngradeArraySpreadStringKeyRector' => $baseDir . '/rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\ClassConst\\DowngradeFinalizePublicClassConstantRector' => $baseDir . '/rules/DowngradePhp81/Rector/ClassConst/DowngradeFinalizePublicClassConstantRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FuncCall\\DowngradeArrayIsListRector' => $baseDir . '/rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FuncCall\\DowngradeFirstClassCallableSyntaxRector' => $baseDir . '/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FunctionLike\\DowngradeNeverTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNeverTypeDeclarationRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FunctionLike\\DowngradeNewInInitializerRector' => $baseDir . '/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.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 ComposerAutoloaderInit42105b12e820559d567df4e84540b182
|
||||
class ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInit42105b12e820559d567df4e84540b182
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit42105b12e820559d567df4e84540b182', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit42105b12e820559d567df4e84540b182', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
\Composer\Autoload\ComposerStaticInit42105b12e820559d567df4e84540b182::getInitializer($loader)();
|
||||
\Composer\Autoload\ComposerStaticInitaa8e843b8b9a56fae00580486a5711d3::getInitializer($loader)();
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit42105b12e820559d567df4e84540b182::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitaa8e843b8b9a56fae00580486a5711d3::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire42105b12e820559d567df4e84540b182($fileIdentifier, $file);
|
||||
composerRequireaa8e843b8b9a56fae00580486a5711d3($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInit42105b12e820559d567df4e84540b182
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire42105b12e820559d567df4e84540b182($fileIdentifier, $file)
|
||||
function composerRequireaa8e843b8b9a56fae00580486a5711d3($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit42105b12e820559d567df4e84540b182
|
||||
class ComposerStaticInitaa8e843b8b9a56fae00580486a5711d3
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@ -2440,6 +2440,7 @@ class ComposerStaticInit42105b12e820559d567df4e84540b182
|
||||
'Rector\\DowngradePhp81\\NodeManipulator\\ObjectToResourceReturn' => __DIR__ . '/../..' . '/rules/DowngradePhp81/NodeManipulator/ObjectToResourceReturn.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\Array_\\DowngradeArraySpreadStringKeyRector' => __DIR__ . '/../..' . '/rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\ClassConst\\DowngradeFinalizePublicClassConstantRector' => __DIR__ . '/../..' . '/rules/DowngradePhp81/Rector/ClassConst/DowngradeFinalizePublicClassConstantRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FuncCall\\DowngradeArrayIsListRector' => __DIR__ . '/../..' . '/rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FuncCall\\DowngradeFirstClassCallableSyntaxRector' => __DIR__ . '/../..' . '/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FunctionLike\\DowngradeNeverTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNeverTypeDeclarationRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\FunctionLike\\DowngradeNewInInitializerRector' => __DIR__ . '/../..' . '/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.php',
|
||||
@ -3838,9 +3839,9 @@ class ComposerStaticInit42105b12e820559d567df4e84540b182
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit42105b12e820559d567df4e84540b182::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit42105b12e820559d567df4e84540b182::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit42105b12e820559d567df4e84540b182::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitaa8e843b8b9a56fae00580486a5711d3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitaa8e843b8b9a56fae00580486a5711d3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitaa8e843b8b9a56fae00580486a5711d3::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
18
vendor/nette/utils/src/Utils/Arrays.php
vendored
18
vendor/nette/utils/src/Utils/Arrays.php
vendored
@ -190,7 +190,23 @@ class Arrays
|
||||
*/
|
||||
public static function isList($value) : bool
|
||||
{
|
||||
return \is_array($value) && (\PHP_VERSION_ID < 80100 ? !$value || \array_keys($value) === \range(0, \count($value) - 1) : array_is_list($value));
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
if (\function_exists('RectorPrefix20220402\\array_is_list')) {
|
||||
return array_is_list($array);
|
||||
}
|
||||
if ($array === []) {
|
||||
return \true;
|
||||
}
|
||||
$current_key = 0;
|
||||
foreach ($array as $key => $noop) {
|
||||
if ($key !== $current_key) {
|
||||
return \false;
|
||||
}
|
||||
++$current_key;
|
||||
}
|
||||
return \true;
|
||||
};
|
||||
return \is_array($value) && (\PHP_VERSION_ID < 80100 ? !$value || \array_keys($value) === \range(0, \count($value) - 1) : $arrayIsList($value));
|
||||
}
|
||||
/**
|
||||
* Reformats table to associative tree. Path looks like 'field|field[]field->field=field'.
|
||||
|
20
vendor/scoper-autoload.php
vendored
20
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('RectorPrefix20220402\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit42105b12e820559d567df4e84540b182', false) && !interface_exists('ComposerAutoloaderInit42105b12e820559d567df4e84540b182', false) && !trait_exists('ComposerAutoloaderInit42105b12e820559d567df4e84540b182', false)) {
|
||||
spl_autoload_call('RectorPrefix20220402\ComposerAutoloaderInit42105b12e820559d567df4e84540b182');
|
||||
if (!class_exists('ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3', false) && !interface_exists('ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3', false) && !trait_exists('ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3', false)) {
|
||||
spl_autoload_call('RectorPrefix20220402\ComposerAutoloaderInitaa8e843b8b9a56fae00580486a5711d3');
|
||||
}
|
||||
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('RectorPrefix20220402\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220402\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire42105b12e820559d567df4e84540b182')) {
|
||||
function composerRequire42105b12e820559d567df4e84540b182() {
|
||||
return \RectorPrefix20220402\composerRequire42105b12e820559d567df4e84540b182(...func_get_args());
|
||||
if (!function_exists('composerRequireaa8e843b8b9a56fae00580486a5711d3')) {
|
||||
function composerRequireaa8e843b8b9a56fae00580486a5711d3() {
|
||||
return \RectorPrefix20220402\composerRequireaa8e843b8b9a56fae00580486a5711d3(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
@ -74,6 +74,11 @@ if (!function_exists('lintFile')) {
|
||||
return \RectorPrefix20220402\lintFile(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('array_is_list')) {
|
||||
function array_is_list() {
|
||||
return \RectorPrefix20220402\array_is_list(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
function parseArgs() {
|
||||
return \RectorPrefix20220402\parseArgs(...func_get_args());
|
||||
@ -164,11 +169,6 @@ if (!function_exists('trigger_deprecation')) {
|
||||
return \RectorPrefix20220402\trigger_deprecation(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('array_is_list')) {
|
||||
function array_is_list() {
|
||||
return \RectorPrefix20220402\array_is_list(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('enum_exists')) {
|
||||
function enum_exists() {
|
||||
return \RectorPrefix20220402\enum_exists(...func_get_args());
|
||||
|
@ -182,7 +182,23 @@ class PrototypedArrayNode extends \RectorPrefix20220402\Symfony\Component\Config
|
||||
return $value;
|
||||
}
|
||||
$value = $this->remapXml($value);
|
||||
$isList = array_is_list($value);
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
if (\function_exists('RectorPrefix20220402\\array_is_list')) {
|
||||
return array_is_list($array);
|
||||
}
|
||||
if ($array === []) {
|
||||
return \true;
|
||||
}
|
||||
$current_key = 0;
|
||||
foreach ($array as $key => $noop) {
|
||||
if ($key !== $current_key) {
|
||||
return \false;
|
||||
}
|
||||
++$current_key;
|
||||
}
|
||||
return \true;
|
||||
};
|
||||
$isList = $arrayIsList($value);
|
||||
$normalized = [];
|
||||
foreach ($value as $k => $v) {
|
||||
if (null !== $this->keyAttribute && \is_array($v)) {
|
||||
@ -245,7 +261,23 @@ class PrototypedArrayNode extends \RectorPrefix20220402\Symfony\Component\Config
|
||||
if (\false === $leftSide || !$this->performDeepMerging) {
|
||||
return $rightSide;
|
||||
}
|
||||
$isList = array_is_list($rightSide);
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
if (\function_exists('RectorPrefix20220402\\array_is_list')) {
|
||||
return array_is_list($array);
|
||||
}
|
||||
if ($array === []) {
|
||||
return \true;
|
||||
}
|
||||
$current_key = 0;
|
||||
foreach ($array as $key => $noop) {
|
||||
if ($key !== $current_key) {
|
||||
return \false;
|
||||
}
|
||||
++$current_key;
|
||||
}
|
||||
return \true;
|
||||
};
|
||||
$isList = $arrayIsList($rightSide);
|
||||
foreach ($rightSide as $k => $v) {
|
||||
// prototype, and key is irrelevant there are no named keys, append the element
|
||||
if (null === $this->keyAttribute && $isList) {
|
||||
|
@ -229,7 +229,23 @@ class XmlDumper extends \RectorPrefix20220402\Symfony\Component\DependencyInject
|
||||
}
|
||||
private function convertParameters(array $parameters, string $type, \DOMElement $parent, string $keyAttribute = 'key')
|
||||
{
|
||||
$withKeys = !array_is_list($parameters);
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
if (\function_exists('RectorPrefix20220402\\array_is_list')) {
|
||||
return array_is_list($array);
|
||||
}
|
||||
if ($array === []) {
|
||||
return \true;
|
||||
}
|
||||
$current_key = 0;
|
||||
foreach ($array as $key => $noop) {
|
||||
if ($key !== $current_key) {
|
||||
return \false;
|
||||
}
|
||||
++$current_key;
|
||||
}
|
||||
return \true;
|
||||
};
|
||||
$withKeys = !$arrayIsList($parameters);
|
||||
foreach ($parameters as $key => $value) {
|
||||
$element = $this->document->createElement($type);
|
||||
if ($withKeys) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user