Updated Rector to commit 7ca5096c12deb3d0619bfcf3ed61b0b6e6737b35

7ca5096c12 [Php56] Skip already initialized on next Stmt on AddDefaultValueForUndefinedVariableRector (#2721)
This commit is contained in:
Tomas Votruba 2022-07-29 16:30:03 +00:00
parent 6420a4d2a1
commit 3bfd3cdb42
18 changed files with 111 additions and 76 deletions

View File

@ -91,18 +91,37 @@ CODE_SAMPLE
if ($this->inlineHTMLAnalyzer->hasInlineHTML($node)) {
return null;
}
if ($node->stmts === null) {
return null;
}
$undefinedVariableNames = $this->undefinedVariableResolver->resolve($node);
if ($undefinedVariableNames === []) {
return null;
}
$variablesInitiation = $this->collectVariablesInitiation($undefinedVariableNames, $node->stmts);
$node->stmts = \array_merge($variablesInitiation, $node->stmts);
return $node;
}
/**
* @param string[] $undefinedVariableNames
* @param Stmt[] $stmts
* @return Expression[]
*/
private function collectVariablesInitiation(array $undefinedVariableNames, array $stmts) : array
{
$variablesInitiation = [];
foreach ($undefinedVariableNames as $undefinedVariableName) {
$value = $this->isArray($undefinedVariableName, (array) $node->stmts) ? new Array_([]) : $this->nodeFactory->createNull();
$value = $this->isArray($undefinedVariableName, $stmts) ? new Array_([]) : $this->nodeFactory->createNull();
$assign = new Assign(new Variable($undefinedVariableName), $value);
$variablesInitiation[] = new Expression($assign);
$expresssion = new Expression($assign);
foreach ($stmts as $stmt) {
if ($this->nodeComparator->areNodesEqual($expresssion, $stmt)) {
continue 2;
}
}
$variablesInitiation[] = $expresssion;
}
$node->stmts = \array_merge($variablesInitiation, (array) $node->stmts);
return $node;
return $variablesInitiation;
}
/**
* @param Stmt[] $stmts

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ec291c4358636e29c026f2d42d575470cde25c76';
public const PACKAGE_VERSION = '7ca5096c12deb3d0619bfcf3ed61b0b6e6737b35';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-07-28 21:26:35';
public const RELEASE_DATE = '2022-07-29 18:24:58';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit630648f07d2397d4ddacbbdc1bf8455b::getLoader();
return ComposerAutoloaderInit1dd519eabd447a35f7109e57b5769e16::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit630648f07d2397d4ddacbbdc1bf8455b
class ComposerAutoloaderInit1dd519eabd447a35f7109e57b5769e16
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit630648f07d2397d4ddacbbdc1bf8455b
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit630648f07d2397d4ddacbbdc1bf8455b', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit1dd519eabd447a35f7109e57b5769e16', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit630648f07d2397d4ddacbbdc1bf8455b', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit1dd519eabd447a35f7109e57b5769e16', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit1dd519eabd447a35f7109e57b5769e16::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit1dd519eabd447a35f7109e57b5769e16::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire630648f07d2397d4ddacbbdc1bf8455b($fileIdentifier, $file);
composerRequire1dd519eabd447a35f7109e57b5769e16($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit630648f07d2397d4ddacbbdc1bf8455b
* @param string $file
* @return void
*/
function composerRequire630648f07d2397d4ddacbbdc1bf8455b($fileIdentifier, $file)
function composerRequire1dd519eabd447a35f7109e57b5769e16($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b
class ComposerStaticInit1dd519eabd447a35f7109e57b5769e16
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3407,9 +3407,9 @@ class ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit630648f07d2397d4ddacbbdc1bf8455b::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit1dd519eabd447a35f7109e57b5769e16::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1dd519eabd447a35f7109e57b5769e16::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1dd519eabd447a35f7109e57b5769e16::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2551,17 +2551,17 @@
},
{
"name": "symfony\/config",
"version": "v6.1.0",
"version_normalized": "6.1.0.0",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/config.git",
"reference": "ed8d12417bcacd2d969750feb1fe1aab1c11e613"
"reference": "a0645dc585d378b73c01115dd7ab9348f7d40c85"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/config\/zipball\/ed8d12417bcacd2d969750feb1fe1aab1c11e613",
"reference": "ed8d12417bcacd2d969750feb1fe1aab1c11e613",
"url": "https:\/\/api.github.com\/repos\/symfony\/config\/zipball\/a0645dc585d378b73c01115dd7ab9348f7d40c85",
"reference": "a0645dc585d378b73c01115dd7ab9348f7d40c85",
"shasum": ""
},
"require": {
@ -2583,7 +2583,7 @@
"suggest": {
"symfony\/yaml": "To use the yaml reference dumper"
},
"time": "2022-05-17T12:56:32+00:00",
"time": "2022-07-20T15:00:40+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2611,7 +2611,7 @@
"description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/config\/tree\/v6.1.0"
"source": "https:\/\/github.com\/symfony\/config\/tree\/v6.1.3"
},
"funding": [
{
@ -2631,17 +2631,17 @@
},
{
"name": "symfony\/console",
"version": "v6.1.2",
"version_normalized": "6.1.2.0",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/console.git",
"reference": "7a86c1c42fbcb69b59768504c7bca1d3767760b7"
"reference": "43fcb5c5966b43c56bcfa481368d90d748936ab8"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/7a86c1c42fbcb69b59768504c7bca1d3767760b7",
"reference": "7a86c1c42fbcb69b59768504c7bca1d3767760b7",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/43fcb5c5966b43c56bcfa481368d90d748936ab8",
"reference": "43fcb5c5966b43c56bcfa481368d90d748936ab8",
"shasum": ""
},
"require": {
@ -2676,7 +2676,7 @@
"symfony\/lock": "",
"symfony\/process": ""
},
"time": "2022-06-26T13:01:30+00:00",
"time": "2022-07-22T14:17:57+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2710,7 +2710,7 @@
"terminal"
],
"support": {
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.1.2"
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.1.3"
},
"funding": [
{
@ -2834,17 +2834,17 @@
},
{
"name": "symfony\/dependency-injection",
"version": "v6.1.2",
"version_normalized": "6.1.2.0",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/dependency-injection.git",
"reference": "5635ff016a814d7984b1c4644ad28e7df546077b"
"reference": "079e336a1880f457b219aecc3d41bef2f1093b0b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/5635ff016a814d7984b1c4644ad28e7df546077b",
"reference": "5635ff016a814d7984b1c4644ad28e7df546077b",
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/079e336a1880f457b219aecc3d41bef2f1093b0b",
"reference": "079e336a1880f457b219aecc3d41bef2f1093b0b",
"shasum": ""
},
"require": {
@ -2876,7 +2876,7 @@
"symfony\/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony\/yaml": ""
},
"time": "2022-06-26T13:01:30+00:00",
"time": "2022-07-20T13:46:29+00:00",
"type": "library",
"extra": {
"patches_applied": [
@ -2910,7 +2910,7 @@
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/dependency-injection\/tree\/v6.1.2"
"source": "https:\/\/github.com\/symfony\/dependency-injection\/tree\/v6.1.3"
},
"funding": [
{
@ -2930,17 +2930,17 @@
},
{
"name": "symfony\/filesystem",
"version": "v6.1.0",
"version_normalized": "6.1.0.0",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/filesystem.git",
"reference": "3132d2f43ca799c2aa099f9738d98228c56baa5d"
"reference": "c780e677cddda78417fa5187a7c6cd2f21110db9"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/3132d2f43ca799c2aa099f9738d98228c56baa5d",
"reference": "3132d2f43ca799c2aa099f9738d98228c56baa5d",
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/c780e677cddda78417fa5187a7c6cd2f21110db9",
"reference": "c780e677cddda78417fa5187a7c6cd2f21110db9",
"shasum": ""
},
"require": {
@ -2948,7 +2948,7 @@
"symfony\/polyfill-ctype": "~1.8",
"symfony\/polyfill-mbstring": "~1.8"
},
"time": "2022-05-21T13:34:40+00:00",
"time": "2022-07-20T14:45:06+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2976,7 +2976,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/filesystem\/tree\/v6.1.0"
"source": "https:\/\/github.com\/symfony\/filesystem\/tree\/v6.1.3"
},
"funding": [
{
@ -2996,17 +2996,17 @@
},
{
"name": "symfony\/finder",
"version": "v6.1.0",
"version_normalized": "6.1.0.0",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/finder.git",
"reference": "45b8beb69d6eb3b05a65689ebfd4222326773f8f"
"reference": "39696bff2c2970b3779a5cac7bf9f0b88fc2b709"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/finder\/zipball\/45b8beb69d6eb3b05a65689ebfd4222326773f8f",
"reference": "45b8beb69d6eb3b05a65689ebfd4222326773f8f",
"url": "https:\/\/api.github.com\/repos\/symfony\/finder\/zipball\/39696bff2c2970b3779a5cac7bf9f0b88fc2b709",
"reference": "39696bff2c2970b3779a5cac7bf9f0b88fc2b709",
"shasum": ""
},
"require": {
@ -3015,7 +3015,7 @@
"require-dev": {
"symfony\/filesystem": "^6.0"
},
"time": "2022-04-15T08:08:08+00:00",
"time": "2022-07-29T07:42:06+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -3043,7 +3043,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/finder\/tree\/v6.1.0"
"source": "https:\/\/github.com\/symfony\/finder\/tree\/v6.1.3"
},
"funding": [
{
@ -3236,17 +3236,17 @@
},
{
"name": "symfony\/string",
"version": "v6.1.2",
"version_normalized": "6.1.2.0",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/string.git",
"reference": "1903f2879875280c5af944625e8246d81c2f0604"
"reference": "f35241f45c30bcd9046af2bb200a7086f70e1d6b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/string\/zipball\/1903f2879875280c5af944625e8246d81c2f0604",
"reference": "1903f2879875280c5af944625e8246d81c2f0604",
"url": "https:\/\/api.github.com\/repos\/symfony\/string\/zipball\/f35241f45c30bcd9046af2bb200a7086f70e1d6b",
"reference": "f35241f45c30bcd9046af2bb200a7086f70e1d6b",
"shasum": ""
},
"require": {
@ -3265,7 +3265,7 @@
"symfony\/translation-contracts": "^2.0|^3.0",
"symfony\/var-exporter": "^5.4|^6.0"
},
"time": "2022-06-26T16:35:04+00:00",
"time": "2022-07-27T15:50:51+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -3304,7 +3304,7 @@
"utf8"
],
"support": {
"source": "https:\/\/github.com\/symfony\/string\/tree\/v6.1.2"
"source": "https:\/\/github.com\/symfony\/string\/tree\/v6.1.3"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -258,7 +258,7 @@ class Command
*
* @return int The command exit code
*
* @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}.
* @throws ExceptionInterface When input binding fails. Bypass this by calling {@link ignoreValidationErrors()}.
*
* @see setCode()
* @see execute()

View File

@ -60,13 +60,13 @@ final class CompleteCommand extends Command
{
try {
// uncomment when a bugfix or BC break has been introduced in the shell completion scripts
//$version = $input->getOption('symfony');
//if ($version && version_compare($version, 'x.y', '>=')) {
// $version = $input->getOption('symfony');
// if ($version && version_compare($version, 'x.y', '>=')) {
// $message = sprintf('Completion script version is not supported ("%s" given, ">=x.y" required).', $version);
// $this->log($message);
// $output->writeln($message.' Install the Symfony completion script again by using the "completion" command.');
// return 126;
//}
// }
$shell = $input->getOption('shell');
if (!$shell) {
throw new \RuntimeException('The "--shell" option must be set.');

View File

@ -13,9 +13,11 @@ _sf_{{ COMMAND_NAME }}() {
# for an alias, get the real script behind it
if [[ $(type -t $sf_cmd) == "alias" ]]; then
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
else
sf_cmd=$(type -p $sf_cmd)
fi
if [ ! -f "$sf_cmd" ]; then
if [ ! -x "$sf_cmd" ]; then
return 1
fi

View File

@ -391,16 +391,16 @@ class SymfonyStyle extends OutputStyle
$chars = \substr(\str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
if (!isset($chars[0])) {
$this->newLine();
//empty history, so we should start with a new line.
// empty history, so we should start with a new line.
return;
}
//Prepend new line for each non LF chars (This means no blank line was output before)
// Prepend new line for each non LF chars (This means no blank line was output before)
$this->newLine(2 - \substr_count($chars, "\n"));
}
private function autoPrependText() : void
{
$fetched = $this->bufferedOutput->fetch();
//Prepend new line if last char isn't EOL:
// Prepend new line if last char isn't EOL:
if (\substr_compare($fetched, "\n", -\strlen("\n")) !== 0) {
$this->newLine();
}

View File

@ -33,7 +33,7 @@ class Autowire
* @param string|null $service Service ID (ie "some.service")
* @param string|null $expression Expression (ie 'service("some.service").someMethod()')
*/
public function __construct(?string $value = null, ?string $service = null, ?string $expression = null)
public function __construct(string $value = null, string $service = null, string $expression = null)
{
if (!($service xor $expression xor null !== $value)) {
throw new LogicException('#[Autowire] attribute must declare exactly one of $service, $expression, or $value.');

View File

@ -30,6 +30,10 @@ class ProxyHelper
if (!$type) {
return null;
}
return self::getTypeHintForType($type, $r, $noBuiltin);
}
private static function getTypeHintForType(\ReflectionType $type, \ReflectionFunctionAbstract $r, bool $noBuiltin) : ?string
{
$types = [];
$glue = '|';
if ($type instanceof \ReflectionUnionType) {
@ -43,6 +47,14 @@ class ProxyHelper
return null;
}
foreach ($reflectionTypes as $type) {
if ($type instanceof \ReflectionIntersectionType) {
$typeHint = self::getTypeHintForType($type, $r, $noBuiltin);
if (null === $typeHint) {
return null;
}
$types[] = \sprintf('(%s)', $typeHint);
continue;
}
if ($type->isBuiltin()) {
if (!$noBuiltin) {
$types[] = $type->getName();

View File

@ -24,7 +24,7 @@ abstract class AbstractConfigurator
{
public const FACTORY = 'unknown';
/**
* @var callable(mixed, bool $allowService)|null
* @var callable(mixed, bool)|null
*/
public static $valuePreProcessor;
/** @internal

View File

@ -580,7 +580,7 @@ EOF;
});
$schema = '<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:include schemaLocation="file:///' . \str_replace('\\', '/', $tmpfile) . '" />
<xsd:include schemaLocation="file:///' . \rawurlencode(\str_replace('\\', '/', $tmpfile)) . '" />
</xsd:schema>';
\file_put_contents($tmpfile, '<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

View File

@ -26,7 +26,7 @@ class SortableIterator implements \IteratorAggregate
public const SORT_BY_CHANGED_TIME = 4;
public const SORT_BY_MODIFIED_TIME = 5;
public const SORT_BY_NAME_NATURAL = 6;
/** @var \Traversable<string, \SplFileInfo> $iterator */
/** @var \Traversable<string, \SplFileInfo> */
private $iterator;
/**
* @var \Closure|int

View File

@ -444,8 +444,10 @@ abstract class AbstractUnicodeString extends AbstractString
| [\\x41-\\x7E]
)|[\\p{Cc}\\x7F]++)/xu', '', $s);
}
// Non printable characters have been dropped, so wcswidth cannot logically return -1.
$width += $this->wcswidth($s);
$lineWidth = $this->wcswidth($s);
if ($lineWidth > $width) {
$width = $lineWidth;
}
}
return $width;
}

View File

@ -81,7 +81,7 @@ final class FrenchInflector implements InflectorInterface
['/^Mes(dame|demoiselle)s$/', 'RectorPrefix202207\\Ma\\1'],
['/^mes(sieur|seigneur)s$/', 'RectorPrefix202207\\mon\\1'],
['/^Mes(sieur|seigneur)s$/', 'RectorPrefix202207\\Mon\\1'],
//Default rule
// Default rule
['/s$/i', ''],
];
/**