mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-06 19:30:50 +00:00
Updated Rector to commit 685fe90cb8752c2a288ee982d03d15d8df6b59f2
685fe90cb8
Make SimplifyUselessVariableRector run without scope (#4791)
This commit is contained in:
parent
8216388351
commit
5b1b83ed61
|
@ -11,21 +11,19 @@ use PhpParser\Node\Expr\Variable;
|
|||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\FunctionReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\Core\NodeAnalyzer\CallAnalyzer;
|
||||
use Rector\Core\NodeAnalyzer\VariableAnalyzer;
|
||||
use Rector\Core\PhpParser\Node\AssignAndBinaryMap;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector\SimplifyUselessVariableRectorTest
|
||||
*/
|
||||
final class SimplifyUselessVariableRector extends AbstractScopeAwareRector
|
||||
final class SimplifyUselessVariableRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
|
@ -73,7 +71,7 @@ CODE_SAMPLE
|
|||
/**
|
||||
* @param StmtsAwareInterface $node
|
||||
*/
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$stmts = $node->stmts;
|
||||
if ($stmts === null) {
|
||||
|
@ -88,7 +86,7 @@ CODE_SAMPLE
|
|||
continue;
|
||||
}
|
||||
$previousStmt = $stmts[$key - 1];
|
||||
if ($this->shouldSkipStmt($stmt, $previousStmt, $scope)) {
|
||||
if ($this->shouldSkipStmt($stmt, $previousStmt)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->hasSomeComment($previousStmt)) {
|
||||
|
@ -120,15 +118,11 @@ CODE_SAMPLE
|
|||
unset($stmtsAware->stmts[$key - 1]);
|
||||
return $stmtsAware;
|
||||
}
|
||||
private function shouldSkipStmt(Return_ $return, Stmt $previousStmt, Scope $scope) : bool
|
||||
private function shouldSkipStmt(Return_ $return, Stmt $previousStmt) : bool
|
||||
{
|
||||
if (!$return->expr instanceof Variable) {
|
||||
return \true;
|
||||
}
|
||||
$functionReflection = $scope->getFunction();
|
||||
if ($functionReflection instanceof FunctionReflection && $functionReflection->returnsByReference()->yes()) {
|
||||
return \true;
|
||||
}
|
||||
if ($return->getAttribute(AttributeKey::IS_BYREF_RETURN) === \true) {
|
||||
return \true;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '2fe68ad7649faf0ebec883dcdeb91ee6118297ce';
|
||||
public const PACKAGE_VERSION = '685fe90cb8752c2a288ee982d03d15d8df6b59f2';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-14 13:42:14';
|
||||
public const RELEASE_DATE = '2023-08-14 15:27:05';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -44,7 +44,7 @@ final class SimpleParameterProvider
|
|||
{
|
||||
$parameter = self::$parameters[$name] ?? [];
|
||||
Assert::isArray($parameter);
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ final class SimpleParameterProvider
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
if ($arrayIsList($parameter)) {
|
||||
if ($arrayIsListFunction($parameter)) {
|
||||
// remove duplicates
|
||||
$uniqueParameters = \array_unique($parameter);
|
||||
return \array_values($uniqueParameters);
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a::getLoader();
|
||||
return ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239::getLoader();
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a
|
||||
class ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitef003b203866411843a8ebe2ebc6e04a
|
||||
class ComposerStaticInit9c580ee581ac8dff49b345ac114fb239
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2959,9 +2959,9 @@ class ComposerStaticInitef003b203866411843a8ebe2ebc6e04a
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -1917,12 +1917,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "47f72d5d2b747a73cf30bee2c798dc9cf21e3411"
|
||||
"reference": "51f273773c748e34c3418cdc569992b5de00128f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/47f72d5d2b747a73cf30bee2c798dc9cf21e3411",
|
||||
"reference": "47f72d5d2b747a73cf30bee2c798dc9cf21e3411",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/51f273773c748e34c3418cdc569992b5de00128f",
|
||||
"reference": "51f273773c748e34c3418cdc569992b5de00128f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1948,7 +1948,7 @@
|
|||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-08-13T11:39:42+00:00",
|
||||
"time": "2023-08-14T14:00:50+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
4
vendor/nette/utils/src/Utils/Arrays.php
vendored
4
vendor/nette/utils/src/Utils/Arrays.php
vendored
|
@ -198,7 +198,7 @@ class Arrays
|
|||
*/
|
||||
public static function isList($value) : bool
|
||||
{
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ class Arrays
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
return is_array($value) && (\PHP_VERSION_ID < 80100 ? !$value || \array_keys($value) === \range(0, count($value) - 1) : $arrayIsList($value));
|
||||
return is_array($value) && (\PHP_VERSION_ID < 80100 ? !$value || \array_keys($value) === \range(0, count($value) - 1) : $arrayIsListFunction($value));
|
||||
}
|
||||
/**
|
||||
* Reformats table to associative tree. Path looks like 'field|field[]field->field=field'.
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0b976ae'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 47f72d5'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f2571b8'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 23bb522'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0b976ae'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 51f2737'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f2571b8'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 23bb522'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ use PHPStan\Analyser\Scope;
|
|||
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Parser\InlineCodeParser;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeAnalyzer\ExprInTopStmtMatcher;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -28,18 +27,13 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
*
|
||||
* @see \Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector\DowngradeArrayIsListRectorTest
|
||||
*/
|
||||
final class DowngradeArrayIsListRector extends AbstractScopeAwareRector
|
||||
final class DowngradeArrayIsListRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Parser\InlineCodeParser
|
||||
*/
|
||||
private $inlineCodeParser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\VariableNaming
|
||||
*/
|
||||
private $variableNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeAnalyzer\ExprInTopStmtMatcher
|
||||
|
@ -49,10 +43,9 @@ final class DowngradeArrayIsListRector extends AbstractScopeAwareRector
|
|||
* @var \PhpParser\Node\Expr\Closure|null
|
||||
*/
|
||||
private $cachedClosure;
|
||||
public function __construct(InlineCodeParser $inlineCodeParser, VariableNaming $variableNaming, ExprInTopStmtMatcher $exprInTopStmtMatcher)
|
||||
public function __construct(InlineCodeParser $inlineCodeParser, ExprInTopStmtMatcher $exprInTopStmtMatcher)
|
||||
{
|
||||
$this->inlineCodeParser = $inlineCodeParser;
|
||||
$this->variableNaming = $variableNaming;
|
||||
$this->exprInTopStmtMatcher = $exprInTopStmtMatcher;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
|
@ -95,20 +88,19 @@ CODE_SAMPLE
|
|||
* @param StmtsAwareInterface|Switch_|Return_|Expression|Echo_ $node
|
||||
* @return Node[]|null
|
||||
*/
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?array
|
||||
public function refactor(Node $node) : ?array
|
||||
{
|
||||
$expr = $this->exprInTopStmtMatcher->match($node, function (Node $subNode) : bool {
|
||||
if (!$subNode instanceof FuncCall) {
|
||||
return \false;
|
||||
}
|
||||
// need pull Scope from target traversed sub Node
|
||||
$scope = $subNode->getAttribute(AttributeKey::SCOPE);
|
||||
return !$this->shouldSkip($subNode, $scope);
|
||||
return !$this->shouldSkip($subNode);
|
||||
});
|
||||
if (!$expr instanceof FuncCall) {
|
||||
return null;
|
||||
}
|
||||
$variable = new Variable($this->variableNaming->createCountedValueName('arrayIsList', $scope));
|
||||
$variable = new Variable('arrayIsListFunction');
|
||||
$function = $this->createClosure();
|
||||
$expression = new Expression(new Assign($variable, $function));
|
||||
$expr->name = $variable;
|
||||
|
@ -129,7 +121,7 @@ CODE_SAMPLE
|
|||
$this->cachedClosure = $expr;
|
||||
return $expr;
|
||||
}
|
||||
private function shouldSkip(CallLike $callLike, ?Scope $scope) : bool
|
||||
private function shouldSkip(CallLike $callLike) : bool
|
||||
{
|
||||
if (!$callLike instanceof FuncCall) {
|
||||
return \false;
|
||||
|
@ -137,11 +129,8 @@ CODE_SAMPLE
|
|||
if (!$this->nodeNameResolver->isName($callLike, 'array_is_list')) {
|
||||
return \true;
|
||||
}
|
||||
if (!$scope instanceof Scope) {
|
||||
$args = $callLike->getArgs();
|
||||
return \count($args) !== 1;
|
||||
}
|
||||
if ($scope->isInFunctionExists('array_is_list')) {
|
||||
$scope = $callLike->getAttribute(AttributeKey::SCOPE);
|
||||
if ($scope instanceof Scope && $scope->isInFunctionExists('array_is_list')) {
|
||||
return \true;
|
||||
}
|
||||
$args = $callLike->getArgs();
|
||||
|
|
|
@ -168,7 +168,7 @@ class YamlReferenceDumper
|
|||
}
|
||||
private function writeArray(array $array, int $depth) : void
|
||||
{
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class YamlReferenceDumper
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
$isIndexed = $arrayIsList($array);
|
||||
$isIndexed = $arrayIsListFunction($array);
|
||||
foreach ($array as $key => $value) {
|
||||
if (\is_array($value)) {
|
||||
$val = '';
|
||||
|
|
|
@ -186,7 +186,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||
return $value;
|
||||
}
|
||||
$value = $this->remapXml($value);
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
$isList = $arrayIsList($value);
|
||||
$isList = $arrayIsListFunction($value);
|
||||
$normalized = [];
|
||||
foreach ($value as $k => $v) {
|
||||
if (null !== $this->keyAttribute && \is_array($v)) {
|
||||
|
@ -264,7 +264,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||
if (\false === $leftSide || !$this->performDeepMerging) {
|
||||
return $rightSide;
|
||||
}
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
$isList = $arrayIsList($rightSide);
|
||||
$isList = $arrayIsListFunction($rightSide);
|
||||
foreach ($rightSide as $k => $v) {
|
||||
// prototype, and key is irrelevant there are no named keys, append the element
|
||||
if (null === $this->keyAttribute && $isList) {
|
||||
|
|
|
@ -94,7 +94,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
|
|||
}
|
||||
if ($resolvedArguments !== $call[1]) {
|
||||
\ksort($resolvedArguments);
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
if (!$value->isAutowired() && !$arrayIsList($resolvedArguments)) {
|
||||
if (!$value->isAutowired() && !$arrayIsListFunction($resolvedArguments)) {
|
||||
\ksort($resolvedKeys);
|
||||
$resolvedArguments = \array_combine($resolvedKeys, $resolvedArguments);
|
||||
}
|
||||
|
|
|
@ -881,7 +881,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
if (null !== $id && $definition->isShared() && (isset($this->services[$id]) || isset($this->privates[$id])) && ($tryProxy || !$definition->isLazy())) {
|
||||
return $this->services[$id] ?? $this->privates[$id];
|
||||
}
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -897,7 +897,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
if (!$arrayIsList($arguments)) {
|
||||
if (!$arrayIsListFunction($arguments)) {
|
||||
$arguments = \array_combine(\array_map(function ($k) {
|
||||
return \preg_replace('/^.*\\$/', '', $k);
|
||||
}, \array_keys($arguments)), $arguments);
|
||||
|
|
|
@ -229,7 +229,7 @@ class XmlDumper extends Dumper
|
|||
}
|
||||
private function convertParameters(array $parameters, string $type, \DOMElement $parent, string $keyAttribute = 'key')
|
||||
{
|
||||
$arrayIsList = function (array $array) : bool {
|
||||
$arrayIsListFunction = function (array $array) : bool {
|
||||
if (\function_exists('array_is_list')) {
|
||||
return \array_is_list($array);
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ class XmlDumper extends Dumper
|
|||
}
|
||||
return \true;
|
||||
};
|
||||
$withKeys = !$arrayIsList($parameters);
|
||||
$withKeys = !$arrayIsListFunction($parameters);
|
||||
foreach ($parameters as $key => $value) {
|
||||
$element = $this->document->createElement($type);
|
||||
if ($withKeys) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user