Updated Rector to commit 7648780936ffae358b4f79230923ee61dde30e14

7648780936 Use Symfony 6.1 to avoid BC break now (#3142)
This commit is contained in:
Tomas Votruba 2022-12-02 14:00:07 +00:00
parent 9181dd5876
commit 91e646a878
110 changed files with 415 additions and 3298 deletions

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '076642f73eee5814a096552c33b28740fbbd48ce';
public const PACKAGE_VERSION = '7648780936ffae358b4f79230923ee61dde30e14';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-12-02 13:12:19';
public const RELEASE_DATE = '2022-12-02 13:55:14';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -895,10 +895,8 @@ return array(
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Extension\\ExtensionTrait' => $vendorDir . '/symfony/dependency-injection/Extension/ExtensionTrait.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Extension\\PrependExtensionInterface' => $vendorDir . '/symfony/dependency-injection/Extension/PrependExtensionInterface.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\InstantiatorInterface' => $vendorDir . '/symfony/dependency-injection/LazyProxy/Instantiator/InstantiatorInterface.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\LazyServiceInstantiator' => $vendorDir . '/symfony/dependency-injection/LazyProxy/Instantiator/LazyServiceInstantiator.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\RealServiceInstantiator' => $vendorDir . '/symfony/dependency-injection/LazyProxy/Instantiator/RealServiceInstantiator.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\PhpDumper\\DumperInterface' => $vendorDir . '/symfony/dependency-injection/LazyProxy/PhpDumper/DumperInterface.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\PhpDumper\\LazyServiceDumper' => $vendorDir . '/symfony/dependency-injection/LazyProxy/PhpDumper/LazyServiceDumper.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\PhpDumper\\NullDumper' => $vendorDir . '/symfony/dependency-injection/LazyProxy/PhpDumper/NullDumper.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\ProxyHelper' => $vendorDir . '/symfony/dependency-injection/LazyProxy/ProxyHelper.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Loader\\ClosureLoader' => $vendorDir . '/symfony/dependency-injection/Loader/ClosureLoader.php',
@ -1000,24 +998,6 @@ return array(
'RectorPrefix202212\\Symfony\\Component\\String\\Slugger\\AsciiSlugger' => $vendorDir . '/symfony/string/Slugger/AsciiSlugger.php',
'RectorPrefix202212\\Symfony\\Component\\String\\Slugger\\SluggerInterface' => $vendorDir . '/symfony/string/Slugger/SluggerInterface.php',
'RectorPrefix202212\\Symfony\\Component\\String\\UnicodeString' => $vendorDir . '/symfony/string/UnicodeString.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\ClassNotFoundException' => $vendorDir . '/symfony/var-exporter/Exception/ClassNotFoundException.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/var-exporter/Exception/ExceptionInterface.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\LogicException' => $vendorDir . '/symfony/var-exporter/Exception/LogicException.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\NotInstantiableTypeException' => $vendorDir . '/symfony/var-exporter/Exception/NotInstantiableTypeException.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Hydrator' => $vendorDir . '/symfony/var-exporter/Hydrator.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Instantiator' => $vendorDir . '/symfony/var-exporter/Instantiator.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Exporter' => $vendorDir . '/symfony/var-exporter/Internal/Exporter.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Hydrator' => $vendorDir . '/symfony/var-exporter/Internal/Hydrator.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\LazyObjectRegistry' => $vendorDir . '/symfony/var-exporter/Internal/LazyObjectRegistry.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\LazyObjectState' => $vendorDir . '/symfony/var-exporter/Internal/LazyObjectState.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Reference' => $vendorDir . '/symfony/var-exporter/Internal/Reference.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Registry' => $vendorDir . '/symfony/var-exporter/Internal/Registry.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Values' => $vendorDir . '/symfony/var-exporter/Internal/Values.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\LazyGhostTrait' => $vendorDir . '/symfony/var-exporter/LazyGhostTrait.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\LazyObjectInterface' => $vendorDir . '/symfony/var-exporter/LazyObjectInterface.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\LazyProxyTrait' => $vendorDir . '/symfony/var-exporter/LazyProxyTrait.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\ProxyHelper' => $vendorDir . '/symfony/var-exporter/ProxyHelper.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\VarExporter' => $vendorDir . '/symfony/var-exporter/VarExporter.php',
'RectorPrefix202212\\Symfony\\Contracts\\Cache\\CacheInterface' => $vendorDir . '/symfony/contracts/Cache/CacheInterface.php',
'RectorPrefix202212\\Symfony\\Contracts\\Cache\\CacheTrait' => $vendorDir . '/symfony/contracts/Cache/CacheTrait.php',
'RectorPrefix202212\\Symfony\\Contracts\\Cache\\CallbackInterface' => $vendorDir . '/symfony/contracts/Cache/CallbackInterface.php',

View File

@ -21,7 +21,6 @@ return array(
'RectorPrefix202212\\Symplify\\EasyParallel\\' => array($vendorDir . '/symplify/easy-parallel/src'),
'RectorPrefix202212\\Symplify\\AutowireArrayParameter\\' => array($vendorDir . '/symplify/autowire-array-parameter/src'),
'RectorPrefix202212\\Symfony\\Contracts\\' => array($vendorDir . '/symfony/contracts'),
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'),
'RectorPrefix202212\\Symfony\\Component\\String\\' => array($vendorDir . '/symfony/string'),
'RectorPrefix202212\\Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
'RectorPrefix202212\\Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642
class ComposerAutoloaderInit9a66746bbab502cbaede3783e4f6aad3
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit9a66746bbab502cbaede3783e4f6aad3', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit9a66746bbab502cbaede3783e4f6aad3', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit9a66746bbab502cbaede3783e4f6aad3::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit9a66746bbab502cbaede3783e4f6aad3::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirebf8a8e464cc895d60afec03925ee6642($fileIdentifier, $file);
composerRequire9a66746bbab502cbaede3783e4f6aad3($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitbf8a8e464cc895d60afec03925ee6642
* @param string $file
* @return void
*/
function composerRequirebf8a8e464cc895d60afec03925ee6642($fileIdentifier, $file)
function composerRequire9a66746bbab502cbaede3783e4f6aad3($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 ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
class ComposerStaticInit9a66746bbab502cbaede3783e4f6aad3
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -38,7 +38,6 @@ class ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
'RectorPrefix202212\\Symplify\\EasyParallel\\' => 41,
'RectorPrefix202212\\Symplify\\AutowireArrayParameter\\' => 51,
'RectorPrefix202212\\Symfony\\Contracts\\' => 37,
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\' => 49,
'RectorPrefix202212\\Symfony\\Component\\String\\' => 44,
'RectorPrefix202212\\Symfony\\Component\\Finder\\' => 44,
'RectorPrefix202212\\Symfony\\Component\\Filesystem\\' => 48,
@ -137,10 +136,6 @@ class ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
array (
0 => __DIR__ . '/..' . '/symfony/contracts',
),
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/var-exporter',
),
'RectorPrefix202212\\Symfony\\Component\\String\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/string',
@ -1145,10 +1140,8 @@ class ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Extension\\ExtensionTrait' => __DIR__ . '/..' . '/symfony/dependency-injection/Extension/ExtensionTrait.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Extension\\PrependExtensionInterface' => __DIR__ . '/..' . '/symfony/dependency-injection/Extension/PrependExtensionInterface.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\InstantiatorInterface' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/Instantiator/InstantiatorInterface.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\LazyServiceInstantiator' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/Instantiator/LazyServiceInstantiator.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\RealServiceInstantiator' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/Instantiator/RealServiceInstantiator.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\PhpDumper\\DumperInterface' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/PhpDumper/DumperInterface.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\PhpDumper\\LazyServiceDumper' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/PhpDumper/LazyServiceDumper.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\PhpDumper\\NullDumper' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/PhpDumper/NullDumper.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\LazyProxy\\ProxyHelper' => __DIR__ . '/..' . '/symfony/dependency-injection/LazyProxy/ProxyHelper.php',
'RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Loader\\ClosureLoader' => __DIR__ . '/..' . '/symfony/dependency-injection/Loader/ClosureLoader.php',
@ -1250,24 +1243,6 @@ class ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
'RectorPrefix202212\\Symfony\\Component\\String\\Slugger\\AsciiSlugger' => __DIR__ . '/..' . '/symfony/string/Slugger/AsciiSlugger.php',
'RectorPrefix202212\\Symfony\\Component\\String\\Slugger\\SluggerInterface' => __DIR__ . '/..' . '/symfony/string/Slugger/SluggerInterface.php',
'RectorPrefix202212\\Symfony\\Component\\String\\UnicodeString' => __DIR__ . '/..' . '/symfony/string/UnicodeString.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\ClassNotFoundException' => __DIR__ . '/..' . '/symfony/var-exporter/Exception/ClassNotFoundException.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/var-exporter/Exception/ExceptionInterface.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\LogicException' => __DIR__ . '/..' . '/symfony/var-exporter/Exception/LogicException.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Exception\\NotInstantiableTypeException' => __DIR__ . '/..' . '/symfony/var-exporter/Exception/NotInstantiableTypeException.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Hydrator' => __DIR__ . '/..' . '/symfony/var-exporter/Hydrator.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Instantiator' => __DIR__ . '/..' . '/symfony/var-exporter/Instantiator.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Exporter' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/Exporter.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Hydrator' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/Hydrator.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\LazyObjectRegistry' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/LazyObjectRegistry.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\LazyObjectState' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/LazyObjectState.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Reference' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/Reference.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Registry' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/Registry.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\Internal\\Values' => __DIR__ . '/..' . '/symfony/var-exporter/Internal/Values.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\LazyGhostTrait' => __DIR__ . '/..' . '/symfony/var-exporter/LazyGhostTrait.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\LazyObjectInterface' => __DIR__ . '/..' . '/symfony/var-exporter/LazyObjectInterface.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\LazyProxyTrait' => __DIR__ . '/..' . '/symfony/var-exporter/LazyProxyTrait.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\ProxyHelper' => __DIR__ . '/..' . '/symfony/var-exporter/ProxyHelper.php',
'RectorPrefix202212\\Symfony\\Component\\VarExporter\\VarExporter' => __DIR__ . '/..' . '/symfony/var-exporter/VarExporter.php',
'RectorPrefix202212\\Symfony\\Contracts\\Cache\\CacheInterface' => __DIR__ . '/..' . '/symfony/contracts/Cache/CacheInterface.php',
'RectorPrefix202212\\Symfony\\Contracts\\Cache\\CacheTrait' => __DIR__ . '/..' . '/symfony/contracts/Cache/CacheTrait.php',
'RectorPrefix202212\\Symfony\\Contracts\\Cache\\CallbackInterface' => __DIR__ . '/..' . '/symfony/contracts/Cache/CallbackInterface.php',
@ -3047,9 +3022,9 @@ class ComposerStaticInitbf8a8e464cc895d60afec03925ee6642
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbf8a8e464cc895d60afec03925ee6642::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit9a66746bbab502cbaede3783e4f6aad3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9a66746bbab502cbaede3783e4f6aad3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9a66746bbab502cbaede3783e4f6aad3::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1849,12 +1849,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "24f2eaebcf6e0ea5ebe2842c212a98b6dfd2d449"
"reference": "d441dba05b3850868d231c0681b5beb9287907d3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/24f2eaebcf6e0ea5ebe2842c212a98b6dfd2d449",
"reference": "24f2eaebcf6e0ea5ebe2842c212a98b6dfd2d449",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/d441dba05b3850868d231c0681b5beb9287907d3",
"reference": "d441dba05b3850868d231c0681b5beb9287907d3",
"shasum": ""
},
"require": {
@ -1880,7 +1880,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-12-02T12:35:58+00:00",
"time": "2022-12-02T13:43:11+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2478,31 +2478,30 @@
},
{
"name": "symfony\/dependency-injection",
"version": "v6.2.0",
"version_normalized": "6.2.0.0",
"version": "v6.1.8",
"version_normalized": "6.1.8.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/dependency-injection.git",
"reference": "bb328032f400961be5db5aed87fac9742b506f80"
"reference": "11e33ed84db0ced77511a23b35168db127909f0e"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/bb328032f400961be5db5aed87fac9742b506f80",
"reference": "bb328032f400961be5db5aed87fac9742b506f80",
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/11e33ed84db0ced77511a23b35168db127909f0e",
"reference": "11e33ed84db0ced77511a23b35168db127909f0e",
"shasum": ""
},
"require": {
"php": ">=8.1",
"psr\/container": "^1.1|^2.0",
"symfony\/deprecation-contracts": "^2.1|^3",
"symfony\/service-contracts": "^1.1.6|^2.0|^3.0",
"symfony\/var-exporter": "^6.2"
"symfony\/service-contracts": "^1.1.6|^2.0|^3.0"
},
"conflict": {
"ext-psr": "<1.1|>=2",
"symfony\/config": "<6.1",
"symfony\/finder": "<5.4",
"symfony\/proxy-manager-bridge": "<6.2",
"symfony\/proxy-manager-bridge": "<5.4",
"symfony\/yaml": "<5.4"
},
"provide": {
@ -2521,12 +2520,12 @@
"symfony\/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony\/yaml": ""
},
"time": "2022-11-25T07:37:13+00:00",
"time": "2022-11-25T07:34:52+00:00",
"type": "library",
"extra": {
"patches_applied": [
"https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/symfony-dependency-injection.patch",
"https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/symfony-dependency-injection-loader-phpfileloader-php.patch"
"https:\/\/raw.githubusercontent.com\/symplify\/vendor-patch-files\/main\/patches\/generic-php-config-loader.patch",
"https:\/\/raw.githubusercontent.com\/rectorphp\/vendor-patches\/main\/patches\/symfony-dependency-injection.patch"
]
},
"installation-source": "dist",
@ -2555,7 +2554,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.2.0"
"source": "https:\/\/github.com\/symfony\/dependency-injection\/tree\/v6.1.8"
},
"funding": [
{
@ -2968,83 +2967,6 @@
],
"install-path": "..\/symfony\/string"
},
{
"name": "symfony\/var-exporter",
"version": "v6.2.0",
"version_normalized": "6.2.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/var-exporter.git",
"reference": "0437f26ca0c648071cc15ddacd26152cc65f4cd6"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/var-exporter\/zipball\/0437f26ca0c648071cc15ddacd26152cc65f4cd6",
"reference": "0437f26ca0c648071cc15ddacd26152cc65f4cd6",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"require-dev": {
"symfony\/var-dumper": "^5.4|^6.0"
},
"time": "2022-11-25T08:33:31+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"RectorPrefix202212\\Symfony\\Component\\VarExporter\\": ""
},
"exclude-from-classmap": [
"\/Tests\/"
]
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https:\/\/symfony.com\/contributors"
}
],
"description": "Allows exporting any serializable PHP data structure to plain PHP code",
"homepage": "https:\/\/symfony.com",
"keywords": [
"clone",
"construct",
"export",
"hydrate",
"instantiate",
"lazy loading",
"proxy",
"serialize"
],
"support": {
"source": "https:\/\/github.com\/symfony\/var-exporter\/tree\/v6.2.0"
},
"funding": [
{
"url": "https:\/\/symfony.com\/sponsor",
"type": "custom"
},
{
"url": "https:\/\/github.com\/fabpot",
"type": "github"
},
{
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/symfony\/symfony",
"type": "tidelift"
}
],
"install-path": "..\/symfony\/var-exporter"
},
{
"name": "symplify\/autowire-array-parameter",
"version": "11.1.17",

File diff suppressed because one or more lines are too long

View File

@ -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 bf394ee'), '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 24f2eae'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 e646c56'), '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 caa1373'));
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 bf394ee'), '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 d441dba'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 e646c56'), '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 caa1373'));
private function __construct()
{
}

View File

@ -95,7 +95,7 @@ CODE_SAMPLE
$node->args[0] = new Arg($variable);
}
$implode = $this->nodeFactory->createFuncCall('implode', [new String_(' '), $variable]);
$this->nodesToAddCollector->addNodeBeforeNode(new If_($this->nodeFactory->createFuncCall('is_array', [$args[0]->value]), ['stmts' => [new Expression(new Assign($variable, $implode))]]), $currentStmt);
$this->nodesToAddCollector->addNodeBeforeNode(new If_($this->nodeFactory->createFuncCall('is_array', [$variable]), ['stmts' => [new Expression(new Assign($variable, $implode))]]), $currentStmt);
return $node;
}
}

View File

@ -56,10 +56,16 @@ final class BoundArgument implements ArgumentInterface
$this->type = $type;
$this->file = $file;
}
/**
* {@inheritdoc}
*/
public function getValues() : array
{
return [$this->value, $this->identifier, $this->used, $this->type, $this->file];
}
/**
* {@inheritdoc}
*/
public function setValues(array $values)
{
if (5 === \count($values)) {

View File

@ -29,10 +29,16 @@ class ServiceClosureArgument implements ArgumentInterface
{
$this->values = [$value];
}
/**
* {@inheritdoc}
*/
public function getValues() : array
{
return $this->values;
}
/**
* {@inheritdoc}
*/
public function setValues(array $values)
{
if ([0] !== \array_keys($values)) {

View File

@ -38,6 +38,7 @@ class ServiceLocator extends BaseServiceLocator
parent::__construct($serviceMap);
}
/**
* {@inheritdoc}
* @return mixed
*/
public function get(string $id)
@ -51,6 +52,9 @@ class ServiceLocator extends BaseServiceLocator
return ($this->factory)(...$this->serviceMap[$id]);
}
}
/**
* {@inheritdoc}
*/
public function getProvidedServices() : array
{
return $this->serviceTypes = $this->serviceTypes ?? \array_map(function () {

View File

@ -23,22 +23,22 @@ class Autowire
{
/**
* @readonly
* @var string|mixed[]|\Symfony\Component\ExpressionLanguage\Expression|\Symfony\Component\DependencyInjection\Reference
* @var string|\Symfony\Component\ExpressionLanguage\Expression|\Symfony\Component\DependencyInjection\Reference
*/
public $value;
/**
* Use only ONE of the following.
*
* @param string|mixed[] $value Parameter value (ie "%kernel.project_dir%/some/path")
* @param string|null $value Parameter value (ie "%kernel.project_dir%/some/path")
* @param string|null $service Service ID (ie "some.service")
* @param string|null $expression Expression (ie 'service("some.service").someMethod()')
*/
public function __construct($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.');
}
if (\is_string($value) && \strncmp($value, '@', \strlen('@')) === 0) {
if (null !== $value && \strncmp($value, '@', \strlen('@')) === 0) {
switch (\true) {
case \strncmp($value, '@@', \strlen('@@')) === 0:
$value = \substr($value, 1);

View File

@ -1,20 +1,6 @@
CHANGELOG
=========
6.2
---
* Use lazy-loading ghost objects and virtual proxies out of the box
* Add arguments `&$asGhostObject` and `$id` to LazyProxy's `DumperInterface` to allow using ghost objects for lazy loading services
* Add `enum` env var processor
* Add `shuffle` env var processor
* Allow #[When] to be extended
* Change the signature of `ContainerAwareInterface::setContainer()` to `setContainer(?ContainerInterface)`
* Deprecate calling `ContainerAwareTrait::setContainer()` without arguments
* Deprecate using numeric parameter names
* Add support for tagged iterators/locators `exclude` option to the xml and yaml loaders/dumpers
* Allow injecting `string $env` into php config closures
6.1
---

View File

@ -41,6 +41,9 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
* @var bool
*/
private $inExpression = \false;
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$this->container = $container;
@ -73,9 +76,6 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
if (\is_array($value)) {
foreach ($value as $k => $v) {
if ($isRoot) {
if ($v->hasTag('container.excluded')) {
continue;
}
$this->currentId = $k;
}
if ($v !== ($processedValue = $this->processValue($v, $isRoot))) {
@ -143,8 +143,8 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
}
} elseif ($class instanceof Definition) {
$class = $class->getClass();
} else {
$class = $class ?? $definition->getClass();
} elseif (null === $class) {
$class = $definition->getClass();
}
return $this->getReflectionMethod(new Definition($class), $method);
}

View File

@ -20,6 +20,7 @@ final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
*/
private $aliases = [];
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/
@ -30,6 +31,9 @@ final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
}
return parent::processValue($value, $isRoot);
}
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->findTaggedServiceIds('container.private') as $id => $tags) {

View File

@ -18,6 +18,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidAr
*/
class AutoAliasServicePass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {

View File

@ -19,6 +19,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
*/
final class AutowireAsDecoratorPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $definition) {

View File

@ -23,10 +23,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\ContainerInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\AutowiringFailedException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\RuntimeException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
use RectorPrefix202212\Symfony\Component\DependencyInjection\TypedReference;
use RectorPrefix202212\Symfony\Component\VarExporter\ProxyHelper;
use RectorPrefix202212\Symfony\Contracts\Service\Attribute\SubscribedService;
/**
* Inspects existing service definitions and wires the autowired ones using the type hints of their classes.
*
@ -100,6 +99,9 @@ class AutowirePass extends AbstractRecursivePass
public $names;
};
}
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$this->populateCombinedAliases($container);
@ -119,6 +121,7 @@ class AutowirePass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/
@ -141,16 +144,6 @@ class AutowirePass extends AbstractRecursivePass
private function doProcessValue($value, bool $isRoot = \false)
{
if ($value instanceof TypedReference) {
if ($attributes = $value->getAttributes()) {
$attribute = \array_pop($attributes);
if ($attributes) {
throw new AutowiringFailedException($this->currentId, \sprintf('Using multiple attributes with "%s" is not supported.', SubscribedService::class));
}
if (!$attribute instanceof Target) {
return $this->processAttribute($attribute, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $value->getInvalidBehavior());
}
$value = new TypedReference($value->getType(), $value->getType(), $value->getInvalidBehavior(), $attribute->name);
}
if ($ref = $this->getAutowiredReference($value, \true)) {
return $ref;
}
@ -191,25 +184,6 @@ class AutowirePass extends AbstractRecursivePass
}
return $value;
}
/**
* @return mixed
*/
private function processAttribute(object $attribute, bool $isOptional = \false)
{
switch (\true) {
case $attribute instanceof Autowire:
$value = $this->container->getParameterBag()->resolveValue($attribute->value);
return $value instanceof Reference && $isOptional ? new Reference($value, ContainerInterface::NULL_ON_INVALID_REFERENCE) : $value;
case $attribute instanceof TaggedIterator:
return new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \false, $attribute->defaultPriorityMethod, (array) $attribute->exclude);
case $attribute instanceof TaggedLocator:
return new ServiceLocatorArgument(new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \true, $attribute->defaultPriorityMethod, (array) $attribute->exclude));
case $attribute instanceof MapDecorated:
$definition = $this->container->getDefinition($this->currentId);
return new Reference($definition->innerServiceId ?? $this->currentId . '.inner', $definition->decorationOnInvalid ?? ContainerInterface::NULL_ON_INVALID_REFERENCE);
}
throw new AutowiringFailedException($this->currentId, \sprintf('"%s" is an unsupported attribute.', \get_class($attribute)));
}
private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot, bool $checkAttributes) : array
{
$this->decoratedId = null;
@ -282,11 +256,31 @@ class AutowirePass extends AbstractRecursivePass
if (\array_key_exists($index, $arguments) && '' !== $arguments[$index]) {
continue;
}
$type = ProxyHelper::exportType($parameter, \true);
$type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, \true);
if ($checkAttributes) {
foreach (\method_exists($parameter, 'getAttributes') ? $parameter->getAttributes() : [] as $attribute) {
if (\in_array($attribute->getName(), [TaggedIterator::class, TaggedLocator::class, Autowire::class, MapDecorated::class], \true)) {
$arguments[$index] = $this->processAttribute($attribute->newInstance(), $parameter->allowsNull());
if (TaggedIterator::class === $attribute->getName()) {
$attribute = $attribute->newInstance();
$arguments[$index] = new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \false, $attribute->defaultPriorityMethod, (array) $attribute->exclude);
break;
}
if (TaggedLocator::class === $attribute->getName()) {
$attribute = $attribute->newInstance();
$arguments[$index] = new ServiceLocatorArgument(new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \true, $attribute->defaultPriorityMethod, (array) $attribute->exclude));
break;
}
if (Autowire::class === $attribute->getName()) {
$value = $attribute->newInstance()->value;
$value = $this->container->getParameterBag()->resolveValue($value);
if ($value instanceof Reference && $parameter->allowsNull()) {
$value = new Reference($value, ContainerInterface::NULL_ON_INVALID_REFERENCE);
}
$arguments[$index] = $value;
break;
}
if (MapDecorated::class === $attribute->getName()) {
$definition = $this->container->getDefinition($this->currentId);
$arguments[$index] = new Reference($definition->innerServiceId ?? $this->currentId . '.inner', $definition->decorationOnInvalid ?? ContainerInterface::NULL_ON_INVALID_REFERENCE);
break;
}
}
@ -307,8 +301,8 @@ class AutowirePass extends AbstractRecursivePass
--$index;
break;
}
$type = ProxyHelper::exportType($parameter);
$type = $type ? \sprintf('is type-hinted "%s"', \preg_replace('/(^|[(|&])\\\\|^\\?\\\\?/', '\\1', $type)) : 'has no type-hint';
$type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, \false);
$type = $type ? \sprintf('is type-hinted "%s"', \ltrim($type, '\\')) : 'has no type-hint';
throw new AutowiringFailedException($this->currentId, \sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" %s, you should configure its value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method, $type));
}
// specifically pass the default value
@ -317,7 +311,7 @@ class AutowirePass extends AbstractRecursivePass
continue;
}
$getValue = function () use($type, $parameter, $class, $method) {
if (!($value = $this->getAutowiredReference($ref = new TypedReference($type, $type, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, Target::parseName($parameter)), \false))) {
if (!($value = $this->getAutowiredReference($ref = new TypedReference($type, $type, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, Target::parseName($parameter)), \true))) {
$failureMessage = $this->createTypeNotFoundMessageCallback($ref, \sprintf('argument "$%s" of method "%s()"', $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method));
if ($parameter->isDefaultValueAvailable()) {
$value = clone $this->defaultArgument;
@ -470,16 +464,7 @@ class AutowirePass extends AbstractRecursivePass
}
private function createTypeNotFoundMessage(TypedReference $reference, string $label, string $currentId) : string
{
$type = $reference->getType();
$i = null;
$namespace = $type;
do {
$namespace = \substr($namespace, 0, $i);
if ($this->container->hasDefinition($namespace) && ($tag = $this->container->getDefinition($namespace)->getTag('container.excluded'))) {
return \sprintf('Cannot autowire service "%s": %s needs an instance of "%s" but this type has been excluded %s.', $currentId, $label, $type, $tag[0]['source'] ?? 'from autowiring');
}
} while (\false !== ($i = \strrpos($namespace, '\\')));
if (!($r = $this->container->getReflectionClass($type, \false))) {
if (!($r = $this->container->getReflectionClass($type = $reference->getType(), \false))) {
// either $type does not exist or a parent class does not exist
try {
$resource = new ClassExistenceResource($type, \false);

View File

@ -20,6 +20,7 @@ use RectorPrefix202212\Symfony\Contracts\Service\Attribute\Required;
class AutowireRequiredMethodsPass extends AbstractRecursivePass
{
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -23,6 +23,7 @@ use RectorPrefix202212\Symfony\Contracts\Service\Attribute\Required;
class AutowireRequiredPropertiesPass extends AbstractRecursivePass
{
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -29,6 +29,7 @@ class CheckArgumentsValidityPass extends AbstractRecursivePass
$this->throwExceptions = $throwExceptions;
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -25,6 +25,9 @@ class CheckExceptionOnInvalidReferenceBehaviorPass extends AbstractRecursivePass
* @var mixed[]
*/
private $serviceLocatorContextIds = [];
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$this->serviceLocatorContextIds = [];

View File

@ -64,6 +64,7 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
$this->skippedIds = $skippedIds;
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -22,6 +22,7 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
class DefinitionErrorExceptionPass extends AbstractRecursivePass
{
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -19,6 +19,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\ContainerBuilder;
*/
class ExtensionCompilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getExtensions() as $extension) {

View File

@ -116,6 +116,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -27,6 +27,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\ParameterBag\Parame
*/
class MergeExtensionConfigurationPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$parameters = $container->getParameterBag()->all();
@ -104,20 +107,18 @@ class MergeExtensionConfigurationParameterBag extends EnvPlaceholderParameterBag
$this->processedEnvPlaceholders = [];
// serialize config and container to catch env vars nested in object graphs
$config = \serialize($config) . \serialize($container->getDefinitions()) . \serialize($container->getAliases()) . \serialize($container->getParameterBag()->all());
if (\false === \stripos($config, 'env_')) {
return;
}
\preg_match_all('/env_[a-f0-9]{16}_\\w+_[a-f0-9]{32}/Ui', $config, $matches);
$usedPlaceholders = \array_flip($matches[0]);
foreach (parent::getEnvPlaceholders() as $env => $placeholders) {
foreach ($placeholders as $placeholder) {
if (isset($usedPlaceholders[$placeholder])) {
if (\false !== \stripos($config, $placeholder)) {
$this->processedEnvPlaceholders[$env] = $placeholders;
break;
}
}
}
}
/**
* {@inheritdoc}
*/
public function getEnvPlaceholders() : array
{
return $this->processedEnvPlaceholders ?? parent::getEnvPlaceholders();
@ -144,21 +145,29 @@ class MergeExtensionConfigurationContainerBuilder extends ContainerBuilder
$this->extensionClass = \get_class($extension);
}
/**
* {@inheritdoc}
* @return $this
*/
public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
{
throw new LogicException(\sprintf('You cannot add compiler pass "%s" from extension "%s". Compiler passes must be registered before the container is compiled.', \get_debug_type($pass), $this->extensionClass));
}
/**
* {@inheritdoc}
*/
public function registerExtension(ExtensionInterface $extension)
{
throw new LogicException(\sprintf('You cannot register extension "%s" from "%s". Extensions must be registered before the container is compiled.', \get_debug_type($extension), $this->extensionClass));
}
/**
* {@inheritdoc}
*/
public function compile(bool $resolveEnvPlaceholders = \false)
{
throw new LogicException(\sprintf('Cannot compile the container in extension "%s".', $this->extensionClass));
}
/**
* {@inheritdoc}
* @param string|bool $format
* @param mixed $value
* @return mixed

View File

@ -23,6 +23,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Loader\YamlFileLoad
final class RegisterAutoconfigureAttributesPass implements CompilerPassInterface
{
private static $registerForAutoconfiguration;
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {

View File

@ -23,7 +23,7 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
*/
class RegisterEnvVarProcessorsPass implements CompilerPassInterface
{
private const ALLOWED_TYPES = ['array', 'bool', 'float', 'int', 'string', \BackedEnum::class];
private const ALLOWED_TYPES = ['array', 'bool', 'float', 'int', 'string'];
public function process(ContainerBuilder $container)
{
$bag = $container->getParameterBag();

View File

@ -19,7 +19,6 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidAr
use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
use RectorPrefix202212\Symfony\Component\DependencyInjection\TypedReference;
use RectorPrefix202212\Symfony\Component\HttpFoundation\Session\SessionInterface;
use RectorPrefix202212\Symfony\Contracts\Service\Attribute\SubscribedService;
use RectorPrefix202212\Symfony\Contracts\Service\ServiceProviderInterface;
use RectorPrefix202212\Symfony\Contracts\Service\ServiceSubscriberInterface;
/**
@ -72,15 +71,6 @@ class RegisterServiceSubscribersPass extends AbstractRecursivePass
$replaceDeprecatedSession = $this->container->has('.session.deprecated') && $r->isSubclassOf(AbstractController::class);
$subscriberMap = [];
foreach ($class::getSubscribedServices() as $key => $type) {
$attributes = [];
if ($type instanceof SubscribedService) {
$key = $type->key;
$attributes = $type->attributes;
if ($type->type === null) {
throw new InvalidArgumentException(\sprintf('When "%s::getSubscribedServices()" returns "%s", a type must be set.', $class, SubscribedService::class));
}
$type = ($type->nullable ? '?' : '') . $type->type;
}
if (!\is_string($type) || !\preg_match('/(?(DEFINE)(?<cn>[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+))(?(DEFINE)(?<fqcn>(?&cn)(?:\\\\(?&cn))*+))^\\??(?&fqcn)(?:(?:\\|(?&fqcn))*+|(?:&(?&fqcn))*+)$/', $type)) {
throw new InvalidArgumentException(\sprintf('"%s::getSubscribedServices()" must return valid PHP types for service "%s" key "%s", "%s" returned.', $class, $this->currentId, $key, \is_string($type) ? $type : \get_debug_type($type)));
}
@ -114,7 +104,7 @@ class RegisterServiceSubscribersPass extends AbstractRecursivePass
$camelCaseName = \lcfirst(\str_replace(' ', '', \ucwords(\preg_replace('/[^a-zA-Z0-9\\x7f-\\xff]++/', ' ', $name))));
$name = $this->container->has($type . ' $' . $camelCaseName) ? $camelCaseName : $name;
}
$subscriberMap[$key] = new TypedReference((string) $serviceMap[$key], $type, $optionalBehavior ?: ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name, $attributes);
$subscriberMap[$key] = new TypedReference((string) $serviceMap[$key], $type, $optionalBehavior ?: ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name);
unset($serviceMap[$key]);
}
if ($serviceMap = \array_keys($serviceMap)) {

View File

@ -68,6 +68,7 @@ class RemoveUnusedDefinitionsPass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -80,6 +80,7 @@ class ReplaceAliasByActualDefinitionPass extends AbstractRecursivePass
$this->replacements = [];
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -18,9 +18,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\ContainerBuilder;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\RuntimeException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
use RectorPrefix202212\Symfony\Component\DependencyInjection\TypedReference;
use RectorPrefix202212\Symfony\Component\VarExporter\ProxyHelper;
/**
* @author Guilhem Niot <guilhem.niot@gmail.com>
*/
@ -38,6 +38,9 @@ class ResolveBindingsPass extends AbstractRecursivePass
* @var mixed[]
*/
private $errorMessages = [];
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$this->usedBindings = $container->getRemovedBindingIds();
@ -84,6 +87,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/
@ -158,9 +162,9 @@ class ResolveBindingsPass extends AbstractRecursivePass
if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
continue;
}
$typeHint = \ltrim(ProxyHelper::exportType($parameter) ?? '', '?');
$typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter);
$name = Target::parseName($parameter);
if ($typeHint && \array_key_exists($k = \preg_replace('/(^|[(|&])\\\\/', '\\1', $typeHint) . ' $' . $name, $bindings)) {
if ($typeHint && \array_key_exists($k = \ltrim($typeHint, '\\') . ' $' . $name, $bindings)) {
$arguments[$key] = $this->getBindingValue($bindings[$k]);
continue;
}

View File

@ -18,6 +18,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidAr
*/
class ResolveClassPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {

View File

@ -18,6 +18,7 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\RuntimeEx
class ResolveFactoryClassPass extends AbstractRecursivePass
{
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -25,6 +25,9 @@ class ResolveHotPathPass extends AbstractRecursivePass
* @var mixed[]
*/
private $resolvedIds = [];
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
try {
@ -35,6 +38,7 @@ class ResolveHotPathPass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -22,6 +22,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\RuntimeEx
*/
class ResolveInstanceofConditionalsPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getAutoconfiguredInstanceof() as $interface => $definition) {

View File

@ -13,8 +13,8 @@ namespace RectorPrefix202212\Symfony\Component\DependencyInjection\Compiler;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
use RectorPrefix202212\Symfony\Component\VarExporter\ProxyHelper;
/**
* Resolves named arguments to their corresponding numeric index.
*
@ -23,6 +23,7 @@ use RectorPrefix202212\Symfony\Component\VarExporter\ProxyHelper;
class ResolveNamedArgumentsPass extends AbstractRecursivePass
{
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/
@ -77,7 +78,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
}
$typeFound = \false;
foreach ($parameters as $j => $p) {
if (!\array_key_exists($j, $resolvedArguments) && ProxyHelper::exportType($p, \true) === $key) {
if (!\array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, \true) === $key) {
$resolvedArguments[$j] = $argument;
$typeFound = \true;
}

View File

@ -25,6 +25,9 @@ class ResolveNoPreloadPass extends AbstractRecursivePass
* @var mixed[]
*/
private $resolvedIds = [];
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$this->container = $container;
@ -54,6 +57,7 @@ class ResolveNoPreloadPass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -39,6 +39,8 @@ class ResolveParameterPlaceHoldersPass extends AbstractRecursivePass
$this->throwOnResolveException = $throwOnResolveException;
}
/**
* {@inheritdoc}
*
* @throws ParameterNotFoundException
*/
public function process(ContainerBuilder $container)

View File

@ -20,6 +20,9 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Reference;
*/
class ResolveReferencesToAliasesPass extends AbstractRecursivePass
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
parent::process($container);
@ -32,6 +35,7 @@ class ResolveReferencesToAliasesPass extends AbstractRecursivePass
}
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -20,6 +20,7 @@ class ResolveTaggedIteratorArgumentPass extends AbstractRecursivePass
{
use PriorityTaggedServiceTrait;
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -29,6 +29,9 @@ class ValidateEnvPlaceholdersPass implements CompilerPassInterface
* @var mixed[]
*/
private $extensionConfig = [];
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$this->extensionConfig = [];

View File

@ -26,10 +26,16 @@ class ContainerParametersResourceChecker implements ResourceCheckerInterface
{
$this->container = $container;
}
/**
* {@inheritdoc}
*/
public function supports(ResourceInterface $metadata) : bool
{
return $metadata instanceof ContainerParametersResource;
}
/**
* {@inheritdoc}
*/
public function isFresh(ResourceInterface $resource, int $timestamp) : bool
{
foreach ($resource->getParameters() as $key => $value) {

View File

@ -15,7 +15,6 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Argument\ServiceLoc
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\RuntimeException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@ -104,7 +103,7 @@ class Container implements ContainerInterface, ResetInterface
*
* @return array|bool|string|int|float|\UnitEnum|null
*
* @throws ParameterNotFoundException if the parameter is not defined
* @throws InvalidArgumentException if the parameter is not defined
*/
public function getParameter(string $name)
{
@ -244,6 +243,9 @@ class Container implements ContainerInterface, ResetInterface
}
return isset($this->services[$id]);
}
/**
* {@inheritdoc}
*/
public function reset()
{
$services = $this->services + $this->privates;

View File

@ -20,5 +20,5 @@ interface ContainerAwareInterface
/**
* Sets the container.
*/
public function setContainer(?ContainerInterface $container);
public function setContainer(ContainerInterface $container = null);
}

View File

@ -23,9 +23,6 @@ trait ContainerAwareTrait
protected $container;
public function setContainer(ContainerInterface $container = null)
{
if (1 > \func_num_args()) {
\RectorPrefix202212\trigger_deprecation('symfony/dependency-injection', '6.2', 'Calling "%s::%s()" without any arguments is deprecated, pass null explicitly instead.', __CLASS__, __FUNCTION__);
}
$this->container = $container;
}
}

View File

@ -38,7 +38,6 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceCi
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\Instantiator\LazyServiceInstantiator;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator;
use RectorPrefix202212\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
use RectorPrefix202212\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@ -85,7 +84,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*/
private $trackResources;
/**
* @var \Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface
* @var \Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface|null
*/
private $proxyInstantiator;
/**
@ -520,11 +519,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
if ($this->isCompiled()) {
throw new BadMethodCallException('Cannot merge on a compiled container.');
}
foreach ($container->getDefinitions() as $id => $definition) {
if (!$definition->hasTag('container.excluded') || !$this->has($id)) {
$this->setDefinition($id, $definition);
}
}
$this->addDefinitions($container->getDefinitions());
$this->addAliases($container->getAliases());
$this->getParameterBag()->add($container->getParameterBag()->all());
if ($this->trackResources) {
@ -642,6 +637,9 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
}
}
}
/**
* {@inheritdoc}
*/
public function getServiceIds() : array
{
return \array_map('strval', \array_unique(\array_merge(\array_keys($this->getDefinitions()), \array_keys($this->aliasDefinitions), parent::getServiceIds())));
@ -838,10 +836,9 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
* @throws RuntimeException When the factory definition is incomplete
* @throws RuntimeException When the service is a synthetic service
* @throws InvalidArgumentException When configure callable is not callable
* @param bool|object $tryProxy
* @return mixed
*/
private function createService(Definition $definition, array &$inlineServices, bool $isConstructorArgument = \false, string $id = null, $tryProxy = \true)
private function createService(Definition $definition, array &$inlineServices, bool $isConstructorArgument = \false, string $id = null, bool $tryProxy = \true)
{
if (null === $id && isset($inlineServices[$h = \spl_object_hash($definition)])) {
return $inlineServices[$h];
@ -856,14 +853,14 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
$deprecation = $definition->getDeprecation($id);
\RectorPrefix202212\trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
}
$parameterBag = $this->getParameterBag();
if (\true === $tryProxy && $definition->isLazy() && !($tryProxy = !($proxy = $this->proxyInstantiator = $this->proxyInstantiator ?? new LazyServiceInstantiator()) || $proxy instanceof RealServiceInstantiator)) {
$proxy = $proxy->instantiateProxy($this, (clone $definition)->setClass($parameterBag->resolveValue($definition->getClass()))->setTags(($definition->hasTag('proxy') ? ['proxy' => $parameterBag->resolveValue($definition->getTag('proxy'))] : []) + $definition->getTags()), $id, function ($proxy = \false) use($definition, &$inlineServices, $id) {
return $this->createService($definition, $inlineServices, \true, $id, $proxy);
if ($tryProxy && $definition->isLazy() && !($tryProxy = !($proxy = $this->proxyInstantiator) || $proxy instanceof RealServiceInstantiator)) {
$proxy = $proxy->instantiateProxy($this, $definition, $id, function () use($definition, &$inlineServices, $id) {
return $this->createService($definition, $inlineServices, \true, $id, \false);
});
$this->shareService($definition, $proxy, $id, $inlineServices);
return $proxy;
}
$parameterBag = $this->getParameterBag();
if (null !== $definition->getFile()) {
require_once $parameterBag->resolveValue($definition->getFile());
}
@ -881,7 +878,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
}
}
$arguments = $this->doResolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($arguments)), $inlineServices, $isConstructorArgument);
if (null !== $id && $definition->isShared() && isset($this->services[$id]) && (\true === $tryProxy || !$definition->isLazy())) {
if (null !== $id && $definition->isShared() && isset($this->services[$id]) && ($tryProxy || !$definition->isLazy())) {
return $this->services[$id];
}
if (null !== $factory) {
@ -894,14 +891,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
}
} else {
$r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass()));
if (\is_object($tryProxy)) {
if ($r->getConstructor()) {
$tryProxy->__construct(...\array_values($arguments));
}
$service = $tryProxy;
} else {
$service = $r->getConstructor() ? $r->newInstanceArgs(\array_values($arguments)) : $r->newInstance();
}
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs(\array_values($arguments));
if (!$definition->isDeprecated() && 0 < \strpos($r->getDocComment(), "\n * @deprecated ")) {
\RectorPrefix202212\trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name);
}
@ -912,7 +902,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
$lastWitherIndex = $k;
}
}
if (null === $lastWitherIndex && (\true === $tryProxy || !$definition->isLazy())) {
if (null === $lastWitherIndex && ($tryProxy || !$definition->isLazy())) {
// share only if proxying failed, or if not a proxy, and if no withers are found
$this->shareService($definition, $service, $id, $inlineServices);
}
@ -922,7 +912,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
}
foreach ($definition->getMethodCalls() as $k => $call) {
$service = $this->callMethod($service, $call, $inlineServices);
if ($lastWitherIndex === $k && (\true === $tryProxy || !$definition->isLazy())) {
if ($lastWitherIndex === $k && ($tryProxy || !$definition->isLazy())) {
// share only if proxying failed, or if not a proxy, and this is the last wither
$this->shareService($definition, $service, $id, $inlineServices);
}
@ -1156,8 +1146,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*/
public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs = null)
{
if (null === $format) {
$format = '%%env(%s)%%';
}
$bag = $this->getParameterBag();
if (\true === ($format = $format ?? '%%env(%s)%%')) {
if (\true === $format) {
$value = $bag->resolveValue($value);
}
if ($value instanceof Definition) {
@ -1170,16 +1163,14 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
}
return $result;
}
if (!\is_string($value) || 38 > \strlen($value) || \false === \stripos($value, 'env_')) {
if (!\is_string($value) || 38 > \strlen($value) || !\preg_match('/env[_(]/i', $value)) {
return $value;
}
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
$completed = \false;
\preg_match_all('/env_[a-f0-9]{16}_\\w+_[a-f0-9]{32}/Ui', $value, $matches);
$usedPlaceholders = \array_flip($matches[0]);
foreach ($envPlaceholders as $env => $placeholders) {
foreach ($placeholders as $placeholder) {
if (isset($usedPlaceholders[$placeholder])) {
if (\false !== \stripos($value, $placeholder)) {
if (\true === $format) {
$resolved = $bag->escapeValue($this->getEnv($env));
} else {
@ -1329,6 +1320,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
return \str_replace(['/', '+'], ['.', '_'], $hash);
}
/**
* {@inheritdoc}
* @return mixed
*/
protected function getEnv(string $name)

View File

@ -11,7 +11,7 @@
namespace RectorPrefix202212\Symfony\Component\DependencyInjection;
use RectorPrefix202212\Psr\Container\ContainerInterface as PsrContainerInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
/**
@ -43,7 +43,7 @@ interface ContainerInterface extends PsrContainerInterface
/**
* @return array|bool|string|int|float|\UnitEnum|null
*
* @throws ParameterNotFoundException if the parameter is not defined
* @throws InvalidArgumentException if the parameter is not defined
*/
public function getParameter(string $name);
public function hasParameter(string $name) : bool;

View File

@ -11,6 +11,7 @@
namespace RectorPrefix202212\Symfony\Component\DependencyInjection\Dumper;
use RectorPrefix202212\Composer\Autoload\ClassLoader;
use RectorPrefix202212\Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Argument\IteratorArgument;
@ -31,7 +32,6 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\RuntimeEx
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use RectorPrefix202212\Symfony\Component\DependencyInjection\ExpressionLanguage;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as ProxyDumper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\LazyServiceDumper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Loader\FileLoader;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Parameter;
@ -164,14 +164,13 @@ class PhpDumper extends Dumper
* @var string
*/
private $baseClass;
/**
* @var string
*/
private $class;
/**
* @var ProxyDumper
*/
private $proxyDumper;
/**
* {@inheritdoc}
*/
public function __construct(ContainerBuilder $container)
{
if (!$container->isCompiled()) {
@ -215,7 +214,6 @@ class PhpDumper extends Dumper
$this->inlineFactories = $this->asFiles && $options['inline_factories_parameter'] && $this->container->hasParameter($options['inline_factories_parameter']) && $this->container->getParameter($options['inline_factories_parameter']);
$this->inlineRequires = $options['inline_class_loader_parameter'] && ($this->container->hasParameter($options['inline_class_loader_parameter']) ? $this->container->getParameter($options['inline_class_loader_parameter']) : $options['debug']);
$this->serviceLocatorTag = $options['service_locator_tag'];
$this->class = $options['class'];
if (\strncmp($baseClass = $options['base_class'], '\\', \strlen('\\')) !== 0 && 'Container' !== $baseClass) {
$baseClass = \sprintf('%s\\%s', $options['namespace'] ? '\\' . $options['namespace'] : '', $baseClass);
$this->baseClass = $baseClass;
@ -418,7 +416,7 @@ EOF;
*/
private function getProxyDumper() : ProxyDumper
{
return $this->proxyDumper = $this->proxyDumper ?? new LazyServiceDumper($this->class);
return $this->proxyDumper = $this->proxyDumper ?? new NullDumper();
}
private function analyzeReferences()
{
@ -551,8 +549,8 @@ EOF;
$strip = '' === $this->docStar && \method_exists(Kernel::class, 'stripComments');
$proxyDumper = $this->getProxyDumper();
\ksort($definitions);
foreach ($definitions as $id => $definition) {
if (!($definition = $this->isProxyCandidate($definition, $asGhostObject, $id))) {
foreach ($definitions as $definition) {
if (!$proxyDumper->isProxyCandidate($definition)) {
continue;
}
if (isset($alreadyGenerated[$class = $definition->getClass()])) {
@ -561,7 +559,7 @@ EOF;
$alreadyGenerated[$class] = \true;
// register class' reflector for resource tracking
$this->container->getReflectionClass($class);
if ("\n" === ($proxyCode = "\n" . $proxyDumper->getProxyCode($definition, $id))) {
if ("\n" === ($proxyCode = "\n" . $proxyDumper->getProxyCode($definition))) {
continue;
}
if ($this->inlineRequires) {
@ -588,10 +586,10 @@ EOF;
}
return $proxyClasses;
}
private function addServiceInclude(string $cId, Definition $definition, bool $isProxyCandidate) : string
private function addServiceInclude(string $cId, Definition $definition) : string
{
$code = '';
if ($this->inlineRequires && (!$this->isHotPath($definition) || $isProxyCandidate)) {
if ($this->inlineRequires && (!$this->isHotPath($definition) || $this->getProxyDumper()->isProxyCandidate($definition))) {
$lineage = [];
foreach ($this->inlinedDefinitions as $def) {
if (!$def->isDeprecated()) {
@ -633,8 +631,7 @@ EOF;
if (\strncmp($class, "'", \strlen("'")) === 0 && \strpos($class, '$') === \false && !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) {
throw new InvalidArgumentException(\sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
}
$asGhostObject = \false;
$isProxyCandidate = $this->isProxyCandidate($definition, $asGhostObject, $id);
$isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
$instantiation = '';
$lastWitherIndex = null;
foreach ($definition->getMethodCalls() as $k => $call) {
@ -653,7 +650,7 @@ EOF;
} else {
$instantiation .= ' = ';
}
return $this->addNewInstance($definition, ' ' . $return . $instantiation, $id, $asGhostObject);
return $this->addNewInstance($definition, ' ' . $return . $instantiation, $id);
}
private function isTrivialInstance(Definition $definition) : bool
{
@ -824,23 +821,22 @@ EOF;
if (!$definition->isShared()) {
$factory = \sprintf('$this->factories%s[%s]', $definition->isPublic() ? '' : "['service_container']", $this->doExport($id));
}
$asGhostObject = \false;
if ($isProxyCandidate = $this->isProxyCandidate($definition, $asGhostObject, $id)) {
$definition = $isProxyCandidate;
if ($isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition)) {
if (!$definition->isShared()) {
$code .= \sprintf(' %s ??= ', $factory);
$code .= \sprintf(' %s = %1$s ?? ', $factory);
if ($asFile) {
$code .= "fn () => self::do(\$container);\n\n";
$code .= "function () {\n";
$code .= " return self::do(\$container);\n";
$code .= " };\n\n";
} else {
$code .= \sprintf("\$this->%s(...);\n\n", $methodName);
}
}
$lazyLoad = $asGhostObject ? '$proxy' : 'false';
$factoryCode = $asFile ? \sprintf('self::do($container, %s)', $lazyLoad) : \sprintf('$this->%s(%s)', $methodName, $lazyLoad);
$factoryCode = $asFile ? 'self::do($container, false)' : \sprintf('$this->%s(false)', $methodName);
$factoryCode = $this->getProxyDumper()->getProxyFactoryCode($definition, $id, $factoryCode);
$code .= $asFile ? \preg_replace('/function \\(([^)]*+)\\)( {|:)/', 'function (\\1) use ($container)\\2', $factoryCode) : $factoryCode;
}
$c = $this->addServiceInclude($id, $definition, null !== $isProxyCandidate);
$c = $this->addServiceInclude($id, $definition);
if ('' !== $c && $isProxyCandidate && !$definition->isShared()) {
$c = \implode("\n", \array_map(function ($line) {
return $line ? ' ' . $line : $line;
@ -937,7 +933,7 @@ EOTXT
}
}
}
if (isset($this->definitionVariables[$inlineDef = $inlineDef ?? $definition])) {
if (isset($this->definitionVariables[$inlineDef = $inlineDef ?: $definition])) {
return $code;
}
$arguments = [$inlineDef->getArguments(), $inlineDef->getFactory()];
@ -947,8 +943,6 @@ EOTXT
} elseif ($definition !== $inlineDef && 2 > $this->inlinedDefinitions[$inlineDef]) {
return $code;
}
$asGhostObject = \false;
$isProxyCandidate = $this->isProxyCandidate($inlineDef, $asGhostObject, $id);
if (isset($this->definitionVariables[$inlineDef])) {
$isSimpleInstance = \false;
} else {
@ -966,13 +960,13 @@ EOTXT
$code .= "\n";
}
$code .= $this->addServiceProperties($inlineDef, $name);
$code .= $this->addServiceMethodCalls($inlineDef, $name, !$isProxyCandidate && $inlineDef->isShared() && !isset($this->singleUsePrivateIds[$id]) ? $id : null);
$code .= $this->addServiceMethodCalls($inlineDef, $name, !$this->getProxyDumper()->isProxyCandidate($inlineDef) && $inlineDef->isShared() && !isset($this->singleUsePrivateIds[$id]) ? $id : null);
$code .= $this->addServiceConfigurator($inlineDef, $name);
}
if (!$isRootInstance || $isSimpleInstance) {
return $code;
if ($isRootInstance && !$isSimpleInstance) {
$code .= "\n return \$instance;\n";
}
return $code . "\n return \$instance;\n";
return $code;
}
private function addServices(array &$services = null) : string
{
@ -1011,9 +1005,9 @@ EOTXT
}
}
}
private function addNewInstance(Definition $definition, string $return = '', string $id = null, bool $asGhostObject = \false) : string
private function addNewInstance(Definition $definition, string $return = '', string $id = null) : string
{
$tail = $return ? \str_repeat(')', \substr_count($return, '(') - \substr_count($return, ')')) . ";\n" : '';
$tail = $return ? ";\n" : '';
if (BaseServiceLocator::class === $definition->getClass() && $definition->hasTag($this->serviceLocatorTag)) {
$arguments = [];
foreach ($definition->getArgument(0) as $k => $argument) {
@ -1062,13 +1056,7 @@ EOTXT
if (null === ($class = $definition->getClass())) {
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
}
if (!$asGhostObject) {
return $return . \sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), \implode(', ', $arguments)) . $tail;
}
if (!\method_exists($this->container->getParameterBag()->resolveValue($class), '__construct')) {
return $return . '$lazyLoad' . $tail;
}
return $return . \sprintf('($lazyLoad->__construct(%s) && false ?: $lazyLoad)', \implode(', ', $arguments)) . $tail;
return $return . \sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), \implode(', ', $arguments)) . $tail;
}
private function startClass(string $class, string $baseClass, bool $hasProxyClasses) : string
{
@ -1079,8 +1067,8 @@ EOTXT
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Argument\\RewindableGenerator;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\ContainerInterface;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Container;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Exception\\LogicException;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Exception\\ParameterNotFoundException;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\Exception\\RuntimeException;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\ParameterBag\\FrozenParameterBag;
use RectorPrefix202212\\Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface;
@ -1159,8 +1147,9 @@ EOF;
EOF;
}
$proxyDumper = $this->getProxyDumper();
foreach ($this->container->getDefinitions() as $definition) {
if (!$definition->isLazy() || $this->getProxyDumper() instanceof NullDumper) {
if (!$proxyDumper->isProxyCandidate($definition)) {
continue;
}
if ($this->asFiles && !$this->inlineFactories) {
@ -1316,7 +1305,7 @@ EOF;
$hotPathServices = $this->hotPathTag && $this->inlineRequires ? $this->container->findTaggedServiceIds($this->hotPathTag) : [];
foreach ($hotPathServices as $id => $tags) {
$definition = $this->container->getDefinition($id);
if ($definition->isLazy() && !$this->getProxyDumper() instanceof NullDumper) {
if ($this->getProxyDumper()->isProxyCandidate($definition)) {
continue;
}
$inlinedDefinitions = $this->getDefinitionsFromArguments([$definition]);
@ -1352,7 +1341,7 @@ EOF;
$hasEnum = \false;
$export = $this->exportParameters([$value], '', 12, $hasEnum);
$export = \explode('0 => ', \substr(\rtrim($export, " ]\n"), 2, -1), 2);
if ($hasEnum || \preg_match("/\\\$this->(?:getEnv\\('(?:[-.\\w\\\\]*+:)*+\\w++'\\)|targetDir\\.'')/", $export[1])) {
if ($hasEnum || \preg_match("/\\\$this->(?:getEnv\\('(?:[-.\\w]*+:)*+\\w++'\\)|targetDir\\.'')/", $export[1])) {
$dynamicPhp[$key] = \sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
} else {
$php[] = \sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
@ -1368,7 +1357,7 @@ EOF;
}
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {
throw new ParameterNotFoundException($name);
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
if (isset($this->loadedDynamicParameters[$name])) {
return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
@ -1416,7 +1405,7 @@ EOF;
$getDynamicParameter = <<<'EOF'
$value = match ($name) {
%s
default => throw new ParameterNotFoundException($name),
default => throw new InvalidArgumentException(sprintf('The dynamic parameter "%%s" must be defined.', $name)),
};
$this->loadedDynamicParameters[$name] = true;
@ -1425,7 +1414,7 @@ EOF;
$getDynamicParameter = \sprintf($getDynamicParameter, \implode("\n", $dynamicPhp));
} else {
$loadedDynamicParameters = '[]';
$getDynamicParameter = \str_repeat(' ', 8) . 'throw new ParameterNotFoundException($name);';
$getDynamicParameter = \str_repeat(' ', 8) . 'throw new InvalidArgumentException(sprintf(\'The dynamic parameter "%s" must be defined.\', $name));';
}
$code .= <<<EOF
@ -1520,7 +1509,9 @@ EOF;
}
private function getDefinitionsFromArguments(array $arguments, \SplObjectStorage $definitions = null, array &$calls = [], bool $byConstructor = null) : \SplObjectStorage
{
$definitions = $definitions ?? new \SplObjectStorage();
if (null === $definitions) {
$definitions = new \SplObjectStorage();
}
foreach ($arguments as $argument) {
if (\is_array($argument)) {
$this->getDefinitionsFromArguments($argument, $definitions, $calls, $byConstructor);
@ -1712,7 +1703,7 @@ EOF;
if (!$value || !\is_array($value)) {
return $dumpedValue;
}
if (!\preg_match("/\\\$this->(?:getEnv\\('(?:[-.\\w\\\\]*+:)*+\\w++'\\)|targetDir\\.'')/", $dumpedValue)) {
if (!\preg_match("/\\\$this->(?:getEnv\\('(?:[-.\\w]*+:)*+\\w++'\\)|targetDir\\.'')/", $dumpedValue)) {
return \sprintf('$this->parameters[%s]', $this->doExport($name));
}
}
@ -1740,7 +1731,7 @@ EOF;
}
$code = $this->addNewInstance($definition, '', $id);
if ($definition->isShared() && !isset($this->singleUsePrivateIds[$id])) {
return \sprintf('($this->%s[%s] ??= %s)', $definition->isPublic() ? 'services' : 'privates', $this->doExport($id), $code);
$code = \sprintf('$this->%s[%s] = %s', $definition->isPublic() ? 'services' : 'privates', $this->doExport($id), $code);
}
$code = "({$code})";
} else {
@ -1952,7 +1943,7 @@ EOF;
if (!\is_array($autoloader)) {
continue;
}
if ($autoloader[0] instanceof DebugClassLoader) {
if ($autoloader[0] instanceof DebugClassLoader || $autoloader[0] instanceof LegacyDebugClassLoader) {
$autoloader = $autoloader[0]->getClassLoader();
}
if (!\is_array($autoloader) || !$autoloader[0] instanceof ClassLoader || !$autoloader[0]->findFile(__CLASS__)) {
@ -1972,7 +1963,6 @@ EOF;
private function getClasses(Definition $definition, string $id) : array
{
$classes = [];
$resolve = \Closure::fromCallable([$this->container->getParameterBag(), 'resolveValue']);
while ($definition instanceof Definition) {
foreach ($definition->getTag($this->preloadTags[0]) as $tag) {
if (!isset($tag['class'])) {
@ -1981,14 +1971,13 @@ EOF;
$classes[] = \trim($tag['class'], '\\');
}
if ($class = $definition->getClass()) {
$classes[] = \trim($resolve($class), '\\');
$classes[] = \trim($class, '\\');
}
$factory = $definition->getFactory();
if (!\is_array($factory)) {
$factory = [$factory];
}
if (\is_string($factory[0])) {
$factory[0] = $resolve($factory[0]);
if (\false !== ($i = \strrpos($factory[0], '::'))) {
$factory[0] = \substr($factory[0], 0, $i);
}
@ -1998,14 +1987,4 @@ EOF;
}
return $classes;
}
private function isProxyCandidate(Definition $definition, ?bool &$asGhostObject, string $id) : ?Definition
{
$asGhostObject = \false;
if (!$definition->isLazy() || ($proxyDumper = $this->getProxyDumper()) instanceof NullDumper) {
return null;
}
$bag = $this->container->getParameterBag();
$definition = (clone $definition)->setClass($bag->resolveValue($definition->getClass()))->setTags(($definition->hasTag('proxy') ? ['proxy' => $bag->resolveValue($definition->getTag('proxy'))] : []) + $definition->getTags());
return $proxyDumper->isProxyCandidate($definition, $asGhostObject, $id) ? $definition : null;
}
}

View File

@ -125,13 +125,8 @@ class XmlDumper extends Dumper
} else {
$tag->appendChild($this->document->createTextNode($name));
}
// Check if we have recursive attributes
if (\array_filter($attributes, \Closure::fromCallable('is_array'))) {
$this->addTagRecursiveAttributes($tag, $attributes);
} else {
foreach ($attributes as $key => $value) {
$tag->setAttribute($key, $value ?? '');
}
foreach ($attributes as $key => $value) {
$tag->setAttribute($key, $value ?? '');
}
$service->appendChild($tag);
}
@ -232,19 +227,6 @@ class XmlDumper extends Dumper
}
$parent->appendChild($services);
}
private function addTagRecursiveAttributes(\DOMElement $parent, array $attributes)
{
foreach ($attributes as $name => $value) {
$attribute = $this->document->createElement('attribute');
$attribute->setAttribute('name', $name);
if (\is_array($value)) {
$this->addTagRecursiveAttributes($attribute, $value);
} else {
$attribute->appendChild($this->document->createTextNode($value));
}
$parent->appendChild($attribute);
}
}
private function convertParameters(array $parameters, string $type, \DOMElement $parent, string $keyAttribute = 'key')
{
$arrayIsList = function (array $array) : bool {
@ -284,15 +266,6 @@ class XmlDumper extends Dumper
$element->setAttribute('default-priority-method', $tag->getDefaultPriorityMethod());
}
}
if ($excludes = $tag->getExclude()) {
if (1 === \count($excludes)) {
$element->setAttribute('exclude', $excludes[0]);
} else {
foreach ($excludes as $exclude) {
$element->appendChild($this->document->createElement('exclude', $exclude));
}
}
}
} elseif ($value instanceof IteratorArgument) {
$element->setAttribute('type', 'iterator');
$this->convertParameters($value->getValues(), $type, $element, 'key');

View File

@ -225,12 +225,6 @@ class YamlDumper extends Dumper
$content['default_priority_method'] = $tag->getDefaultPriorityMethod();
}
}
if ($excludes = $tag->getExclude()) {
if (!\is_array($content)) {
$content = ['tag' => $content];
}
$content['exclude'] = 1 === \count($excludes) ? $excludes[0] : $excludes;
}
return new TaggedValue($value instanceof TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator', $content);
}
if ($value instanceof IteratorArgument) {

View File

@ -22,25 +22,31 @@ class EnvVarProcessor implements EnvVarProcessorInterface
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
private $container;
/** @var \Traversable<EnvVarLoaderInterface> */
/**
* @var \Traversable
*/
private $loaders;
/**
* @var mixed[]
*/
private $loadedVars = [];
/**
* @param \Traversable<EnvVarLoaderInterface>|null $loaders
* @param EnvVarLoaderInterface[] $loaders
*/
public function __construct(ContainerInterface $container, \Traversable $loaders = null)
{
$this->container = $container;
$this->loaders = $loaders ?? new \ArrayIterator();
}
/**
* {@inheritdoc}
*/
public static function getProvidedTypes() : array
{
return ['base64' => 'string', 'bool' => 'bool', 'not' => 'bool', 'const' => 'bool|int|float|string|array', 'csv' => 'array', 'file' => 'string', 'float' => 'float', 'int' => 'int', 'json' => 'array', 'key' => 'bool|int|float|string|array', 'url' => 'array', 'query_string' => 'array', 'resolve' => 'string', 'default' => 'bool|int|float|string|array', 'string' => 'string', 'trim' => 'string', 'require' => 'bool|int|float|string|array', 'enum' => \BackedEnum::class, 'shuffle' => 'array'];
return ['base64' => 'string', 'bool' => 'bool', 'not' => 'bool', 'const' => 'bool|int|float|string|array', 'csv' => 'array', 'file' => 'string', 'float' => 'float', 'int' => 'int', 'json' => 'array', 'key' => 'bool|int|float|string|array', 'url' => 'array', 'query_string' => 'array', 'resolve' => 'string', 'default' => 'bool|int|float|string|array', 'string' => 'string', 'trim' => 'string', 'require' => 'bool|int|float|string|array'];
}
/**
* {@inheritdoc}
* @return mixed
*/
public function getEnv(string $prefix, string $name, \Closure $getEnv)
@ -61,24 +67,6 @@ class EnvVarProcessor implements EnvVarProcessorInterface
}
return $array[$key];
}
if ('enum' === $prefix) {
if (\false === $i) {
throw new RuntimeException(\sprintf('Invalid env "enum:%s": a "%s" class-string should be provided.', $name, \BackedEnum::class));
}
$next = \substr($name, $i + 1);
$backedEnumClassName = \substr($name, 0, $i);
$backedEnumValue = $getEnv($next);
if (!\is_string($backedEnumValue) && !\is_int($backedEnumValue)) {
throw new RuntimeException(\sprintf('Resolved value of "%s" did not result in a string or int value.', $next));
}
if (!\is_subclass_of($backedEnumClassName, \BackedEnum::class)) {
throw new RuntimeException(\sprintf('"%s" is not a "%s".', $backedEnumClassName, \BackedEnum::class));
}
if ($backedEnumClassName::tryFrom($backedEnumValue) !== null) {
throw new RuntimeException(\sprintf('Enum value "%s" is not backed by "%s".', $backedEnumValue, $backedEnumClassName));
}
return $backedEnumClassName::tryFrom($backedEnumValue);
}
if ('default' === $prefix) {
if (\false === $i) {
throw new RuntimeException(\sprintf('Invalid env "default:%s": a fallback parameter should be provided.', $name));
@ -163,12 +151,6 @@ class EnvVarProcessor implements EnvVarProcessorInterface
}
return null;
}
if ('shuffle' === $prefix) {
if (!\is_array($env)) {
throw new RuntimeException(\sprintf('Env var "%s" cannot be shuffled, expected array, got "%s".', $name, \get_debug_type($env)));
}
return $env;
}
if (!\is_scalar($env)) {
throw new RuntimeException(\sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix));
}
@ -176,7 +158,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
return (string) $env;
}
if (\in_array($prefix, ['bool', 'not'], \true)) {
$env = (bool) ((\filter_var($env, \FILTER_VALIDATE_BOOL) ?: \filter_var($env, \FILTER_VALIDATE_INT)) ?: \filter_var($env, \FILTER_VALIDATE_FLOAT));
$env = (bool) ((\filter_var($env, \FILTER_VALIDATE_BOOLEAN) ?: \filter_var($env, \FILTER_VALIDATE_INT)) ?: \filter_var($env, \FILTER_VALIDATE_FLOAT));
return 'not' === $prefix ? !$env : $env;
}
if ('int' === $prefix) {

View File

@ -28,10 +28,16 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
* @var mixed[]
*/
private $processedConfigs = [];
/**
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
{
return \false;
}
/**
* {@inheritdoc}
*/
public function getNamespace()
{
return 'http://example.org/schema/dic/' . $this->getAlias();
@ -63,6 +69,9 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
$classBaseName = \substr(\strrchr($className, '\\'), 1, -9);
return Container::underscore($classBaseName);
}
/**
* {@inheritdoc}
*/
public function getConfiguration(array $config, ContainerBuilder $container)
{
$class = static::class;

View File

@ -21,8 +21,6 @@ interface ExtensionInterface
/**
* Loads a specific configuration.
*
* @param array<array<mixed>> $configs
*
* @throws \InvalidArgumentException When provided tag is not defined in this extension
*/
public function load(array $configs, ContainerBuilder $container);

View File

@ -23,8 +23,8 @@ interface InstantiatorInterface
/**
* Instantiates a proxy object.
*
* @param string $id Identifier of the requested service
* @param callable(object=) $realInstantiator A callback that is capable of producing the real service instance
* @param string $id Identifier of the requested service
* @param callable $realInstantiator Zero-argument callback that is capable of producing the real service instance
*
* @return object
*/

View File

@ -1,30 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\Instantiator;
use RectorPrefix202212\Symfony\Component\DependencyInjection\ContainerInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\LazyServiceDumper;
use RectorPrefix202212\Symfony\Component\VarExporter\LazyGhostTrait;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
final class LazyServiceInstantiator implements InstantiatorInterface
{
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator) : object
{
$dumper = new LazyServiceDumper();
if (!\class_exists($proxyClass = $dumper->getProxyClass($definition, $class), \false)) {
eval($dumper->getProxyCode($definition, $id));
}
return isset(\class_uses($proxyClass)[LazyGhostTrait::class]) ? $proxyClass::createLazyGhost($realInstantiator) : $proxyClass::createLazyProxy($realInstantiator);
}
}

View File

@ -13,12 +13,17 @@ namespace RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\Ins
use RectorPrefix202212\Symfony\Component\DependencyInjection\ContainerInterface;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
/**
* {@inheritdoc}
*
* Noop proxy instantiator - produces the real service instead of a proxy instance.
*
* @author Marco Pivetta <ocramius@gmail.com>
*/
class RealServiceInstantiator implements InstantiatorInterface
{
/**
* {@inheritdoc}
*/
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator) : object
{
return $realInstantiator();

View File

@ -20,9 +20,6 @@ interface DumperInterface
{
/**
* Inspects whether the given definitions should produce proxy instantiation logic in the dumped container.
*
* @param bool|null &$asGhostObject Set to true after the call if the proxy is a ghost object
* @param string|null $id
*/
public function isProxyCandidate(Definition $definition) : bool;
/**

View File

@ -1,131 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use RectorPrefix202212\Symfony\Component\VarExporter\Exception\LogicException;
use RectorPrefix202212\Symfony\Component\VarExporter\ProxyHelper;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
final class LazyServiceDumper implements DumperInterface
{
/**
* @var string
*/
private $salt = '';
public function __construct(string $salt = '')
{
$this->salt = $salt;
}
public function isProxyCandidate(Definition $definition, bool &$asGhostObject = null, string $id = null) : bool
{
$asGhostObject = \false;
if ($definition->hasTag('proxy')) {
if (!$definition->isLazy()) {
throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": setting the "proxy" tag on a service requires it to be "lazy".', $id ?? $definition->getClass()));
}
return \true;
}
if (!$definition->isLazy()) {
return \false;
}
if (!($class = $definition->getClass()) || !(\class_exists($class) || \interface_exists($class, \false))) {
return \false;
}
if ($definition->getFactory()) {
return \true;
}
foreach ($definition->getMethodCalls() as $call) {
if ($call[2] ?? \false) {
return \true;
}
}
try {
$asGhostObject = (bool) ProxyHelper::generateLazyGhost(new \ReflectionClass($class));
} catch (LogicException $exception) {
}
return \true;
}
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode) : string
{
$instantiation = 'return';
if ($definition->isShared()) {
$instantiation .= \sprintf(' $this->%s[%s] =', $definition->isPublic() && !$definition->isPrivate() ? 'services' : 'privates', \var_export($id, \true));
}
$proxyClass = $this->getProxyClass($definition);
if (\strpos($factoryCode, '$proxy') === \false) {
return <<<EOF
if (true === \$lazyLoad) {
{$instantiation} \$this->createProxy('{$proxyClass}', fn () => \\{$proxyClass}::createLazyProxy(fn () => {$factoryCode}));
}
EOF;
}
if (\preg_match('/^\\$this->\\w++\\(\\$proxy\\)$/', $factoryCode)) {
$factoryCode = \substr_replace($factoryCode, '(...)', -8);
} else {
$factoryCode = \sprintf('fn ($proxy) => %s', $factoryCode);
}
return <<<EOF
if (true === \$lazyLoad) {
{$instantiation} \$this->createProxy('{$proxyClass}', fn () => \\{$proxyClass}::createLazyGhost({$factoryCode}));
}
EOF;
}
public function getProxyCode(Definition $definition, string $id = null) : string
{
if (!$this->isProxyCandidate($definition, $asGhostObject, $id)) {
throw new InvalidArgumentException(\sprintf('Cannot instantiate lazy proxy for service "%s".', $id ?? $definition->getClass()));
}
$proxyClass = $this->getProxyClass($definition, $class);
if ($asGhostObject) {
try {
return 'class ' . $proxyClass . ProxyHelper::generateLazyGhost($class);
} catch (LogicException $e) {
throw new InvalidArgumentException(\sprintf('Cannot generate lazy ghost for service "%s".', $id ?? $definition->getClass()), 0, $e);
}
}
$interfaces = [];
if ($definition->hasTag('proxy')) {
foreach ($definition->getTag('proxy') as $tag) {
if (!isset($tag['interface'])) {
throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": the "interface" attribute is missing on a "proxy" tag.', $id ?? $definition->getClass()));
}
if (!\interface_exists($tag['interface']) && !\class_exists($tag['interface'], \false)) {
throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": several "proxy" tags found but "%s" is not an interface.', $id ?? $definition->getClass(), $tag['interface']));
}
if (!\is_a($class->name, $tag['interface'], \true)) {
throw new InvalidArgumentException(\sprintf('Invalid "proxy" tag for service "%s": class "%s" doesn\'t implement "%s".', $id ?? $definition->getClass(), $definition->getClass(), $tag['interface']));
}
$interfaces[] = new \ReflectionClass($tag['interface']);
}
$class = 1 === \count($interfaces) && !$interfaces[0]->isInterface() ? \array_pop($interfaces) : null;
} elseif ($class->isInterface()) {
$interfaces = [$class];
$class = null;
}
try {
return (\PHP_VERSION_ID >= 80200 && (($class2 = $class) ? $class2->isReadOnly() : null) ? 'readonly ' : '') . 'class ' . $proxyClass . ProxyHelper::generateLazyProxy($class, $interfaces);
} catch (LogicException $e) {
throw new InvalidArgumentException(\sprintf('Cannot generate lazy proxy for service "%s".', $id ?? $definition->getClass()), 0, $e);
}
}
public function getProxyClass(Definition $definition, \ReflectionClass &$class = null) : string
{
$class = new \ReflectionClass($definition->getClass());
return \preg_replace('/^.*\\\\/', '', $class->name) . '_' . \substr(\hash('sha256', $this->salt . '+' . $class->name), -7);
}
}

View File

@ -20,15 +20,24 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Definition;
*/
class NullDumper implements DumperInterface
{
public function isProxyCandidate(Definition $definition, bool &$asGhostObject = null, string $id = null) : bool
/**
* {@inheritdoc}
*/
public function isProxyCandidate(Definition $definition) : bool
{
return $asGhostObject = \false;
return \false;
}
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode) : string
{
return '';
}
public function getProxyCode(Definition $definition, string $id = null) : string
/**
* {@inheritdoc}
*/
public function getProxyCode(Definition $definition) : string
{
return '';
}

View File

@ -10,11 +10,10 @@
*/
namespace RectorPrefix202212\Symfony\Component\DependencyInjection\LazyProxy;
\RectorPrefix202212\trigger_deprecation('symfony/dependency-injection', '6.2', 'The "%s" class is deprecated, use "%s" instead.', ProxyHelper::class, \RectorPrefix202212\Symfony\Component\VarExporter\ProxyHelper::class);
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @deprecated since Symfony 6.2, use VarExporter's ProxyHelper instead
* @internal
*/
class ProxyHelper
{

View File

@ -31,6 +31,7 @@ class ClosureLoader extends Loader
parent::__construct($env);
}
/**
* {@inheritdoc}
* @param mixed $resource
* @return mixed
*/
@ -39,6 +40,7 @@ class ClosureLoader extends Loader
return $resource($this->container, $this->env);
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool

View File

@ -48,7 +48,7 @@ abstract class AbstractConfigurator
/**
* Checks that a value is valid, optionally replacing Definition and Reference configurators by their configure value.
*
* @param bool $allowServices whether Definition and Reference are allowed; by default, only scalars, arrays and enum are
* @param bool $allowServices whether Definition and Reference are allowed; by default, only scalars and arrays are
*
* @return mixed the value, optionally cast to a Definition/Reference
* @param mixed $value
@ -82,7 +82,6 @@ abstract class AbstractConfigurator
switch (\true) {
case null === $value:
case \is_scalar($value):
case $value instanceof \UnitEnum:
return $value;
case $value instanceof ArgumentInterface:
case $value instanceof Definition:

View File

@ -43,7 +43,11 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
if ('' === $name) {
throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.');
}
$this->validateAttributes($name, $attributes);
foreach ($attributes as $attribute => $value) {
if (null !== $value && !\is_scalar($value)) {
throw new InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute));
}
}
$this->definition->addTag($name, $attributes);
return $this;
}
@ -54,14 +58,4 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
{
return $this->parent->instanceof($fqcn);
}
private function validateAttributes(string $tagName, array $attributes, string $prefix = '') : void
{
foreach ($attributes as $attribute => $value) {
if (\is_array($value)) {
$this->validateAttributes($tagName, $value, $attribute . '.');
} elseif (!\is_scalar($value ?? '')) {
throw new InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type or an array of scalar-type.', $tagName, $prefix . $attribute));
}
}
}
}

View File

@ -178,14 +178,4 @@ class EnvConfigurator extends ParamConfigurator
\array_unshift($this->stack, 'require');
return $this;
}
/**
* @param class-string<\BackedEnum> $backedEnumClassName
*
* @return $this
*/
public function enum(string $backedEnumClassName)
{
\array_unshift($this->stack, 'enum', $backedEnumClassName);
return $this;
}
}

View File

@ -49,11 +49,7 @@ class PrototypeConfigurator extends AbstractServiceConfigurator
* @var bool
*/
private $allowParent;
/**
* @var string|null
*/
private $path;
public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, string $namespace, string $resource, bool $allowParent, string $path = null)
public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, string $namespace, string $resource, bool $allowParent)
{
$definition = new Definition();
if (!$defaults->isPublic() || !$defaults->isPrivate()) {
@ -67,14 +63,13 @@ class PrototypeConfigurator extends AbstractServiceConfigurator
$this->loader = $loader;
$this->resource = $resource;
$this->allowParent = $allowParent;
$this->path = $path;
parent::__construct($parent, $definition, $namespace, $defaults->getTags());
}
public function __destruct()
{
parent::__destruct();
if (isset($this->loader)) {
$this->loader->registerClasses($this->definition, $this->id, $this->resource, $this->excludes, $this->path);
$this->loader->registerClasses($this->definition, $this->id, $this->resource, $this->excludes);
}
unset($this->loader);
}

View File

@ -132,7 +132,7 @@ class ServicesConfigurator extends AbstractConfigurator
*/
public final function load(string $namespace, string $resource) : PrototypeConfigurator
{
return new PrototypeConfigurator($this, $this->loader, $this->defaults, $namespace, $resource, \true, $this->path);
return new PrototypeConfigurator($this, $this->loader, $this->defaults, $namespace, $resource, \true);
}
/**
* Gets an already defined service definition.

View File

@ -23,18 +23,12 @@ trait TagTrait
if ('' === $name) {
throw new InvalidArgumentException(\sprintf('The tag name for service "%s" must be a non-empty string.', $this->id));
}
$this->validateAttributes($name, $attributes);
foreach ($attributes as $attribute => $value) {
if (!\is_scalar($value) && null !== $value) {
throw new InvalidArgumentException(\sprintf('A tag attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $this->id, $name, $attribute));
}
}
$this->definition->addTag($name, $attributes);
return $this;
}
private function validateAttributes(string $tagName, array $attributes, string $prefix = '') : void
{
foreach ($attributes as $attribute => $value) {
if (\is_array($value)) {
$this->validateAttributes($tagName, $value, $attribute . '.');
} elseif (!\is_scalar($value ?? '')) {
throw new InvalidArgumentException(\sprintf('A tag attribute must be of a scalar-type or an array of scalar-types for service "%s", tag "%s", attribute "%s".', $this->id, $tagName, $prefix . $attribute));
}
}
}
}

View File

@ -18,6 +18,7 @@ namespace RectorPrefix202212\Symfony\Component\DependencyInjection\Loader;
class DirectoryLoader extends FileLoader
{
/**
* {@inheritdoc}
* @param mixed $file
* @return mixed
*/
@ -39,6 +40,7 @@ class DirectoryLoader extends FileLoader
return null;
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool

View File

@ -42,6 +42,8 @@ abstract class FileLoader extends BaseFileLoader
parent::__construct($locator, $env);
}
/**
* {@inheritdoc}
*
* @param bool|string $ignoreErrors Whether errors should be ignored; pass "not_found" to ignore only when the loaded resource is not found
* @param mixed $resource
* @return mixed
@ -78,7 +80,6 @@ abstract class FileLoader extends BaseFileLoader
* @param string $namespace The namespace prefix of classes in the scanned directory
* @param string $resource The directory to look for classes, glob-patterns allowed
* @param string|mixed[] $exclude A globbed path of files to exclude or an array of globbed paths of files to exclude
* @param string|null $source The path to the file that defines the auto-discovery rule
*/
public function registerClasses(Definition $prototype, string $namespace, string $resource, $exclude = null)
{
@ -88,25 +89,16 @@ abstract class FileLoader extends BaseFileLoader
if (!\preg_match('/^(?:[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+\\\\)++$/', $namespace)) {
throw new InvalidArgumentException(\sprintf('Namespace is not a valid PSR-4 prefix: "%s".', $namespace));
}
// This can happen with YAML files
if (\is_array($exclude) && \in_array(null, $exclude, \true)) {
throw new InvalidArgumentException('The exclude list must not contain a "null" value.');
}
// This can happen with XML files
if (\is_array($exclude) && \in_array('', $exclude, \true)) {
throw new InvalidArgumentException('The exclude list must not contain an empty value.');
}
$source = \func_num_args() > 4 ? \func_get_arg(4) : null;
$autoconfigureAttributes = new RegisterAutoconfigureAttributesPass();
$autoconfigureAttributes = $autoconfigureAttributes->accept($prototype) ? $autoconfigureAttributes : null;
$classes = $this->findClasses($namespace, $resource, (array) $exclude, $autoconfigureAttributes, $source);
$classes = $this->findClasses($namespace, $resource, (array) $exclude, $autoconfigureAttributes);
// prepare for deep cloning
$serializedPrototype = \serialize($prototype);
foreach ($classes as $class => $errorMessage) {
if (null === $errorMessage && $autoconfigureAttributes && $this->env) {
$r = $this->container->getReflectionClass($class);
$attribute = null;
foreach ($r->getAttributes(When::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
foreach ($r->getAttributes(When::class) as $attribute) {
if ($this->env === $attribute->newInstance()->env) {
$attribute = null;
break;
@ -157,7 +149,7 @@ abstract class FileLoader extends BaseFileLoader
$this->container->setDefinition($id, $definition->setInstanceofConditionals($this->instanceof));
}
}
private function findClasses(string $namespace, string $pattern, array $excludePatterns, ?RegisterAutoconfigureAttributesPass $autoconfigureAttributes, ?string $source) : array
private function findClasses(string $namespace, string $pattern, array $excludePatterns, ?RegisterAutoconfigureAttributesPass $autoconfigureAttributes) : array
{
$parameterBag = $this->container->getParameterBag();
$excludePaths = [];
@ -165,13 +157,16 @@ abstract class FileLoader extends BaseFileLoader
$excludePatterns = $parameterBag->unescapeValue($parameterBag->resolveValue($excludePatterns));
foreach ($excludePatterns as $excludePattern) {
foreach ($this->glob($excludePattern, \true, $resource, \true, \true) as $path => $info) {
$excludePrefix = $excludePrefix ?? $resource->getPrefix();
if (null === $excludePrefix) {
$excludePrefix = $resource->getPrefix();
}
// normalize Windows slashes and remove trailing slashes
$excludePaths[\rtrim(\str_replace('\\', '/', $path), '/')] = \true;
}
}
$pattern = $parameterBag->unescapeValue($parameterBag->resolveValue($pattern));
$classes = [];
$extRegexp = '/\\.php$/';
$prefixLen = null;
foreach ($this->glob($pattern, \true, $resource, \false, \false, $excludePaths) as $path => $info) {
if (null === $prefixLen) {
@ -183,10 +178,10 @@ abstract class FileLoader extends BaseFileLoader
if (isset($excludePaths[\str_replace('\\', '/', $path)])) {
continue;
}
if (\substr_compare($path, '.php', -\strlen('.php')) !== 0 || !$info->isReadable()) {
if (!\preg_match($extRegexp, $path, $m) || !$info->isReadable()) {
continue;
}
$class = $namespace . \ltrim(\str_replace('/', '\\', \substr($path, $prefixLen, -4)), '\\');
$class = $namespace . \ltrim(\str_replace('/', '\\', \substr($path, $prefixLen, -\strlen($m[0]))), '\\');
if (!\preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+(?:\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+)*+$/', $class)) {
continue;
}
@ -215,15 +210,6 @@ abstract class FileLoader extends BaseFileLoader
$this->container->fileExists($path, \false);
}
}
if (null !== $prefixLen) {
$attributes = null !== $source ? ['source' => \sprintf('in "%s/%s"', \basename(\dirname($source)), \basename($source))] : [];
foreach ($excludePaths as $path => $_) {
$class = $namespace . \ltrim(\str_replace('/', '\\', \substr($path, $prefixLen, \substr_compare($path, '.php', -\strlen('.php')) === 0 ? -4 : null)), '\\');
if (!$this->container->has($class)) {
$this->container->register($class)->setAbstract(\true)->addTag('container.excluded', $attributes);
}
}
}
return $classes;
}
}

View File

@ -18,6 +18,7 @@ namespace RectorPrefix202212\Symfony\Component\DependencyInjection\Loader;
class GlobFileLoader extends FileLoader
{
/**
* {@inheritdoc}
* @param mixed $resource
* @return mixed
*/
@ -30,6 +31,7 @@ class GlobFileLoader extends FileLoader
return null;
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool

View File

@ -20,6 +20,7 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Exception\InvalidAr
class IniFileLoader extends FileLoader
{
/**
* {@inheritdoc}
* @param mixed $resource
* @return mixed
*/
@ -36,11 +37,7 @@ class IniFileLoader extends FileLoader
$result = \parse_ini_file($path, \true, \INI_SCANNER_RAW);
if (isset($result['parameters']) && \is_array($result['parameters'])) {
foreach ($result['parameters'] as $key => $value) {
if (\is_array($value)) {
$this->container->setParameter($key, \array_map(\Closure::fromCallable([$this, 'phpize']), $value));
} else {
$this->container->setParameter($key, $this->phpize($value));
}
$this->container->setParameter($key, $this->phpize($value));
}
}
if ($this->env && \is_array($result['parameters@' . $this->env] ?? null)) {
@ -51,6 +48,7 @@ class IniFileLoader extends FileLoader
return null;
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool

View File

@ -42,6 +42,7 @@ class PhpFileLoader extends FileLoader
$this->generator = $generator;
}
/**
* {@inheritdoc}
* @param mixed $resource
* @return mixed
*/
@ -60,9 +61,6 @@ class PhpFileLoader extends FileLoader
try {
$callback = $load($path, $this->env);
if (\is_object($callback) && \is_callable($callback)) {
// generic solution
$reflectionFunction = new \ReflectionFunction($callback);
$containerConfiguratorClass = $reflectionFunction->getParameters()[0]->getType()->getName();
// generic solution
$reflectionFunction = new \ReflectionFunction($callback);
$containerConfiguratorClass = $reflectionFunction->getParameters()[0]->getType()->getName();
@ -75,6 +73,7 @@ class PhpFileLoader extends FileLoader
return null;
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool
@ -97,7 +96,7 @@ class PhpFileLoader extends FileLoader
$configBuilders = [];
$r = new \ReflectionFunction($callback);
$attribute = null;
foreach (\method_exists($r, 'getAttributes') ? $r->getAttributes(When::class, \ReflectionAttribute::IS_INSTANCEOF) : [] as $attribute) {
foreach (\method_exists($r, 'getAttributes') ? $r->getAttributes(When::class) : [] as $attribute) {
if ($this->env === $attribute->newInstance()->env) {
$attribute = null;
break;
@ -116,9 +115,6 @@ class PhpFileLoader extends FileLoader
$arguments[] = $containerConfigurator;
} else {
switch ($type) {
case ContainerConfigurator::class:
$arguments[] = $containerConfigurator;
break;
case ContainerBuilder::class:
$arguments[] = $this->container;
break;
@ -126,12 +122,6 @@ class PhpFileLoader extends FileLoader
case self::class:
$arguments[] = $this;
break;
case 'string':
if (null !== $this->env && 'env' === $parameter->getName()) {
$arguments[] = $this->env;
break;
}
// no break
default:
try {
$configBuilder = $this->configBuilder($type);
@ -166,7 +156,7 @@ class PhpFileLoader extends FileLoader
if (\class_exists($namespace) && \is_subclass_of($namespace, ConfigBuilderInterface::class)) {
return new $namespace();
}
// If it does not start with Symfony\Config\ we don't know how to handle this
// If it does not start with Symfony\Config\ we dont know how to handle this
if (\strncmp($namespace, 'Symfony\\Config\\', \strlen('Symfony\\Config\\')) !== 0) {
throw new InvalidArgumentException(\sprintf('Could not find or generate class "%s".', $namespace));
}

View File

@ -37,6 +37,7 @@ class XmlFileLoader extends FileLoader
public const NS = 'http://symfony.com/schema/dic/services';
protected $autoRegisterAliasesForSinglyImplementedInterfaces = \false;
/**
* {@inheritdoc}
* @param mixed $resource
* @return mixed
*/
@ -81,6 +82,7 @@ class XmlFileLoader extends FileLoader
}
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool
@ -153,7 +155,7 @@ class XmlFileLoader extends FileLoader
}
$excludes = [$service->getAttribute('exclude')];
}
$this->registerClasses($definition, (string) $service->getAttribute('namespace'), (string) $service->getAttribute('resource'), $excludes, $file);
$this->registerClasses($definition, (string) $service->getAttribute('namespace'), (string) $service->getAttribute('resource'), $excludes);
} else {
$this->setDefinition((string) $service->getAttribute('id'), $definition);
}
@ -281,12 +283,10 @@ class XmlFileLoader extends FileLoader
}
$tags = $this->getChildren($service, 'tag');
foreach ($tags as $tag) {
if ('' === ($tagName = $tag->hasChildNodes() || '' === $tag->nodeValue ? $tag->getAttribute('name') : $tag->nodeValue)) {
throw new InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', (string) $service->getAttribute('id'), $file));
}
$parameters = $this->getTagAttributes($tag, \sprintf('The attribute name of tag "%s" for service "%s" in %s must be a non-empty string.', $tagName, (string) $service->getAttribute('id'), $file));
$parameters = [];
$tagName = $tag->nodeValue;
foreach ($tag->attributes as $name => $node) {
if ('name' === $name) {
if ('name' === $name && '' === $tagName) {
continue;
}
if (\strpos($name, '-') !== \false && \strpos($name, '_') === \false && !\array_key_exists($normalizedName = \str_replace('-', '_', $name), $parameters)) {
@ -295,6 +295,9 @@ class XmlFileLoader extends FileLoader
// keep not normalized key
$parameters[$name] = XmlUtils::phpize($node->nodeValue);
}
if ('' === $tagName && '' === ($tagName = $tag->getAttribute('name'))) {
throw new InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $service->getAttribute('id'), $file));
}
$definition->addTag($tagName, $parameters);
}
$definition->setTags(\array_merge_recursive($definition->getTags(), $defaults->getTags()));
@ -455,14 +458,7 @@ class XmlFileLoader extends FileLoader
if (!$arg->getAttribute('tag')) {
throw new InvalidArgumentException(\sprintf('Tag "<%s>" with type="%s" has no or empty "tag" attribute in "%s".', $name, $type, $file));
}
$excludes = \array_column($this->getChildren($arg, 'exclude'), 'nodeValue');
if ($arg->hasAttribute('exclude')) {
if (\count($excludes) > 0) {
throw new InvalidArgumentException('You cannot use both the attribute "exclude" and <exclude> tags at the same time.');
}
$excludes = [$arg->getAttribute('exclude')];
}
$arguments[$key] = new TaggedIteratorArgument($arg->getAttribute('tag'), $arg->getAttribute('index-by') ?: null, $arg->getAttribute('default-index-method') ?: null, $forLocator, $arg->getAttribute('default-priority-method') ?: null, $excludes);
$arguments[$key] = new TaggedIteratorArgument($arg->getAttribute('tag'), $arg->getAttribute('index-by') ?: null, $arg->getAttribute('default-index-method') ?: null, $forLocator, $arg->getAttribute('default-priority-method') ?: null);
if ($forLocator) {
$arguments[$key] = new ServiceLocatorArgument($arguments[$key]);
}
@ -503,26 +499,6 @@ class XmlFileLoader extends FileLoader
}
return $children;
}
private function getTagAttributes(\DOMNode $node, string $missingName) : array
{
$parameters = [];
$children = $this->getChildren($node, 'attribute');
foreach ($children as $childNode) {
if ('' === ($name = $childNode->getAttribute('name'))) {
throw new InvalidArgumentException($missingName);
}
if ($this->getChildren($childNode, 'attribute')) {
$parameters[$name] = $this->getTagAttributes($childNode, $missingName);
} else {
if (\strpos($name, '-') !== \false && \strpos($name, '_') === \false && !\array_key_exists($normalizedName = \str_replace('-', '_', $name), $parameters)) {
$parameters[$normalizedName] = XmlUtils::phpize($childNode->nodeValue);
}
// keep not normalized key
$parameters[$name] = XmlUtils::phpize($childNode->nodeValue);
}
}
return $parameters;
}
/**
* Validates a documents XML schema.
*

View File

@ -55,6 +55,7 @@ class YamlFileLoader extends FileLoader
private $anonymousServicesSuffix;
protected $autoRegisterAliasesForSinglyImplementedInterfaces = \false;
/**
* {@inheritdoc}
* @param mixed $resource
* @return mixed
*/
@ -110,6 +111,7 @@ class YamlFileLoader extends FileLoader
}
}
/**
* {@inheritdoc}
* @param mixed $resource
*/
public function supports($resource, string $type = null) : bool
@ -213,7 +215,11 @@ class YamlFileLoader extends FileLoader
if (!\is_string($name) || '' === $name) {
throw new InvalidArgumentException(\sprintf('The tag name in "_defaults" must be a non-empty string in "%s".', $file));
}
$this->validateAttributes(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in "%s". Check your YAML syntax.', $name, '%s', $file), $tag);
foreach ($tag as $attribute => $value) {
if (!\is_scalar($value) && null !== $value) {
throw new InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in "%s". Check your YAML syntax.', $name, $attribute, $file));
}
}
}
}
if (isset($defaults['bind'])) {
@ -254,7 +260,10 @@ class YamlFileLoader extends FileLoader
if (\is_array($service) && $this->isUsingShortSyntax($service)) {
$service = ['arguments' => $service];
}
if (!\is_array($service = $service ?? [])) {
if (null === $service) {
$service = [];
}
if (!\is_array($service)) {
throw new InvalidArgumentException(\sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file));
}
if (isset($service['stack'])) {
@ -442,7 +451,11 @@ class YamlFileLoader extends FileLoader
if (!\is_string($name) || '' === $name) {
throw new InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $id, $file));
}
$this->validateAttributes(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, '%s', $file), $tag);
foreach ($tag as $attribute => $value) {
if (!\is_scalar($value) && null !== $value) {
throw new InvalidArgumentException(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, $attribute, $file));
}
}
$definition->addTag($name, $tag);
}
if (null !== ($decorates = $service['decorates'] ?? null)) {
@ -504,7 +517,7 @@ class YamlFileLoader extends FileLoader
}
$exclude = $service['exclude'] ?? null;
$namespace = $service['namespace'] ?? $id;
$this->registerClasses($definition, $namespace, $service['resource'], $exclude, $file);
$this->registerClasses($definition, $namespace, $service['resource'], $exclude);
} else {
$this->setDefinition($id, $definition);
}
@ -629,10 +642,10 @@ class YamlFileLoader extends FileLoader
if (\in_array($value->getTag(), ['tagged', 'tagged_iterator', 'tagged_locator'], \true)) {
$forLocator = 'tagged_locator' === $value->getTag();
if (\is_array($argument) && isset($argument['tag']) && $argument['tag']) {
if ($diff = \array_diff(\array_keys($argument), $supportedKeys = ['tag', 'index_by', 'default_index_method', 'default_priority_method', 'exclude'])) {
throw new InvalidArgumentException(\sprintf('"!%s" tag contains unsupported key "%s"; supported ones are "%s".', $value->getTag(), \implode('", "', $diff), \implode('", "', $supportedKeys)));
if ($diff = \array_diff(\array_keys($argument), ['tag', 'index_by', 'default_index_method', 'default_priority_method'])) {
throw new InvalidArgumentException(\sprintf('"!%s" tag contains unsupported key "%s"; supported ones are "tag", "index_by", "default_index_method", and "default_priority_method".', $value->getTag(), \implode('", "', $diff)));
}
$argument = new TaggedIteratorArgument($argument['tag'], $argument['index_by'] ?? null, $argument['default_index_method'] ?? null, $forLocator, $argument['default_priority_method'] ?? null, (array) ($argument['exclude'] ?? null));
$argument = new TaggedIteratorArgument($argument['tag'], $argument['index_by'] ?? null, $argument['default_index_method'] ?? null, $forLocator, $argument['default_priority_method'] ?? null);
} elseif (\is_string($argument) && $argument) {
$argument = new TaggedIteratorArgument($argument, null, null, $forLocator);
} else {
@ -725,14 +738,4 @@ class YamlFileLoader extends FileLoader
}
}
}
private function validateAttributes(string $message, array $attributes, string $prefix = '') : void
{
foreach ($attributes as $attribute => $value) {
if (\is_array($value)) {
$this->validateAttributes($message, $value, $attribute . '.');
} elseif (!\is_scalar($value ?? '')) {
throw new InvalidArgumentException(\sprintf($message, $prefix . $attribute));
}
}
}
}

View File

@ -219,11 +219,12 @@
<xsd:attribute name="public" type="boolean" />
</xsd:complexType>
<xsd:complexType name="tag" mixed="true">
<xsd:choice minOccurs="0">
<xsd:element name="attribute" type="tag_attribute" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:anyAttribute namespace="##any" processContents="lax" />
<xsd:complexType name="tag">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:anyAttribute namespace="##any" processContents="lax" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="deprecated">
@ -235,13 +236,6 @@
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="tag_attribute" mixed="true">
<xsd:choice minOccurs="0">
<xsd:element name="attribute" type="tag_attribute" maxOccurs="unbounded" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="parameters">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="parameter" type="parameter" />
@ -290,7 +284,6 @@
<xsd:choice minOccurs="0">
<xsd:element name="argument" type="argument" maxOccurs="unbounded" />
<xsd:element name="service" type="service" />
<xsd:element name="exclude" type="xsd:string" maxOccurs="unbounded" />
</xsd:choice>
<xsd:attribute name="type" type="argument_type" />
<xsd:attribute name="id" type="xsd:string" />
@ -301,7 +294,6 @@
<xsd:attribute name="index-by" type="xsd:string" />
<xsd:attribute name="default-index-method" type="xsd:string" />
<xsd:attribute name="default-priority-method" type="xsd:string" />
<xsd:attribute name="exclude" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="call">

View File

@ -2,10 +2,10 @@ This file was automatically generated by Composer Patches (https://github.com/cw
Patches applied to this directory:
0
Source: https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/symfony-dependency-injection.patch
Source: https://raw.githubusercontent.com/symplify/vendor-patch-files/main/patches/generic-php-config-loader.patch
1
Source: https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/symfony-dependency-injection-loader-phpfileloader-php.patch
Source: https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/symfony-dependency-injection.patch

View File

@ -24,17 +24,24 @@ class ContainerBag extends FrozenParameterBag implements ContainerBagInterface
{
$this->container = $container;
}
/**
* {@inheritdoc}
*/
public function all() : array
{
return $this->container->getParameterBag()->all();
}
/**
* {@inheritdoc}
* @return mixed[]|bool|string|int|float|\UnitEnum|null
*/
public function get(string $name)
{
return $this->container->getParameter($name);
}
/**
* {@inheritdoc}
*/
public function has(string $name) : bool
{
return $this->container->hasParameter($name);

View File

@ -26,13 +26,8 @@ interface ContainerBagInterface extends ContainerInterface
/**
* Replaces parameter placeholders (%name%) by their values.
*
* @template TValue of array<array|scalar>|scalar
*
* @param mixed $value
*
* @psalm-return (TValue is scalar ? array|scalar : array<array|scalar>)
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
* @param mixed $value
*/
public function resolveValue($value);
/**

View File

@ -38,6 +38,7 @@ class EnvPlaceholderParameterBag extends ParameterBag
*/
private static $counter = 0;
/**
* {@inheritdoc}
* @return mixed[]|bool|string|int|float|\UnitEnum|null
*/
public function get(string $name)
@ -56,7 +57,7 @@ class EnvPlaceholderParameterBag extends ParameterBag
// return first result
}
}
if (!\preg_match('/^(?:[-.\\w\\\\]*+:)*+\\w++$/', $env)) {
if (!\preg_match('/^(?:[-.\\w]*+:)*+\\w++$/', $env)) {
throw new InvalidArgumentException(\sprintf('Invalid %s name: only "word" characters are allowed.', $name));
}
if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) {
@ -134,6 +135,9 @@ class EnvPlaceholderParameterBag extends ParameterBag
{
return $this->providedTypes;
}
/**
* {@inheritdoc}
*/
public function resolve()
{
if ($this->resolved) {

View File

@ -31,21 +31,31 @@ class FrozenParameterBag extends ParameterBag
$this->parameters = $parameters;
$this->resolved = \true;
}
/**
* {@inheritdoc}
*/
public function clear()
{
throw new LogicException('Impossible to call clear() on a frozen ParameterBag.');
}
/**
* {@inheritdoc}
*/
public function add(array $parameters)
{
throw new LogicException('Impossible to call add() on a frozen ParameterBag.');
}
/**
* {@inheritdoc}
* @param mixed[]|bool|string|int|float|\UnitEnum|null $value
*/
public function set(string $name, $value)
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
}
/**
* {@inheritdoc}
*/
public function remove(string $name)
{
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');

View File

@ -26,21 +26,31 @@ class ParameterBag implements ParameterBagInterface
{
$this->add($parameters);
}
/**
* {@inheritdoc}
*/
public function clear()
{
$this->parameters = [];
}
/**
* {@inheritdoc}
*/
public function add(array $parameters)
{
foreach ($parameters as $key => $value) {
$this->set($key, $value);
}
}
/**
* {@inheritdoc}
*/
public function all() : array
{
return $this->parameters;
}
/**
* {@inheritdoc}
* @return mixed[]|bool|string|int|float|\UnitEnum|null
*/
public function get(string $name)
@ -75,25 +85,30 @@ class ParameterBag implements ParameterBagInterface
return $this->parameters[$name];
}
/**
* {@inheritdoc}
* @param mixed[]|bool|string|int|float|\UnitEnum|null $value
*/
public function set(string $name, $value)
{
if (\is_numeric($name)) {
\RectorPrefix202212\trigger_deprecation('symfony/dependency-injection', '6.2', \sprintf('Using numeric parameter name "%s" is deprecated and will throw as of 7.0.', $name));
// uncomment the following line in 7.0
// throw new InvalidArgumentException(sprintf('The parameter name "%s" cannot be numeric.', $name));
}
$this->parameters[$name] = $value;
}
/**
* {@inheritdoc}
*/
public function has(string $name) : bool
{
return \array_key_exists($name, $this->parameters);
}
/**
* {@inheritdoc}
*/
public function remove(string $name)
{
unset($this->parameters[$name]);
}
/**
* {@inheritdoc}
*/
public function resolve()
{
if ($this->resolved) {
@ -115,27 +130,20 @@ class ParameterBag implements ParameterBagInterface
/**
* Replaces parameter placeholders (%name%) by their values.
*
* @template TValue of array<array|scalar>|scalar
*
* @param mixed $value
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @return mixed
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
* @throws ParameterCircularReferenceException if a circular reference if detected
* @throws RuntimeException when a given parameter has a type problem
* @param mixed $value
* @return mixed
*/
public function resolveValue($value, array $resolving = [])
{
if (\is_array($value)) {
$args = [];
foreach ($value as $key => $v) {
$resolvedKey = \is_string($key) ? $this->resolveValue($key, $resolving) : $key;
if (!\is_scalar($resolvedKey) && !$resolvedKey instanceof \Stringable) {
throw new RuntimeException(\sprintf('Array keys must be a scalar-value, but found key "%s" to resolve to type "%s".', $key, \get_debug_type($resolvedKey)));
}
$args[$resolvedKey] = $this->resolveValue($v, $resolving);
foreach ($value as $k => $v) {
$args[\is_string($k) ? $this->resolveValue($k, $resolving) : $k] = $this->resolveValue($v, $resolving);
}
return $args;
}
@ -190,6 +198,7 @@ class ParameterBag implements ParameterBagInterface
return $this->resolved;
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/
@ -208,6 +217,7 @@ class ParameterBag implements ParameterBagInterface
return $value;
}
/**
* {@inheritdoc}
* @param mixed $value
* @return mixed
*/

View File

@ -36,6 +36,7 @@ class ServiceLocator implements ServiceProviderInterface, \Countable
*/
private $container;
/**
* {@inheritdoc}
* @return mixed
*/
public function get(string $id)

View File

@ -25,23 +25,17 @@ class TypedReference extends Reference
* @var string|null
*/
private $name;
/**
* @var mixed[]
*/
private $attributes;
/**
* @param string $id The service identifier
* @param string $type The PHP type of the identified service
* @param int $invalidBehavior The behavior when the service does not exist
* @param string|null $name The name of the argument targeting the service
* @param array $attributes The attributes to be used
*/
public function __construct(string $id, string $type, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, string $name = null, array $attributes = [])
public function __construct(string $id, string $type, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, string $name = null)
{
$this->name = $type === $id ? $name : null;
parent::__construct($id, $invalidBehavior);
$this->type = $type;
$this->attributes = $attributes;
}
public function getType()
{
@ -51,8 +45,4 @@ class TypedReference extends Reference
{
return $this->name;
}
public function getAttributes() : array
{
return $this->attributes;
}
}

View File

@ -19,8 +19,7 @@
"php": ">=8.1",
"psr\/container": "^1.1|^2.0",
"symfony\/deprecation-contracts": "^2.1|^3",
"symfony\/service-contracts": "^1.1.6|^2.0|^3.0",
"symfony\/var-exporter": "^6.2"
"symfony\/service-contracts": "^1.1.6|^2.0|^3.0"
},
"require-dev": {
"symfony\/yaml": "^5.4|^6.0",
@ -38,7 +37,7 @@
"ext-psr": "<1.1|>=2",
"symfony\/config": "<6.1",
"symfony\/finder": "<5.4",
"symfony\/proxy-manager-bridge": "<6.2",
"symfony\/proxy-manager-bridge": "<5.4",
"symfony\/yaml": "<5.4"
},
"provide": {

View File

@ -1,20 +0,0 @@
CHANGELOG
=========
6.2
---
* Add support for lazy ghost objects and virtual proxies
* Add `Hydrator::hydrate()`
* Preserve PHP references also when using `Hydrator::hydrate()` or `Instantiator::instantiate()`
* Add support for hydrating from native (array) casts
5.1.0
-----
* added argument `array &$foundClasses` to `VarExporter::export()` to ease with preloading exported values
4.2.0
-----
* added the component

View File

@ -1,19 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Exception;
class ClassNotFoundException extends \Exception implements ExceptionInterface
{
public function __construct(string $class, \Throwable $previous = null)
{
parent::__construct(\sprintf('Class "%s" not found.', $class), 0, $previous);
}
}

View File

@ -1,15 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Exception;
interface ExceptionInterface extends \Throwable
{
}

View File

@ -1,15 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Exception;
class LogicException extends \LogicException implements ExceptionInterface
{
}

View File

@ -1,19 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Exception;
class NotInstantiableTypeException extends \Exception implements ExceptionInterface
{
public function __construct(string $type, \Throwable $previous = null)
{
parent::__construct(\sprintf('Type "%s" is not instantiable.', $type), 0, $previous);
}
}

View File

@ -1,73 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter;
use RectorPrefix202212\Symfony\Component\VarExporter\Internal\Hydrator as InternalHydrator;
/**
* Utility class to hydrate the properties of an object.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
final class Hydrator
{
/**
* Sets the properties of an object, including private and protected ones.
*
* For example:
*
* // Sets the public or protected $object->propertyName property
* Hydrator::hydrate($object, ['propertyName' => $propertyValue]);
*
* // Sets a private property defined on its parent Bar class:
* Hydrator::hydrate($object, ["\0Bar\0privateBarProperty" => $propertyValue]);
*
* // Alternative way to set the private $object->privateBarProperty property
* Hydrator::hydrate($object, [], [
* Bar::class => ['privateBarProperty' => $propertyValue],
* ]);
*
* Instances of ArrayObject, ArrayIterator and SplObjectStorage can be hydrated
* by using the special "\0" property name to define their internal value:
*
* // Hydrates an SplObjectStorage where $info1 is attached to $obj1, etc.
* Hydrator::hydrate($object, ["\0" => [$obj1, $info1, $obj2, $info2...]]);
*
* // Hydrates an ArrayObject populated with $inputArray
* Hydrator::hydrate($object, ["\0" => [$inputArray]]);
*
* @template T of object
*
* @param T $instance The object to hydrate
* @param array<string, mixed> $properties The properties to set on the instance
* @param array<class-string, array<string, mixed>> $scopedProperties The properties to set on the instance,
* keyed by their declaring class
*
* @return T
*/
public static function hydrate(object $instance, array $properties = [], array $scopedProperties = []) : object
{
if ($properties) {
$class = \get_class($instance);
$propertyScopes = InternalHydrator::$propertyScopes[$class] = InternalHydrator::$propertyScopes[$class] ?? InternalHydrator::getPropertyScopes($class);
foreach ($properties as $name => &$value) {
[$scope, $name, $readonlyScope] = $propertyScopes[$name] ?? [$class, $name, $class];
$scopedProperties[$readonlyScope ?? $scope][$name] =& $value;
}
unset($value);
}
foreach ($scopedProperties as $scope => $properties) {
if ($properties) {
(InternalHydrator::$simpleHydrators[$scope] = InternalHydrator::$simpleHydrators[$scope] ?? InternalHydrator::getSimpleHydrator($scope))($properties, $instance);
}
}
return $instance;
}
}

View File

@ -1,55 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter;
use RectorPrefix202212\Symfony\Component\VarExporter\Exception\ExceptionInterface;
use RectorPrefix202212\Symfony\Component\VarExporter\Exception\NotInstantiableTypeException;
use RectorPrefix202212\Symfony\Component\VarExporter\Internal\Registry;
/**
* A utility class to create objects without calling their constructor.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
final class Instantiator
{
/**
* Creates an object and sets its properties without calling its constructor nor any other methods.
*
* @see Hydrator::hydrate() for examples
*
* @template T of object
*
* @param class-string<T> $class The class of the instance to create
* @param array<string, mixed> $properties The properties to set on the instance
* @param array<class-string, array<string, mixed>> $scopedProperties The properties to set on the instance,
* keyed by their declaring class
*
* @return T
*
* @throws ExceptionInterface When the instance cannot be created
*/
public static function instantiate(string $class, array $properties = [], array $scopedProperties = []) : object
{
$reflector = Registry::$reflectors[$class] = Registry::$reflectors[$class] ?? Registry::getClassReflector($class);
if (Registry::$cloneable[$class]) {
$instance = clone Registry::$prototypes[$class];
} elseif (Registry::$instantiableWithoutConstructor[$class]) {
$instance = $reflector->newInstanceWithoutConstructor();
} elseif (null === Registry::$prototypes[$class]) {
throw new NotInstantiableTypeException($class);
} elseif ($reflector->implementsInterface('Serializable') && !\method_exists($class, '__unserialize')) {
$instance = \unserialize('C:' . \strlen($class) . ':"' . $class . '":0:{}');
} else {
$instance = \unserialize('O:' . \strlen($class) . ':"' . $class . '":0:{}');
}
return $properties || $scopedProperties ? Hydrator::hydrate($instance, $properties, $scopedProperties) : $instance;
}
}

View File

@ -1,350 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Internal;
use RectorPrefix202212\Symfony\Component\VarExporter\Exception\NotInstantiableTypeException;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
class Exporter
{
/**
* Prepares an array of values for VarExporter.
*
* For performance this method is public and has no type-hints.
*
* @param array &$values
* @param \SplObjectStorage $objectsPool
* @param array &$refsPool
* @param int &$objectsCount
* @param bool &$valuesAreStatic
*
* @return array
*
* @throws NotInstantiableTypeException When a value cannot be serialized
*/
public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount, &$valuesAreStatic)
{
$refs = $values;
foreach ($values as $k => $value) {
if (\is_resource($value)) {
throw new NotInstantiableTypeException(\get_resource_type($value) . ' resource');
}
$refs[$k] = $objectsPool;
if ($isRef = !($valueIsStatic = $values[$k] !== $objectsPool)) {
$values[$k] =& $value;
// Break hard references to make $values completely
unset($value);
// independent from the original structure
$refs[$k] = $value = $values[$k];
if ($value instanceof Reference && 0 > $value->id) {
$valuesAreStatic = \false;
++$value->count;
continue;
}
$refsPool[] = [&$refs[$k], $value, &$value];
$refs[$k] = $values[$k] = new Reference(-\count($refsPool), $value);
}
if (\is_array($value)) {
if ($value) {
$value = self::prepare($value, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
}
goto handle_value;
} elseif (!\is_object($value) || $value instanceof \UnitEnum) {
goto handle_value;
}
$valueIsStatic = \false;
if (isset($objectsPool[$value])) {
++$objectsCount;
$value = new Reference($objectsPool[$value][0]);
goto handle_value;
}
$class = \get_class($value);
$reflector = Registry::$reflectors[$class] = Registry::$reflectors[$class] ?? Registry::getClassReflector($class);
if ($reflector->hasMethod('__serialize')) {
if (!$reflector->getMethod('__serialize')->isPublic()) {
throw new \Error(\sprintf('Call to %s method "%s::__serialize()".', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class));
}
if (!\is_array($properties = $value->__serialize())) {
throw new \TypeError($class . '::__serialize() must return an array');
}
goto prepare_value;
}
$properties = [];
$sleep = null;
$proto = Registry::$prototypes[$class];
if (($value instanceof \ArrayIterator || $value instanceof \ArrayObject) && null !== $proto) {
// ArrayIterator and ArrayObject need special care because their "flags"
// option changes the behavior of the (array) casting operator.
[$arrayValue, $properties] = self::getArrayObjectProperties($value, $proto);
// populates Registry::$prototypes[$class] with a new instance
Registry::getClassReflector($class, Registry::$instantiableWithoutConstructor[$class], Registry::$cloneable[$class]);
} elseif ($value instanceof \SplObjectStorage && Registry::$cloneable[$class] && null !== $proto) {
// By implementing Serializable, SplObjectStorage breaks
// internal references; let's deal with it on our own.
foreach (clone $value as $v) {
$properties[] = $v;
$properties[] = $value[$v];
}
$properties = ['SplObjectStorage' => ["\x00" => $properties]];
$arrayValue = (array) $value;
} elseif ($value instanceof \Serializable || $value instanceof \__PHP_Incomplete_Class || \PHP_VERSION_ID < 80200 && $value instanceof \DatePeriod) {
++$objectsCount;
$objectsPool[$value] = [$id = \count($objectsPool), \serialize($value), [], 0];
$value = new Reference($id);
goto handle_value;
} else {
if (\method_exists($class, '__sleep')) {
if (!\is_array($sleep = $value->__sleep())) {
\trigger_error('serialize(): __sleep should return an array only containing the names of instance-variables to serialize', \E_USER_NOTICE);
$value = null;
goto handle_value;
}
$sleep = \array_flip($sleep);
}
$arrayValue = (array) $value;
}
$proto = (array) $proto;
foreach ($arrayValue as $name => $v) {
$i = 0;
$n = (string) $name;
if ('' === $n || "\x00" !== $n[0]) {
$c = $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass';
} elseif ('*' === $n[1]) {
$n = \substr($n, 3);
$c = $reflector->getProperty($n)->class;
if ('Error' === $c) {
$c = 'TypeError';
} elseif ('Exception' === $c) {
$c = 'ErrorException';
}
} else {
$i = \strpos($n, "\x00", 2);
$c = \substr($n, 1, $i - 1);
$n = \substr($n, 1 + $i);
}
if (null !== $sleep) {
if (!isset($sleep[$n]) || $i && $c !== $class) {
continue;
}
$sleep[$n] = \false;
}
if (!\array_key_exists($name, $proto) || $proto[$name] !== $v || "\x00Error\x00trace" === $name || "\x00Exception\x00trace" === $name) {
$properties[$c][$n] = $v;
}
}
if ($sleep) {
foreach ($sleep as $n => $v) {
if (\false !== $v) {
\trigger_error(\sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $n), \E_USER_NOTICE);
}
}
}
prepare_value:
$objectsPool[$value] = [$id = \count($objectsPool)];
$properties = self::prepare($properties, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
++$objectsCount;
$objectsPool[$value] = [$id, $class, $properties, \method_exists($class, '__unserialize') ? -$objectsCount : (\method_exists($class, '__wakeup') ? $objectsCount : 0)];
$value = new Reference($id);
handle_value:
if ($isRef) {
unset($value);
// Break the hard reference created above
} elseif (!$valueIsStatic) {
$values[$k] = $value;
}
$valuesAreStatic = $valueIsStatic && $valuesAreStatic;
}
return $values;
}
public static function export($value, $indent = '')
{
switch (\true) {
case \is_int($value) || \is_float($value):
return \var_export($value, \true);
case [] === $value:
return '[]';
case \false === $value:
return 'false';
case \true === $value:
return 'true';
case null === $value:
return 'null';
case '' === $value:
return "''";
case $value instanceof \UnitEnum:
return \ltrim(\var_export($value, \true), '\\');
}
if ($value instanceof Reference) {
if (0 <= $value->id) {
return '$o[' . $value->id . ']';
}
if (!$value->count) {
return self::export($value->value, $indent);
}
$value = -$value->id;
return '&$r[' . $value . ']';
}
$subIndent = $indent . ' ';
if (\is_string($value)) {
$code = \sprintf("'%s'", \addcslashes($value, "'\\"));
$code = \preg_replace_callback("/((?:[\\0\\r\\n]|||||||||)++)(.)/", function ($m) use($subIndent) {
$m[1] = \sprintf('\'."%s".\'', \str_replace(["\x00", "\r", "\n", "", "", "", "", "", "", "", "", "", '\\n\\'], ['\\0', '\\r', '\\n', '\\u{202A}', '\\u{202B}', '\\u{202D}', '\\u{202E}', '\\u{2066}', '\\u{2067}', '\\u{2068}', '\\u{202C}', '\\u{2069}', '\\n"' . "\n" . $subIndent . '."\\'], $m[1]));
if ("'" === $m[2]) {
return \substr($m[1], 0, -2);
}
if (\substr_compare($m[1], 'n".\'', -\strlen('n".\'')) === 0) {
return \substr_replace($m[1], "\n" . $subIndent . ".'" . $m[2], -2);
}
return $m[1] . $m[2];
}, $code, -1, $count);
if ($count && \strncmp($code, "''.", \strlen("''.")) === 0) {
$code = \substr($code, 3);
}
return $code;
}
if (\is_array($value)) {
$j = -1;
$code = '';
foreach ($value as $k => $v) {
$code .= $subIndent;
if (!\is_int($k) || 1 !== $k - $j) {
$code .= self::export($k, $subIndent) . ' => ';
}
if (\is_int($k) && $k > $j) {
$j = $k;
}
$code .= self::export($v, $subIndent) . ",\n";
}
return "[\n" . $code . $indent . ']';
}
if ($value instanceof Values) {
$code = $subIndent . "\$r = [],\n";
foreach ($value->values as $k => $v) {
$code .= $subIndent . '$r[' . $k . '] = ' . self::export($v, $subIndent) . ",\n";
}
return "[\n" . $code . $indent . ']';
}
if ($value instanceof Registry) {
return self::exportRegistry($value, $indent, $subIndent);
}
if ($value instanceof Hydrator) {
return self::exportHydrator($value, $indent, $subIndent);
}
throw new \UnexpectedValueException(\sprintf('Cannot export value of type "%s".', \get_debug_type($value)));
}
private static function exportRegistry(Registry $value, string $indent, string $subIndent) : string
{
$code = '';
$serializables = [];
$seen = [];
$prototypesAccess = 0;
$factoriesAccess = 0;
$r = '\\' . Registry::class;
$j = -1;
foreach ($value->classes as $k => $class) {
if (':' === ($class[1] ?? null)) {
$serializables[$k] = $class;
continue;
}
if (!Registry::$instantiableWithoutConstructor[$class]) {
if (\is_subclass_of($class, 'Serializable') && !\method_exists($class, '__unserialize')) {
$serializables[$k] = 'C:' . \strlen($class) . ':"' . $class . '":0:{}';
} else {
$serializables[$k] = 'O:' . \strlen($class) . ':"' . $class . '":0:{}';
}
if (\is_subclass_of($class, 'Throwable')) {
$eol = \is_subclass_of($class, 'Error') ? "\x00Error\x00" : "\x00Exception\x00";
$serializables[$k] = \substr_replace($serializables[$k], '1:{s:' . (5 + \strlen($eol)) . ':"' . $eol . 'trace";a:0:{}}', -4);
}
continue;
}
$code .= $subIndent . (1 !== $k - $j ? $k . ' => ' : '');
$j = $k;
$eol = ",\n";
$c = '[' . self::export($class) . ']';
if ($seen[$class] ?? \false) {
if (Registry::$cloneable[$class]) {
++$prototypesAccess;
$code .= 'clone $p' . $c;
} else {
++$factoriesAccess;
$code .= '$f' . $c . '()';
}
} else {
$seen[$class] = \true;
if (Registry::$cloneable[$class]) {
$code .= 'clone (' . ($prototypesAccess++ ? '$p' : '($p = &' . $r . '::$prototypes)') . $c . ' ?? ' . $r . '::p';
} else {
$code .= '(' . ($factoriesAccess++ ? '$f' : '($f = &' . $r . '::$factories)') . $c . ' ?? ' . $r . '::f';
$eol = '()' . $eol;
}
$code .= '(' . \substr($c, 1, -1) . '))';
}
$code .= $eol;
}
if (1 === $prototypesAccess) {
$code = \str_replace('($p = &' . $r . '::$prototypes)', $r . '::$prototypes', $code);
}
if (1 === $factoriesAccess) {
$code = \str_replace('($f = &' . $r . '::$factories)', $r . '::$factories', $code);
}
if ('' !== $code) {
$code = "\n" . $code . $indent;
}
if ($serializables) {
$code = $r . '::unserialize([' . $code . '], ' . self::export($serializables, $indent) . ')';
} else {
$code = '[' . $code . ']';
}
return '$o = ' . $code;
}
private static function exportHydrator(Hydrator $value, string $indent, string $subIndent) : string
{
$code = '';
foreach ($value->properties as $class => $properties) {
$code .= $subIndent . ' ' . self::export($class) . ' => ' . self::export($properties, $subIndent . ' ') . ",\n";
}
$code = [self::export($value->registry, $subIndent), self::export($value->values, $subIndent), '' !== $code ? "[\n" . $code . $subIndent . ']' : '[]', self::export($value->value, $subIndent), self::export($value->wakeups, $subIndent)];
return '\\' . \get_class($value) . "::hydrate(\n" . $subIndent . \implode(",\n" . $subIndent, $code) . "\n" . $indent . ')';
}
/**
* @param \ArrayIterator|\ArrayObject $value
* @param \ArrayIterator|\ArrayObject $proto
*/
private static function getArrayObjectProperties($value, $proto) : array
{
$reflector = $value instanceof \ArrayIterator ? 'ArrayIterator' : 'ArrayObject';
$reflector = Registry::$reflectors[$reflector] = Registry::$reflectors[$reflector] ?? Registry::getClassReflector($reflector);
$properties = [$arrayValue = (array) $value, $reflector->getMethod('getFlags')->invoke($value), $value instanceof \ArrayObject ? $reflector->getMethod('getIteratorClass')->invoke($value) : 'ArrayIterator'];
$reflector = $reflector->getMethod('setFlags');
$reflector->invoke($proto, \ArrayObject::STD_PROP_LIST);
if ($properties[1] & \ArrayObject::STD_PROP_LIST) {
$reflector->invoke($value, 0);
$properties[0] = (array) $value;
} else {
$reflector->invoke($value, \ArrayObject::STD_PROP_LIST);
$arrayValue = (array) $value;
}
$reflector->invoke($value, $properties[1]);
if ([[], 0, 'ArrayIterator'] === $properties) {
$properties = [];
} else {
if ('ArrayIterator' === $properties[2]) {
unset($properties[2]);
}
$properties = [$reflector->class => ["\x00" => $properties]];
}
return [$arrayValue, $properties];
}
}

View File

@ -1,257 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Internal;
use RectorPrefix202212\Symfony\Component\VarExporter\Exception\ClassNotFoundException;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
class Hydrator
{
public static $hydrators = [];
public static $simpleHydrators = [];
public static $propertyScopes = [];
public $registry;
public $values;
public $properties;
public $value;
public $wakeups;
public function __construct(?Registry $registry, ?Values $values, array $properties, $value, array $wakeups)
{
$this->registry = $registry;
$this->values = $values;
$this->properties = $properties;
$this->value = $value;
$this->wakeups = $wakeups;
}
public static function hydrate($objects, $values, $properties, $value, $wakeups)
{
foreach ($properties as $class => $vars) {
(self::$hydrators[$class] = self::$hydrators[$class] ?? self::getHydrator($class))($vars, $objects);
}
foreach ($wakeups as $k => $v) {
if (\is_array($v)) {
$objects[-$k]->__unserialize($v);
} else {
$objects[$v]->__wakeup();
}
}
return $value;
}
public static function getHydrator($class)
{
$baseHydrator = self::$hydrators['stdClass'] = self::$hydrators['stdClass'] ?? static function ($properties, $objects) {
foreach ($properties as $name => $values) {
foreach ($values as $i => $v) {
$objects[$i]->{$name} = $v;
}
}
};
switch ($class) {
case 'stdClass':
return $baseHydrator;
case 'ErrorException':
return $baseHydrator->bindTo(null, new class extends \ErrorException
{
});
case 'TypeError':
return $baseHydrator->bindTo(null, new class extends \Error
{
});
case 'SplObjectStorage':
return static function ($properties, $objects) {
foreach ($properties as $name => $values) {
if ("\x00" === $name) {
foreach ($values as $i => $v) {
for ($j = 0; $j < \count($v); ++$j) {
$objects[$i]->attach($v[$j], $v[++$j]);
}
}
continue;
}
foreach ($values as $i => $v) {
$objects[$i]->{$name} = $v;
}
}
};
}
if (!\class_exists($class) && !\interface_exists($class, \false) && !\trait_exists($class, \false)) {
throw new ClassNotFoundException($class);
}
$classReflector = new \ReflectionClass($class);
switch ($class) {
case 'ArrayIterator':
case 'ArrayObject':
$constructor = \Closure::fromCallable([$classReflector->getConstructor(), 'invokeArgs']);
return static function ($properties, $objects) use($constructor) {
foreach ($properties as $name => $values) {
if ("\x00" !== $name) {
foreach ($values as $i => $v) {
$objects[$i]->{$name} = $v;
}
}
}
foreach ($properties["\x00"] ?? [] as $i => $v) {
$constructor($objects[$i], $v);
}
};
}
if (!$classReflector->isInternal()) {
return $baseHydrator->bindTo(null, $class);
}
if ($classReflector->name !== $class) {
return self::$hydrators[$classReflector->name] = self::$hydrators[$classReflector->name] ?? self::getHydrator($classReflector->name);
}
$propertySetters = [];
foreach ($classReflector->getProperties() as $propertyReflector) {
if (!$propertyReflector->isStatic()) {
$propertySetters[$propertyReflector->name] = \Closure::fromCallable([$propertyReflector, 'setValue']);
}
}
if (!$propertySetters) {
return $baseHydrator;
}
return static function ($properties, $objects) use($propertySetters) {
foreach ($properties as $name => $values) {
if ($setValue = $propertySetters[$name] ?? null) {
foreach ($values as $i => $v) {
$setValue($objects[$i], $v);
}
continue;
}
foreach ($values as $i => $v) {
$objects[$i]->{$name} = $v;
}
}
};
}
public static function getSimpleHydrator($class)
{
$baseHydrator = self::$simpleHydrators['stdClass'] = self::$simpleHydrators['stdClass'] ?? (function ($properties, $object) {
$readonly = (array) $this;
foreach ($properties as $name => &$value) {
$object->{$name} = $value;
if (!($readonly[$name] ?? \false)) {
$object->{$name} =& $value;
}
}
})->bindTo(new \stdClass());
switch ($class) {
case 'stdClass':
return $baseHydrator;
case 'ErrorException':
return $baseHydrator->bindTo(new \stdClass(), new class extends \ErrorException
{
});
case 'TypeError':
return $baseHydrator->bindTo(new \stdClass(), new class extends \Error
{
});
case 'SplObjectStorage':
return static function ($properties, $object) {
foreach ($properties as $name => &$value) {
if ("\x00" !== $name) {
$object->{$name} = $value;
$object->{$name} =& $value;
continue;
}
for ($i = 0; $i < \count($value); ++$i) {
$object->attach($value[$i], $value[++$i]);
}
}
};
}
if (!\class_exists($class) && !\interface_exists($class, \false) && !\trait_exists($class, \false)) {
throw new ClassNotFoundException($class);
}
$classReflector = new \ReflectionClass($class);
switch ($class) {
case 'ArrayIterator':
case 'ArrayObject':
$constructor = \Closure::fromCallable([$classReflector->getConstructor(), 'invokeArgs']);
return static function ($properties, $object) use($constructor) {
foreach ($properties as $name => &$value) {
if ("\x00" === $name) {
$constructor($object, $value);
} else {
$object->{$name} = $value;
$object->{$name} =& $value;
}
}
};
}
if (!$classReflector->isInternal()) {
$readonly = new \stdClass();
foreach ($classReflector->getProperties(\ReflectionProperty::IS_READONLY) as $propertyReflector) {
if ($class === $propertyReflector->class) {
$readonly->{$propertyReflector->name} = \true;
}
}
return $baseHydrator->bindTo($readonly, $class);
}
if ($classReflector->name !== $class) {
return self::$simpleHydrators[$classReflector->name] = self::$simpleHydrators[$classReflector->name] ?? self::getSimpleHydrator($classReflector->name);
}
$propertySetters = [];
foreach ($classReflector->getProperties() as $propertyReflector) {
if (!$propertyReflector->isStatic()) {
$propertySetters[$propertyReflector->name] = \Closure::fromCallable([$propertyReflector, 'setValue']);
}
}
if (!$propertySetters) {
return $baseHydrator;
}
return static function ($properties, $object) use($propertySetters) {
foreach ($properties as $name => &$value) {
if ($setValue = $propertySetters[$name] ?? null) {
$setValue($object, $value);
} else {
$object->{$name} = $value;
$object->{$name} =& $value;
}
}
};
}
public static function getPropertyScopes($class)
{
$propertyScopes = [];
$r = new \ReflectionClass($class);
foreach ($r->getProperties() as $property) {
$flags = $property->getModifiers();
if (\ReflectionProperty::IS_STATIC & $flags) {
continue;
}
$name = $property->name;
if (\ReflectionProperty::IS_PRIVATE & $flags) {
$propertyScopes["\x00{$class}\x00{$name}"] = $propertyScopes[$name] = [$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $class : null];
continue;
}
$propertyScopes[$name] = [$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $property->class : null];
if (\ReflectionProperty::IS_PROTECTED & $flags) {
$propertyScopes["\x00*\x00{$name}"] = $propertyScopes[$name];
}
}
while ($r = $r->getParentClass()) {
$class = $r->name;
foreach ($r->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) {
if (!$property->isStatic()) {
$name = $property->name;
$readonlyScope = $property->isReadOnly() ? $class : null;
$propertyScopes["\x00{$class}\x00{$name}"] = [$class, $name, $readonlyScope];
$propertyScopes[$name] = $propertyScopes[$name] ?? [$class, $name, $readonlyScope];
}
}
}
return $propertyScopes;
}
}

View File

@ -1,126 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Internal;
/**
* Stores the state of lazy objects and caches related reflection information.
*
* As a micro-optimization, this class uses no type declarations.
*
* @internal
*/
class LazyObjectRegistry
{
/**
* @var array<int, LazyObjectState>
*/
public static $states = [];
/**
* @var array<class-string, \ReflectionClass>
*/
public static $classReflectors = [];
/**
* @var array<class-string, array<string, mixed>>
*/
public static $defaultProperties = [];
/**
* @var array<class-string, list<\Closure>>
*/
public static $classResetters = [];
/**
* @var array<class-string, array{get: \Closure, set: \Closure, isset: \Closure, unset: \Closure}>
*/
public static $classAccessors = [];
/**
* @var array<class-string, array{set: bool, isset: bool, unset: bool, clone: bool, serialize: bool, unserialize: bool, sleep: bool, wakeup: bool, destruct: bool, get: int}>
*/
public static $parentMethods = [];
public static function getClassResetters($class)
{
$classProperties = [];
if ((self::$classReflectors[$class] = self::$classReflectors[$class] ?? new \ReflectionClass($class))->isInternal()) {
$propertyScopes = [];
} else {
$propertyScopes = Hydrator::$propertyScopes[$class] = Hydrator::$propertyScopes[$class] ?? Hydrator::getPropertyScopes($class);
}
foreach ($propertyScopes as $key => [$scope, $name, $readonlyScope]) {
$propertyScopes[$k = "\x00{$scope}\x00{$name}"] ?? $propertyScopes[$k = "\x00*\x00{$name}"] ?? ($k = $name);
if ($k === $key && "\x00{$class}\x00lazyObjectId" !== $k) {
$classProperties[$readonlyScope ?? $scope][$name] = $key;
}
}
$resetters = [];
foreach ($classProperties as $scope => $properties) {
$resetters[] = \Closure::bind(static function ($instance, $skippedProperties, $onlyProperties = null) use($properties) {
foreach ($properties as $name => $key) {
if (!\array_key_exists($key, $skippedProperties) && (null === $onlyProperties || \array_key_exists($key, $onlyProperties))) {
unset($instance->{$name});
}
}
}, null, $scope);
}
$resetters[] = static function ($instance, $skippedProperties, $onlyProperties = null) {
foreach ((array) $instance as $name => $value) {
if ("\x00" !== ($name[0] ?? '') && !\array_key_exists($name, $skippedProperties) && (null === $onlyProperties || \array_key_exists($name, $onlyProperties))) {
unset($instance->{$name});
}
}
};
return $resetters;
}
public static function getClassAccessors($class)
{
return \Closure::bind(static function () {
return ['get' => static function &($instance, $name, $readonly) {
if (!$readonly) {
return $instance->{$name};
}
$value = $instance->{$name};
return $value;
}, 'set' => static function ($instance, $name, $value) {
$instance->{$name} = $value;
}, 'isset' => static function ($instance, $name) {
return isset($instance->{$name});
}, 'unset' => static function ($instance, $name) {
unset($instance->{$name});
}];
}, null, \Closure::class === $class ? null : $class)();
}
public static function getParentMethods($class)
{
$parent = \get_parent_class($class);
$methods = [];
foreach (['set', 'isset', 'unset', 'clone', 'serialize', 'unserialize', 'sleep', 'wakeup', 'destruct', 'get'] as $method) {
if (!$parent || !\method_exists($parent, '__' . $method)) {
$methods[$method] = \false;
} else {
$m = new \ReflectionMethod($parent, '__' . $method);
$methods[$method] = !$m->isAbstract() && !$m->isPrivate();
}
}
$methods['get'] = $methods['get'] ? $m->returnsReference() ? 2 : 1 : 0;
return $methods;
}
public static function getScope($propertyScopes, $class, $property, $readonlyScope = null)
{
if (null === $readonlyScope && !isset($propertyScopes[$k = "\x00{$class}\x00{$property}"]) && !isset($propertyScopes[$k = "\x00*\x00{$property}"])) {
return null;
}
$frame = \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2];
if (\ReflectionProperty::class === ($scope = $frame['class'] ?? \Closure::class)) {
$scope = $frame['object']->class;
}
if (null === $readonlyScope && '*' === $k[1] && ($class === $scope || \is_subclass_of($class, $scope))) {
return null;
}
return $scope;
}
}

View File

@ -1,116 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Internal;
use RectorPrefix202212\Symfony\Component\VarExporter\Hydrator as PublicHydrator;
/**
* Keeps the state of lazy objects.
*
* As a micro-optimization, this class uses no type declarations.
*
* @internal
*/
class LazyObjectState
{
public const STATUS_UNINITIALIZED_FULL = 1;
public const STATUS_UNINITIALIZED_PARTIAL = 2;
public const STATUS_INITIALIZED_FULL = 3;
public const STATUS_INITIALIZED_PARTIAL = 4;
/**
* @var array<string, true>
* @readonly
*/
public $skippedProperties;
/**
* @var self::STATUS_*
*/
public $status = 0;
/**
* @readonly
* @var \Closure|mixed[]
*/
public $initializer;
/**
* @param \Closure|mixed[] $initializer
*/
public function __construct($initializer, $skippedProperties = [])
{
$this->initializer = $initializer;
$this->skippedProperties = $skippedProperties;
$this->status = \is_array($initializer) ? self::STATUS_UNINITIALIZED_PARTIAL : self::STATUS_UNINITIALIZED_FULL;
}
public function initialize($instance, $propertyName, $propertyScope)
{
if (self::STATUS_INITIALIZED_FULL === $this->status) {
return self::STATUS_INITIALIZED_FULL;
}
if (\is_array($this->initializer)) {
$class = \get_class($instance);
$propertyScope = $propertyScope ?? $class;
$propertyScopes = Hydrator::$propertyScopes[$class];
$propertyScopes[$k = "\x00{$propertyScope}\x00{$propertyName}"] ?? $propertyScopes[$k = "\x00*\x00{$propertyName}"] ?? ($k = $propertyName);
if ($initializer = $this->initializer[$k] ?? null) {
$value = $initializer(...[$instance, $propertyName, $propertyScope, LazyObjectRegistry::$defaultProperties[$class][$k] ?? null]);
$accessor = LazyObjectRegistry::$classAccessors[$propertyScope] = LazyObjectRegistry::$classAccessors[$propertyScope] ?? LazyObjectRegistry::getClassAccessors($propertyScope);
$accessor['set']($instance, $propertyName, $value);
return $this->status = self::STATUS_INITIALIZED_PARTIAL;
}
$status = self::STATUS_UNINITIALIZED_PARTIAL;
if ($initializer = $this->initializer["\x00"] ?? null) {
if (!\is_array($values = $initializer($instance, LazyObjectRegistry::$defaultProperties[$class]))) {
throw new \TypeError(\sprintf('The lazy-initializer defined for instance of "%s" must return an array, got "%s".', $class, \get_debug_type($values)));
}
$properties = (array) $instance;
foreach ($values as $key => $value) {
if ($k === $key) {
$status = self::STATUS_INITIALIZED_PARTIAL;
}
if (!\array_key_exists($key, $properties) && ([$scope, $name, $readonlyScope] = $propertyScopes[$key] ?? null)) {
$scope = $readonlyScope ?? ('*' !== $scope ? $scope : $class);
$accessor = LazyObjectRegistry::$classAccessors[$scope] = LazyObjectRegistry::$classAccessors[$scope] ?? LazyObjectRegistry::getClassAccessors($scope);
$accessor['set']($instance, $name, $value);
}
}
}
return $status;
}
$this->status = self::STATUS_INITIALIZED_FULL;
try {
if ($defaultProperties = \array_diff_key(LazyObjectRegistry::$defaultProperties[\get_class($instance)], $this->skippedProperties)) {
PublicHydrator::hydrate($instance, $defaultProperties);
}
($this->initializer)($instance);
} catch (\Throwable $e) {
$this->status = self::STATUS_UNINITIALIZED_FULL;
$this->reset($instance);
throw $e;
}
return self::STATUS_INITIALIZED_FULL;
}
public function reset($instance) : void
{
$class = \get_class($instance);
$propertyScopes = Hydrator::$propertyScopes[$class] = Hydrator::$propertyScopes[$class] ?? Hydrator::getPropertyScopes($class);
$skippedProperties = $this->skippedProperties;
$properties = (array) $instance;
$onlyProperties = \is_array($this->initializer) ? $this->initializer : null;
foreach ($propertyScopes as $key => [$scope, $name, $readonlyScope]) {
$propertyScopes[$k = "\x00{$scope}\x00{$name}"] ?? $propertyScopes[$k = "\x00*\x00{$name}"] ?? ($k = $name);
if ($k === $key && (null !== $readonlyScope || !\array_key_exists($k, $properties))) {
$skippedProperties[$k] = \true;
}
}
foreach (LazyObjectRegistry::$classResetters[$class] as $reset) {
$reset($instance, $skippedProperties, $onlyProperties);
}
$this->status = self::STATUS_INITIALIZED_FULL === $this->status ? self::STATUS_UNINITIALIZED_FULL : self::STATUS_UNINITIALIZED_PARTIAL;
}
}

View File

@ -1,28 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202212\Symfony\Component\VarExporter\Internal;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
class Reference
{
public $id;
public $value;
public $count = 0;
public function __construct(int $id, $value = null)
{
$this->id = $id;
$this->value = $value;
}
}

Some files were not shown because too many files have changed in this diff Show More