mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
composer --no-dev
This commit is contained in:
2251
vendor/composer/autoload_classmap.php
vendored
2251
vendor/composer/autoload_classmap.php
vendored
File diff suppressed because it is too large
Load Diff
11
vendor/composer/autoload_files.php
vendored
11
vendor/composer/autoload_files.php
vendored
@@ -6,24 +6,17 @@ $vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'383eaff206634a77a1be54e64e6459c7' => $vendorDir . '/sabre/uri/lib/functions.php',
|
||||
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
||||
'2b9d0f43f9552984cfa82fee95491826' => $vendorDir . '/sabre/event/lib/coroutine.php',
|
||||
'd81bab31d3feb45bfe2f283ea3c8fdf7' => $vendorDir . '/sabre/event/lib/Loop/functions.php',
|
||||
'a1cce3d26cc15c00fcd0b3354bd72c88' => $vendorDir . '/sabre/event/lib/Promise/functions.php',
|
||||
'3569eecfeed3bcf0bad3c998a494ecb8' => $vendorDir . '/sabre/xml/lib/Deserializer/functions.php',
|
||||
'93aa591bc4ca510c520999e34229ee79' => $vendorDir . '/sabre/xml/lib/Serializer/functions.php',
|
||||
'9e7a8ca9c2c682ec2704dd873a0e3618' => $vendorDir . '/php-mock/php-mock/autoload.php',
|
||||
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
|
||||
'ebdb698ed4152ae445614b69b5e4bb6a' => $vendorDir . '/sabre/http/lib/functions.php',
|
||||
'cf8d012d3963323bc1a5e6f9e7e54ef4' => $vendorDir . '/dms/phpunit-arraysubset-asserts/assertarraysubset-autoload.php',
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
|
||||
'125bba9b2a34259a2ab4c8f405781876' => $vendorDir . '/php-mock/php-mock-phpunit/autoload.php',
|
||||
'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
|
||||
'9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php',
|
||||
'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php',
|
||||
'c15d4a1253e33e055d05e547c61dcb71' => $vendorDir . '/smarty/smarty/src/functions.php',
|
||||
);
|
||||
|
||||
1
vendor/composer/autoload_namespaces.php
vendored
1
vendor/composer/autoload_namespaces.php
vendored
@@ -9,7 +9,6 @@ return array(
|
||||
'URLify' => array($vendorDir . '/jbroadway/urlify'),
|
||||
'Text' => array($vendorDir . '/pear/text_languagedetect'),
|
||||
'SimplePie' => array($vendorDir . '/simplepie/simplepie/library'),
|
||||
'PHPMD\\' => array($vendorDir . '/phpmd/phpmd/src/main/php'),
|
||||
'OAuth2' => array($vendorDir . '/bshaffer/oauth2-server-php/src'),
|
||||
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
|
||||
);
|
||||
|
||||
16
vendor/composer/autoload_psr4.php
vendored
16
vendor/composer/autoload_psr4.php
vendored
@@ -8,20 +8,10 @@ $baseDir = dirname($vendorDir);
|
||||
return array(
|
||||
'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku', $vendorDir . '/voku/stop-words/src/voku'),
|
||||
'phpseclib\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
|
||||
'phpmock\\phpunit\\' => array($vendorDir . '/php-mock/php-mock-phpunit/classes'),
|
||||
'phpmock\\integration\\' => array($vendorDir . '/php-mock/php-mock-integration/classes'),
|
||||
'phpmock\\' => array($vendorDir . '/php-mock/php-mock/classes', $vendorDir . '/php-mock/php-mock/tests'),
|
||||
'chillerlan\\Settings\\' => array($vendorDir . '/chillerlan/php-settings-container/src'),
|
||||
'chillerlan\\QRCode\\' => array($vendorDir . '/chillerlan/php-qrcode/src'),
|
||||
'Zotlabs\\Tests\\Unit\\' => array($baseDir . '/tests/unit'),
|
||||
'Zotlabs\\' => array($baseDir . '/Zotlabs'),
|
||||
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
|
||||
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
||||
'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'),
|
||||
'Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'),
|
||||
'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
|
||||
'Symfony\\Component\\DependencyInjection\\' => array($vendorDir . '/symfony/dependency-injection'),
|
||||
'Symfony\\Component\\Config\\' => array($vendorDir . '/symfony/config'),
|
||||
'StephenHill\\Benchmarks\\' => array($vendorDir . '/stephenhill/base58/benchmarks'),
|
||||
'StephenHill\\' => array($vendorDir . '/stephenhill/base58/src'),
|
||||
'Smarty\\' => array($vendorDir . '/smarty/smarty/src'),
|
||||
@@ -36,11 +26,8 @@ return array(
|
||||
'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'),
|
||||
'Ramsey\\Collection\\' => array($vendorDir . '/ramsey/collection/src'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
|
||||
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
|
||||
'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'),
|
||||
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
|
||||
'ParagonIE\\ConstantTime\\' => array($vendorDir . '/paragonie/constant_time_encoding/src'),
|
||||
'PDepend\\' => array($vendorDir . '/pdepend/pdepend/src/main/php/PDepend'),
|
||||
'OTPHP\\' => array($vendorDir . '/spomky-labs/otphp/src'),
|
||||
'Mmccook\\JsonCanonicalizator\\' => array($vendorDir . '/mmccook/php-json-canonicalization-scheme/src'),
|
||||
'Michelf\\' => array($vendorDir . '/michelf/php-markdown/Michelf'),
|
||||
@@ -48,9 +35,6 @@ return array(
|
||||
'LanguageDetection\\' => array($vendorDir . '/patrickschur/language-detection/src/LanguageDetection'),
|
||||
'ID3Parser\\' => array($vendorDir . '/lukasreschke/id3parser/src'),
|
||||
'Hubzilla\\' => array($baseDir . '/include'),
|
||||
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
|
||||
'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
|
||||
'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
|
||||
'CommerceGuys\\Intl\\' => array($vendorDir . '/commerceguys/intl/src'),
|
||||
'Brick\\Math\\' => array($vendorDir . '/brick/math/src'),
|
||||
);
|
||||
|
||||
2353
vendor/composer/autoload_static.php
vendored
2353
vendor/composer/autoload_static.php
vendored
File diff suppressed because it is too large
Load Diff
2999
vendor/composer/installed.json
vendored
2999
vendor/composer/installed.json
vendored
File diff suppressed because it is too large
Load Diff
411
vendor/composer/installed.php
vendored
411
vendor/composer/installed.php
vendored
@@ -3,11 +3,11 @@
|
||||
'name' => 'zotlabs/hubzilla',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'd9b262348facf0f5591a73a8f2518ea9e837691e',
|
||||
'reference' => '65c8de34101cedc33fc8e6282ff11e8e57eeed1b',
|
||||
'type' => 'application',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev' => true,
|
||||
'dev' => false,
|
||||
),
|
||||
'versions' => array(
|
||||
'blueimp/jquery-file-upload' => array(
|
||||
@@ -64,24 +64,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'composer/pcre' => array(
|
||||
'pretty_version' => '3.3.2',
|
||||
'version' => '3.3.2.0',
|
||||
'reference' => 'b2bed4734f0cc156ee1fe9c0da2550420d99a21e',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/./pcre',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'composer/xdebug-handler' => array(
|
||||
'pretty_version' => '3.0.5',
|
||||
'version' => '3.0.5.0',
|
||||
'reference' => '6c1925561632e83d60a44492e0b344cf48ab85ef',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/./xdebug-handler',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'desandro/imagesloaded' => array(
|
||||
'pretty_version' => 'v4.1.4',
|
||||
'version' => '4.1.4.0',
|
||||
@@ -91,15 +73,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'dms/phpunit-arraysubset-asserts' => array(
|
||||
'pretty_version' => 'v0.5.0',
|
||||
'version' => '0.5.0.0',
|
||||
'reference' => 'aa6b9e858414e91cca361cac3b2035ee57d212e0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../dms/phpunit-arraysubset-asserts',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'ezyang/htmlpurifier' => array(
|
||||
'pretty_version' => 'v4.18.0',
|
||||
'version' => '4.18.0.0',
|
||||
@@ -136,12 +109,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'malkusch/php-mock' => array(
|
||||
'dev_requirement' => true,
|
||||
'replaced' => array(
|
||||
0 => '*',
|
||||
),
|
||||
),
|
||||
'michelf/php-markdown' => array(
|
||||
'pretty_version' => '2.0.0',
|
||||
'version' => '2.0.0.0',
|
||||
@@ -160,24 +127,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'myclabs/deep-copy' => array(
|
||||
'pretty_version' => '1.13.0',
|
||||
'version' => '1.13.0.0',
|
||||
'reference' => '024473a478be9df5fdaca2c793f2232fe788e414',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../myclabs/deep-copy',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'nikic/php-parser' => array(
|
||||
'pretty_version' => 'v5.4.0',
|
||||
'version' => '5.4.0.0',
|
||||
'reference' => '447a020a1f875a434d62f2a401f53b82a396e494',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../nikic/php-parser',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'paragonie/constant_time_encoding' => array(
|
||||
'pretty_version' => 'v3.0.0',
|
||||
'version' => '3.0.0.0',
|
||||
@@ -196,15 +145,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'pdepend/pdepend' => array(
|
||||
'pretty_version' => '2.16.2',
|
||||
'version' => '2.16.2.0',
|
||||
'reference' => 'f942b208dc2a0868454d01b29f0c75bbcfc6ed58',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../pdepend/pdepend',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'pear/text_languagedetect' => array(
|
||||
'pretty_version' => 'v1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
@@ -214,60 +154,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'phar-io/manifest' => array(
|
||||
'pretty_version' => '2.0.4',
|
||||
'version' => '2.0.4.0',
|
||||
'reference' => '54750ef60c58e43759730615a392c31c80e23176',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phar-io/manifest',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phar-io/version' => array(
|
||||
'pretty_version' => '3.2.1',
|
||||
'version' => '3.2.1.0',
|
||||
'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phar-io/version',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'php-mock/php-mock' => array(
|
||||
'pretty_version' => '2.5.1',
|
||||
'version' => '2.5.1.0',
|
||||
'reference' => '8f58972dce4de5a804dc0459383a11bc651416cf',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-mock/php-mock',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'php-mock/php-mock-integration' => array(
|
||||
'pretty_version' => '2.3.0',
|
||||
'version' => '2.3.0.0',
|
||||
'reference' => 'ec6a00a8129d50ed0f07907c91e3274ca4ade877',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-mock/php-mock-integration',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'php-mock/php-mock-phpunit' => array(
|
||||
'pretty_version' => '2.10.0',
|
||||
'version' => '2.10.0.0',
|
||||
'reference' => 'e1f7e795990b00937376e345883ea68ca3bda7e0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-mock/php-mock-phpunit',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpmd/phpmd' => array(
|
||||
'pretty_version' => '2.15.0',
|
||||
'version' => '2.15.0.0',
|
||||
'reference' => '74a1f56e33afad4128b886e334093e98e1b5e7c0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpmd/phpmd',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpseclib/phpseclib' => array(
|
||||
'pretty_version' => '2.0.48',
|
||||
'version' => '2.0.48.0',
|
||||
@@ -277,69 +163,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'phpstan/phpstan' => array(
|
||||
'pretty_version' => '2.1.6',
|
||||
'version' => '2.1.6.0',
|
||||
'reference' => '6eaec7c6c9e90dcfe46ad1e1ffa5171e2dab641c',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpstan/phpstan',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpunit/php-code-coverage' => array(
|
||||
'pretty_version' => '10.1.16',
|
||||
'version' => '10.1.16.0',
|
||||
'reference' => '7e308268858ed6baedc8704a304727d20bc07c77',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpunit/php-code-coverage',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpunit/php-file-iterator' => array(
|
||||
'pretty_version' => '4.1.0',
|
||||
'version' => '4.1.0.0',
|
||||
'reference' => 'a95037b6d9e608ba092da1b23931e537cadc3c3c',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpunit/php-file-iterator',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpunit/php-invoker' => array(
|
||||
'pretty_version' => '4.0.0',
|
||||
'version' => '4.0.0.0',
|
||||
'reference' => 'f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpunit/php-invoker',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpunit/php-text-template' => array(
|
||||
'pretty_version' => '3.0.1',
|
||||
'version' => '3.0.1.0',
|
||||
'reference' => '0c7b06ff49e3d5072f057eb1fa59258bf287a748',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpunit/php-text-template',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpunit/php-timer' => array(
|
||||
'pretty_version' => '6.0.0',
|
||||
'version' => '6.0.0.0',
|
||||
'reference' => 'e2a2d67966e740530f4a3343fe2e030ffdc1161d',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpunit/php-timer',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'phpunit/phpunit' => array(
|
||||
'pretty_version' => '10.5.45',
|
||||
'version' => '10.5.45.0',
|
||||
'reference' => 'bd68a781d8e30348bc297449f5234b3458267ae8',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpunit/phpunit',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'psr/clock' => array(
|
||||
'pretty_version' => '1.0.0',
|
||||
'version' => '1.0.0.0',
|
||||
@@ -349,21 +172,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/container' => array(
|
||||
'pretty_version' => '2.0.2',
|
||||
'version' => '2.0.2.0',
|
||||
'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/container',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'psr/container-implementation' => array(
|
||||
'dev_requirement' => true,
|
||||
'provided' => array(
|
||||
0 => '1.1|2.0',
|
||||
),
|
||||
),
|
||||
'psr/log' => array(
|
||||
'pretty_version' => '3.0.2',
|
||||
'version' => '3.0.2.0',
|
||||
@@ -460,141 +268,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'sebastian/cli-parser' => array(
|
||||
'pretty_version' => '2.0.1',
|
||||
'version' => '2.0.1.0',
|
||||
'reference' => 'c34583b87e7b7a8055bf6c450c2c77ce32a24084',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/cli-parser',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/code-unit' => array(
|
||||
'pretty_version' => '2.0.0',
|
||||
'version' => '2.0.0.0',
|
||||
'reference' => 'a81fee9eef0b7a76af11d121767abc44c104e503',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/code-unit',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/code-unit-reverse-lookup' => array(
|
||||
'pretty_version' => '3.0.0',
|
||||
'version' => '3.0.0.0',
|
||||
'reference' => '5e3a687f7d8ae33fb362c5c0743794bbb2420a1d',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/comparator' => array(
|
||||
'pretty_version' => '5.0.3',
|
||||
'version' => '5.0.3.0',
|
||||
'reference' => 'a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/comparator',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/complexity' => array(
|
||||
'pretty_version' => '3.2.0',
|
||||
'version' => '3.2.0.0',
|
||||
'reference' => '68ff824baeae169ec9f2137158ee529584553799',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/complexity',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/diff' => array(
|
||||
'pretty_version' => '5.1.1',
|
||||
'version' => '5.1.1.0',
|
||||
'reference' => 'c41e007b4b62af48218231d6c2275e4c9b975b2e',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/diff',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/environment' => array(
|
||||
'pretty_version' => '6.1.0',
|
||||
'version' => '6.1.0.0',
|
||||
'reference' => '8074dbcd93529b357029f5cc5058fd3e43666984',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/environment',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/exporter' => array(
|
||||
'pretty_version' => '5.1.2',
|
||||
'version' => '5.1.2.0',
|
||||
'reference' => '955288482d97c19a372d3f31006ab3f37da47adf',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/exporter',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/global-state' => array(
|
||||
'pretty_version' => '6.0.2',
|
||||
'version' => '6.0.2.0',
|
||||
'reference' => '987bafff24ecc4c9ac418cab1145b96dd6e9cbd9',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/global-state',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/lines-of-code' => array(
|
||||
'pretty_version' => '2.0.2',
|
||||
'version' => '2.0.2.0',
|
||||
'reference' => '856e7f6a75a84e339195d48c556f23be2ebf75d0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/lines-of-code',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/object-enumerator' => array(
|
||||
'pretty_version' => '5.0.0',
|
||||
'version' => '5.0.0.0',
|
||||
'reference' => '202d0e344a580d7f7d04b3fafce6933e59dae906',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/object-enumerator',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/object-reflector' => array(
|
||||
'pretty_version' => '3.0.0',
|
||||
'version' => '3.0.0.0',
|
||||
'reference' => '24ed13d98130f0e7122df55d06c5c4942a577957',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/object-reflector',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/recursion-context' => array(
|
||||
'pretty_version' => '5.0.0',
|
||||
'version' => '5.0.0.0',
|
||||
'reference' => '05909fb5bc7df4c52992396d0116aed689f93712',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/recursion-context',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/type' => array(
|
||||
'pretty_version' => '4.0.0',
|
||||
'version' => '4.0.0.0',
|
||||
'reference' => '462699a16464c3944eefc02ebdd77882bd3925bf',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/type',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'sebastian/version' => array(
|
||||
'pretty_version' => '4.0.1',
|
||||
'version' => '4.0.1.0',
|
||||
'reference' => 'c51fa83a5d8f43f1402e3f32a005e6262244ef17',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../sebastian/version',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'simplepie/simplepie' => array(
|
||||
'pretty_version' => '1.8.1',
|
||||
'version' => '1.8.1.0',
|
||||
@@ -622,15 +295,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'squizlabs/php_codesniffer' => array(
|
||||
'pretty_version' => '3.11.3',
|
||||
'version' => '3.11.3.0',
|
||||
'reference' => 'ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../squizlabs/php_codesniffer',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'stephenhill/base58' => array(
|
||||
'pretty_version' => 'v1.1.5',
|
||||
'version' => '1.1.5.0',
|
||||
@@ -640,24 +304,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/config' => array(
|
||||
'pretty_version' => 'v6.4.14',
|
||||
'version' => '6.4.14.0',
|
||||
'reference' => '4e55e7e4ffddd343671ea972216d4509f46c22ef',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/config',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'symfony/dependency-injection' => array(
|
||||
'pretty_version' => 'v6.4.16',
|
||||
'version' => '6.4.16.0',
|
||||
'reference' => '7a379d8871f6a36f01559c14e11141cc02eb8dc8',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/dependency-injection',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'symfony/deprecation-contracts' => array(
|
||||
'pretty_version' => 'v3.5.1',
|
||||
'version' => '3.5.1.0',
|
||||
@@ -667,24 +313,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/filesystem' => array(
|
||||
'pretty_version' => 'v6.4.13',
|
||||
'version' => '6.4.13.0',
|
||||
'reference' => '4856c9cf585d5a0313d8d35afd681a526f038dd3',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/filesystem',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'symfony/polyfill-ctype' => array(
|
||||
'pretty_version' => 'v1.31.0',
|
||||
'version' => '1.31.0.0',
|
||||
'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'symfony/polyfill-mbstring' => array(
|
||||
'pretty_version' => 'v1.31.0',
|
||||
'version' => '1.31.0.0',
|
||||
@@ -694,39 +322,6 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/service-contracts' => array(
|
||||
'pretty_version' => 'v3.5.1',
|
||||
'version' => '3.5.1.0',
|
||||
'reference' => 'e53260aabf78fb3d63f8d79d69ece59f80d5eda0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/service-contracts',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'symfony/service-implementation' => array(
|
||||
'dev_requirement' => true,
|
||||
'provided' => array(
|
||||
0 => '1.1|2.0|3.0',
|
||||
),
|
||||
),
|
||||
'symfony/var-exporter' => array(
|
||||
'pretty_version' => 'v6.4.13',
|
||||
'version' => '6.4.13.0',
|
||||
'reference' => '0f605f72a363f8743001038a176eeb2a11223b51',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/var-exporter',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'theseer/tokenizer' => array(
|
||||
'pretty_version' => '1.2.3',
|
||||
'version' => '1.2.3.0',
|
||||
'reference' => '737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../theseer/tokenizer',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => true,
|
||||
),
|
||||
'twbs/bootstrap' => array(
|
||||
'pretty_version' => 'v5.3.3',
|
||||
'version' => '5.3.3.0',
|
||||
@@ -772,7 +367,7 @@
|
||||
'zotlabs/hubzilla' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'd9b262348facf0f5591a73a8f2518ea9e837691e',
|
||||
'reference' => '65c8de34101cedc33fc8e6282ff11e8e57eeed1b',
|
||||
'type' => 'application',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
||||
25
vendor/symfony/var-exporter/CHANGELOG.md
vendored
25
vendor/symfony/var-exporter/CHANGELOG.md
vendored
@@ -1,25 +0,0 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
6.4
|
||||
---
|
||||
|
||||
* Deprecate per-property lazy-initializers
|
||||
|
||||
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
|
||||
@@ -1,20 +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 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);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +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 Symfony\Component\VarExporter\Exception;
|
||||
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
@@ -1,16 +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 Symfony\Component\VarExporter\Exception;
|
||||
|
||||
class LogicException extends \LogicException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
@@ -1,20 +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 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);
|
||||
}
|
||||
}
|
||||
78
vendor/symfony/var-exporter/Hydrator.php
vendored
78
vendor/symfony/var-exporter/Hydrator.php
vendored
@@ -1,78 +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 Symfony\Component\VarExporter;
|
||||
|
||||
use 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 = $instance::class;
|
||||
$propertyScopes = 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::getSimpleHydrator($scope))($properties, $instance);
|
||||
}
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
59
vendor/symfony/var-exporter/Instantiator.php
vendored
59
vendor/symfony/var-exporter/Instantiator.php
vendored
@@ -1,59 +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 Symfony\Component\VarExporter;
|
||||
|
||||
use Symfony\Component\VarExporter\Exception\ExceptionInterface;
|
||||
use Symfony\Component\VarExporter\Exception\NotInstantiableTypeException;
|
||||
use 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::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;
|
||||
}
|
||||
}
|
||||
419
vendor/symfony/var-exporter/Internal/Exporter.php
vendored
419
vendor/symfony/var-exporter/Internal/Exporter.php
vendored
@@ -1,419 +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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
use 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 = $value::class;
|
||||
$reflector = Registry::$reflectors[$class] ??= Registry::getClassReflector($class);
|
||||
$properties = [];
|
||||
|
||||
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($serializeProperties = $value->__serialize())) {
|
||||
throw new \TypeError($class.'::__serialize() must return an array');
|
||||
}
|
||||
|
||||
if ($reflector->hasMethod('__unserialize')) {
|
||||
$properties = $serializeProperties;
|
||||
} else {
|
||||
foreach ($serializeProperties as $n => $v) {
|
||||
$c = $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass';
|
||||
$properties[$c][$n] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
goto prepare_value;
|
||||
}
|
||||
|
||||
$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' => ["\0" => $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 || "\0" !== $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, "\0", 2);
|
||||
$c = substr($n, 1, $i - 1);
|
||||
$n = substr($n, 1 + $i);
|
||||
}
|
||||
if (null !== $sleep) {
|
||||
if (!isset($sleep[$name]) && (!isset($sleep[$n]) || ($i && $c !== $class))) {
|
||||
unset($arrayValue[$name]);
|
||||
continue;
|
||||
}
|
||||
unset($sleep[$name], $sleep[$n]);
|
||||
}
|
||||
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) {
|
||||
trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $n), \E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
if (method_exists($class, '__unserialize')) {
|
||||
$properties = $arrayValue;
|
||||
}
|
||||
|
||||
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]|\u{202A}|\u{202B}|\u{202D}|\u{202E}|\u{2066}|\u{2067}|\u{2068}|\u{202C}|\u{2069})++)(.)/", function ($m) use ($subIndent) {
|
||||
$m[1] = sprintf('\'."%s".\'', str_replace(
|
||||
["\0", "\r", "\n", "\u{202A}", "\u{202B}", "\u{202D}", "\u{202E}", "\u{2066}", "\u{2067}", "\u{2068}", "\u{202C}", "\u{2069}", '\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 (str_ends_with($m[1], 'n".\'')) {
|
||||
return substr_replace($m[1], "\n".$subIndent.".'".$m[2], -2);
|
||||
}
|
||||
|
||||
return $m[1].$m[2];
|
||||
}, $code, -1, $count);
|
||||
|
||||
if ($count && str_starts_with($code, "''.")) {
|
||||
$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') ? "\0Error\0" : "\0Exception\0";
|
||||
$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 '\\'.$value::class."::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::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 => ["\0" => $properties]];
|
||||
}
|
||||
|
||||
return [$arrayValue, $properties];
|
||||
}
|
||||
}
|
||||
308
vendor/symfony/var-exporter/Internal/Hydrator.php
vendored
308
vendor/symfony/var-exporter/Internal/Hydrator.php
vendored
@@ -1,308 +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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
use Symfony\Component\VarExporter\Exception\ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hydrator
|
||||
{
|
||||
public static array $hydrators = [];
|
||||
public static array $simpleHydrators = [];
|
||||
public static array $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::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'] ??= 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 ("\0" === $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 = $classReflector->getConstructor()->invokeArgs(...);
|
||||
|
||||
return static function ($properties, $objects) use ($constructor) {
|
||||
foreach ($properties as $name => $values) {
|
||||
if ("\0" !== $name) {
|
||||
foreach ($values as $i => $v) {
|
||||
$objects[$i]->$name = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($properties["\0"] ?? [] 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::getHydrator($classReflector->name);
|
||||
}
|
||||
|
||||
$propertySetters = [];
|
||||
foreach ($classReflector->getProperties() as $propertyReflector) {
|
||||
if (!$propertyReflector->isStatic()) {
|
||||
$propertySetters[$propertyReflector->name] = $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'] ??= (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 ("\0" !== $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 = $classReflector->getConstructor()->invokeArgs(...);
|
||||
|
||||
return static function ($properties, $object) use ($constructor) {
|
||||
foreach ($properties as $name => &$value) {
|
||||
if ("\0" === $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::getSimpleHydrator($classReflector->name);
|
||||
}
|
||||
|
||||
$propertySetters = [];
|
||||
foreach ($classReflector->getProperties() as $propertyReflector) {
|
||||
if (!$propertyReflector->isStatic()) {
|
||||
$propertySetters[$propertyReflector->name] = $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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
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) {
|
||||
$readonlyScope = null;
|
||||
if ($flags & \ReflectionProperty::IS_READONLY) {
|
||||
$readonlyScope = $class;
|
||||
}
|
||||
$propertyScopes["\0$class\0$name"] = $propertyScopes[$name] = [$class, $name, $readonlyScope, $property];
|
||||
|
||||
continue;
|
||||
}
|
||||
$readonlyScope = null;
|
||||
if ($flags & \ReflectionProperty::IS_READONLY) {
|
||||
$readonlyScope = $property->class;
|
||||
}
|
||||
$propertyScopes[$name] = [$class, $name, $readonlyScope, $property];
|
||||
|
||||
if (\ReflectionProperty::IS_PROTECTED & $flags) {
|
||||
$propertyScopes["\0*\0$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["\0$class\0$name"] = [$class, $name, $readonlyScope, $property];
|
||||
$propertyScopes[$name] ??= [$class, $name, $readonlyScope, $property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $propertyScopes;
|
||||
}
|
||||
}
|
||||
@@ -1,146 +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 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<class-string, \ReflectionClass>
|
||||
*/
|
||||
public static array $classReflectors = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string, array<string, mixed>>
|
||||
*/
|
||||
public static array $defaultProperties = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string, list<\Closure>>
|
||||
*/
|
||||
public static array $classResetters = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string, array{get: \Closure, set: \Closure, isset: \Closure, unset: \Closure}>
|
||||
*/
|
||||
public static array $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 array $parentMethods = [];
|
||||
|
||||
public static ?\Closure $noInitializerState = null;
|
||||
|
||||
public static function getClassResetters($class)
|
||||
{
|
||||
$classProperties = [];
|
||||
|
||||
if ((self::$classReflectors[$class] ??= new \ReflectionClass($class))->isInternal()) {
|
||||
$propertyScopes = [];
|
||||
} else {
|
||||
$propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class);
|
||||
}
|
||||
|
||||
foreach ($propertyScopes as $key => [$scope, $name, $readonlyScope]) {
|
||||
$propertyScopes[$k = "\0$scope\0$name"] ?? $propertyScopes[$k = "\0*\0$name"] ?? $k = $name;
|
||||
|
||||
if ($k === $key && "\0$class\0lazyObjectState" !== $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 ("\0" !== ($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 fn () => [
|
||||
'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 fn ($instance, $name) => 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 = "\0$class\0$property"]) && !isset($propertyScopes[$k = "\0*\0$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) && !isset($propertyScopes["\0$scope\0$property"])))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $scope;
|
||||
}
|
||||
}
|
||||
@@ -1,133 +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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
use 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>
|
||||
*/
|
||||
public readonly array $skippedProperties;
|
||||
|
||||
/**
|
||||
* @var self::STATUS_*
|
||||
*/
|
||||
public int $status = 0;
|
||||
|
||||
public object $realInstance;
|
||||
|
||||
public function __construct(public readonly \Closure|array $initializer, $skippedProperties = [])
|
||||
{
|
||||
$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 = $instance::class;
|
||||
$propertyScope ??= $class;
|
||||
$propertyScopes = Hydrator::$propertyScopes[$class];
|
||||
$propertyScopes[$k = "\0$propertyScope\0$propertyName"] ?? $propertyScopes[$k = "\0*\0$propertyName"] ?? $k = $propertyName;
|
||||
|
||||
if ($initializer = $this->initializer[$k] ?? null) {
|
||||
$value = $initializer(...[$instance, $propertyName, $propertyScope, LazyObjectRegistry::$defaultProperties[$class][$k] ?? null]);
|
||||
$accessor = LazyObjectRegistry::$classAccessors[$propertyScope] ??= LazyObjectRegistry::getClassAccessors($propertyScope);
|
||||
$accessor['set']($instance, $propertyName, $value);
|
||||
|
||||
return $this->status = self::STATUS_INITIALIZED_PARTIAL;
|
||||
}
|
||||
|
||||
if ($initializer = $this->initializer["\0"] ?? 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 (!\array_key_exists($key, $properties) && [$scope, $name, $readonlyScope] = $propertyScopes[$key] ?? null) {
|
||||
$scope = $readonlyScope ?? ('*' !== $scope ? $scope : $class);
|
||||
$accessor = LazyObjectRegistry::$classAccessors[$scope] ??= LazyObjectRegistry::getClassAccessors($scope);
|
||||
$accessor['set']($instance, $name, $value);
|
||||
|
||||
if ($k === $key) {
|
||||
$this->status = self::STATUS_INITIALIZED_PARTIAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
if (self::STATUS_INITIALIZED_PARTIAL === $this->status) {
|
||||
return self::STATUS_INITIALIZED_PARTIAL;
|
||||
}
|
||||
|
||||
$this->status = self::STATUS_INITIALIZED_PARTIAL;
|
||||
|
||||
try {
|
||||
if ($defaultProperties = array_diff_key(LazyObjectRegistry::$defaultProperties[$instance::class], $this->skippedProperties)) {
|
||||
PublicHydrator::hydrate($instance, $defaultProperties);
|
||||
}
|
||||
|
||||
($this->initializer)($instance);
|
||||
} catch (\Throwable $e) {
|
||||
$this->status = self::STATUS_UNINITIALIZED_FULL;
|
||||
$this->reset($instance);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $this->status = self::STATUS_INITIALIZED_FULL;
|
||||
}
|
||||
|
||||
public function reset($instance): void
|
||||
{
|
||||
$class = $instance::class;
|
||||
$propertyScopes = 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 = "\0$scope\0$name"] ?? $propertyScopes[$k = "\0*\0$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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Ignore;
|
||||
|
||||
if (\PHP_VERSION_ID >= 80300) {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait LazyObjectTrait
|
||||
{
|
||||
#[Ignore]
|
||||
private readonly LazyObjectState $lazyObjectState;
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait LazyObjectTrait
|
||||
{
|
||||
#[Ignore]
|
||||
private LazyObjectState $lazyObjectState;
|
||||
}
|
||||
}
|
||||
@@ -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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Reference
|
||||
{
|
||||
public int $count = 0;
|
||||
|
||||
public function __construct(
|
||||
public readonly int $id,
|
||||
public readonly mixed $value = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
144
vendor/symfony/var-exporter/Internal/Registry.php
vendored
144
vendor/symfony/var-exporter/Internal/Registry.php
vendored
@@ -1,144 +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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
use Symfony\Component\VarExporter\Exception\ClassNotFoundException;
|
||||
use Symfony\Component\VarExporter\Exception\NotInstantiableTypeException;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Registry
|
||||
{
|
||||
public static array $reflectors = [];
|
||||
public static array $prototypes = [];
|
||||
public static array $factories = [];
|
||||
public static array $cloneable = [];
|
||||
public static array $instantiableWithoutConstructor = [];
|
||||
|
||||
public $classes = [];
|
||||
|
||||
public function __construct(array $classes)
|
||||
{
|
||||
$this->classes = $classes;
|
||||
}
|
||||
|
||||
public static function unserialize($objects, $serializables)
|
||||
{
|
||||
$unserializeCallback = ini_set('unserialize_callback_func', __CLASS__.'::getClassReflector');
|
||||
|
||||
try {
|
||||
foreach ($serializables as $k => $v) {
|
||||
$objects[$k] = unserialize($v);
|
||||
}
|
||||
} finally {
|
||||
ini_set('unserialize_callback_func', $unserializeCallback);
|
||||
}
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public static function p($class)
|
||||
{
|
||||
self::getClassReflector($class, true, true);
|
||||
|
||||
return self::$prototypes[$class];
|
||||
}
|
||||
|
||||
public static function f($class)
|
||||
{
|
||||
$reflector = self::$reflectors[$class] ??= self::getClassReflector($class, true, false);
|
||||
|
||||
return self::$factories[$class] = [$reflector, 'newInstanceWithoutConstructor'](...);
|
||||
}
|
||||
|
||||
public static function getClassReflector($class, $instantiableWithoutConstructor = false, $cloneable = null)
|
||||
{
|
||||
if (!($isClass = class_exists($class)) && !interface_exists($class, false) && !trait_exists($class, false)) {
|
||||
throw new ClassNotFoundException($class);
|
||||
}
|
||||
$reflector = new \ReflectionClass($class);
|
||||
|
||||
if ($instantiableWithoutConstructor) {
|
||||
$proto = $reflector->newInstanceWithoutConstructor();
|
||||
} elseif (!$isClass || $reflector->isAbstract()) {
|
||||
throw new NotInstantiableTypeException($class);
|
||||
} elseif ($reflector->name !== $class) {
|
||||
$reflector = self::$reflectors[$name = $reflector->name] ??= self::getClassReflector($name, false, $cloneable);
|
||||
self::$cloneable[$class] = self::$cloneable[$name];
|
||||
self::$instantiableWithoutConstructor[$class] = self::$instantiableWithoutConstructor[$name];
|
||||
self::$prototypes[$class] = self::$prototypes[$name];
|
||||
|
||||
return $reflector;
|
||||
} else {
|
||||
try {
|
||||
$proto = $reflector->newInstanceWithoutConstructor();
|
||||
$instantiableWithoutConstructor = true;
|
||||
} catch (\ReflectionException) {
|
||||
$proto = $reflector->implementsInterface('Serializable') && !method_exists($class, '__unserialize') ? 'C:' : 'O:';
|
||||
if ('C:' === $proto && !$reflector->getMethod('unserialize')->isInternal()) {
|
||||
$proto = null;
|
||||
} else {
|
||||
try {
|
||||
$proto = @unserialize($proto.\strlen($class).':"'.$class.'":0:{}');
|
||||
} catch (\Exception $e) {
|
||||
if (__FILE__ !== $e->getFile()) {
|
||||
throw $e;
|
||||
}
|
||||
throw new NotInstantiableTypeException($class, $e);
|
||||
}
|
||||
if (false === $proto) {
|
||||
throw new NotInstantiableTypeException($class);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && !method_exists($class, '__serialize')) {
|
||||
try {
|
||||
serialize($proto);
|
||||
} catch (\Exception $e) {
|
||||
throw new NotInstantiableTypeException($class, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $cloneable) {
|
||||
if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !method_exists($proto, '__wakeup') && !method_exists($class, '__unserialize'))) {
|
||||
throw new NotInstantiableTypeException($class);
|
||||
}
|
||||
|
||||
$cloneable = $reflector->isCloneable() && !$reflector->hasMethod('__clone');
|
||||
}
|
||||
|
||||
self::$cloneable[$class] = $cloneable;
|
||||
self::$instantiableWithoutConstructor[$class] = $instantiableWithoutConstructor;
|
||||
self::$prototypes[$class] = $proto;
|
||||
|
||||
if ($proto instanceof \Throwable) {
|
||||
static $setTrace;
|
||||
|
||||
if (null === $setTrace) {
|
||||
$setTrace = [
|
||||
new \ReflectionProperty(\Error::class, 'trace'),
|
||||
new \ReflectionProperty(\Exception::class, 'trace'),
|
||||
];
|
||||
$setTrace[0] = $setTrace[0]->setValue(...);
|
||||
$setTrace[1] = $setTrace[1]->setValue(...);
|
||||
}
|
||||
|
||||
$setTrace[$proto instanceof \Exception]($proto, []);
|
||||
}
|
||||
|
||||
return $reflector;
|
||||
}
|
||||
}
|
||||
27
vendor/symfony/var-exporter/Internal/Values.php
vendored
27
vendor/symfony/var-exporter/Internal/Values.php
vendored
@@ -1,27 +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 Symfony\Component\VarExporter\Internal;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Values
|
||||
{
|
||||
public $values;
|
||||
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/var-exporter/LICENSE
vendored
19
vendor/symfony/var-exporter/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2018-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
403
vendor/symfony/var-exporter/LazyGhostTrait.php
vendored
403
vendor/symfony/var-exporter/LazyGhostTrait.php
vendored
@@ -1,403 +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 Symfony\Component\VarExporter;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Ignore;
|
||||
use Symfony\Component\VarExporter\Internal\Hydrator;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectRegistry as Registry;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectState;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectTrait;
|
||||
|
||||
trait LazyGhostTrait
|
||||
{
|
||||
use LazyObjectTrait;
|
||||
|
||||
/**
|
||||
* Creates a lazy-loading ghost instance.
|
||||
*
|
||||
* Skipped properties should be indexed by their array-cast identifier, see
|
||||
* https://php.net/manual/language.types.array#language.types.array.casting
|
||||
*
|
||||
* @param (\Closure(static):void $initializer The closure should initialize the object it receives as argument
|
||||
* @param array<string, true>|null $skippedProperties An array indexed by the properties to skip, a.k.a. the ones
|
||||
* that the initializer doesn't initialize, if any
|
||||
* @param static|null $instance
|
||||
*/
|
||||
public static function createLazyGhost(\Closure|array $initializer, ?array $skippedProperties = null, ?object $instance = null): static
|
||||
{
|
||||
if (\is_array($initializer)) {
|
||||
trigger_deprecation('symfony/var-exporter', '6.4', 'Per-property lazy-initializers are deprecated and won\'t be supported anymore in 7.0, use an object initializer instead.');
|
||||
}
|
||||
|
||||
$onlyProperties = null === $skippedProperties && \is_array($initializer) ? $initializer : null;
|
||||
|
||||
if (self::class !== $class = $instance ? $instance::class : static::class) {
|
||||
$skippedProperties["\0".self::class."\0lazyObjectState"] = true;
|
||||
} elseif (\defined($class.'::LAZY_OBJECT_PROPERTY_SCOPES')) {
|
||||
Hydrator::$propertyScopes[$class] ??= $class::LAZY_OBJECT_PROPERTY_SCOPES;
|
||||
}
|
||||
|
||||
$instance ??= (Registry::$classReflectors[$class] ??= new \ReflectionClass($class))->newInstanceWithoutConstructor();
|
||||
Registry::$defaultProperties[$class] ??= (array) $instance;
|
||||
$instance->lazyObjectState = new LazyObjectState($initializer, $skippedProperties ??= []);
|
||||
|
||||
foreach (Registry::$classResetters[$class] ??= Registry::getClassResetters($class) as $reset) {
|
||||
$reset($instance, $skippedProperties, $onlyProperties);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is initialized.
|
||||
*
|
||||
* @param $partial Whether partially initialized objects should be considered as initialized
|
||||
*/
|
||||
#[Ignore]
|
||||
public function isLazyObjectInitialized(bool $partial = false): bool
|
||||
{
|
||||
if (!$state = $this->lazyObjectState ?? null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!\is_array($state->initializer)) {
|
||||
return LazyObjectState::STATUS_INITIALIZED_FULL === $state->status;
|
||||
}
|
||||
|
||||
$class = $this::class;
|
||||
$properties = (array) $this;
|
||||
|
||||
if ($partial) {
|
||||
return (bool) array_intersect_key($state->initializer, $properties);
|
||||
}
|
||||
|
||||
$propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class);
|
||||
foreach ($state->initializer as $key => $initializer) {
|
||||
if (!\array_key_exists($key, $properties) && isset($propertyScopes[$key])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces initialization of a lazy object and returns it.
|
||||
*/
|
||||
public function initializeLazyObject(): static
|
||||
{
|
||||
if (!$state = $this->lazyObjectState ?? null) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!\is_array($state->initializer)) {
|
||||
if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $state->status) {
|
||||
$state->initialize($this, '', null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$values = isset($state->initializer["\0"]) ? null : [];
|
||||
|
||||
$class = $this::class;
|
||||
$properties = (array) $this;
|
||||
$propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class);
|
||||
foreach ($state->initializer as $key => $initializer) {
|
||||
if (\array_key_exists($key, $properties) || ![$scope, $name, $readonlyScope] = $propertyScopes[$key] ?? null) {
|
||||
continue;
|
||||
}
|
||||
$scope = $readonlyScope ?? ('*' !== $scope ? $scope : $class);
|
||||
|
||||
if (null === $values) {
|
||||
if (!\is_array($values = ($state->initializer["\0"])($this, Registry::$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)));
|
||||
}
|
||||
|
||||
if (\array_key_exists($key, $properties = (array) $this)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (\array_key_exists($key, $values)) {
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
$accessor['set']($this, $name, $properties[$key] = $values[$key]);
|
||||
} else {
|
||||
$state->initialize($this, $name, $scope);
|
||||
$properties = (array) $this;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Returns false when the object cannot be reset, ie when it's not a lazy object
|
||||
*/
|
||||
public function resetLazyObject(): bool
|
||||
{
|
||||
if (!$state = $this->lazyObjectState ?? null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LazyObjectState::STATUS_UNINITIALIZED_FULL !== $state->status) {
|
||||
$state->reset($this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function &__get($name): mixed
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name);
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if ($state && (null === $scope || isset($propertyScopes["\0$scope\0$name"]))) {
|
||||
if (LazyObjectState::STATUS_INITIALIZED_FULL === $state->status) {
|
||||
// Work around php/php-src#12695
|
||||
$property = null === $scope ? $name : "\0$scope\0$name";
|
||||
$property = $propertyScopes[$property][3]
|
||||
?? Hydrator::$propertyScopes[$this::class][$property][3] = new \ReflectionProperty($scope ?? $class, $name);
|
||||
} else {
|
||||
$property = null;
|
||||
}
|
||||
|
||||
if ($property?->isInitialized($this) ?? LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $state->initialize($this, $name, $readonlyScope ?? $scope)) {
|
||||
goto get_in_scope;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent = (Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['get']) {
|
||||
if (2 === $parent) {
|
||||
return parent::__get($name);
|
||||
}
|
||||
$value = parent::__get($name);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (null === $class) {
|
||||
$frame = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
|
||||
trigger_error(sprintf('Undefined property: %s::$%s in %s on line %s', $this::class, $name, $frame['file'], $frame['line']), \E_USER_NOTICE);
|
||||
}
|
||||
|
||||
get_in_scope:
|
||||
|
||||
try {
|
||||
if (null === $scope) {
|
||||
if (null === $readonlyScope) {
|
||||
return $this->$name;
|
||||
}
|
||||
$value = $this->$name;
|
||||
|
||||
return $value;
|
||||
}
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
|
||||
return $accessor['get']($this, $name, null !== $readonlyScope);
|
||||
} catch (\Error $e) {
|
||||
if (\Error::class !== $e::class || !str_starts_with($e->getMessage(), 'Cannot access uninitialized non-nullable property')) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try {
|
||||
if (null === $scope) {
|
||||
$this->$name = [];
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
$accessor['set']($this, $name, []);
|
||||
|
||||
return $accessor['get']($this, $name, null !== $readonlyScope);
|
||||
} catch (\Error) {
|
||||
if (preg_match('/^Cannot access uninitialized non-nullable property ([^ ]++) by reference$/', $e->getMessage(), $matches)) {
|
||||
throw new \Error('Typed property '.$matches[1].' must not be accessed before initialization', $e->getCode(), $e->getPrevious());
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __set($name, $value): void
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope);
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if ($state && ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"]))
|
||||
&& LazyObjectState::STATUS_INITIALIZED_FULL !== $state->status
|
||||
) {
|
||||
if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $state->status) {
|
||||
$state->initialize($this, $name, $readonlyScope ?? $scope);
|
||||
}
|
||||
goto set_in_scope;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['set']) {
|
||||
parent::__set($name, $value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
set_in_scope:
|
||||
|
||||
if (null === $scope) {
|
||||
$this->$name = $value;
|
||||
} else {
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
$accessor['set']($this, $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function __isset($name): bool
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name);
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if ($state && (null === $scope || isset($propertyScopes["\0$scope\0$name"]))
|
||||
&& LazyObjectState::STATUS_INITIALIZED_FULL !== $state->status
|
||||
&& LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $state->initialize($this, $name, $readonlyScope ?? $scope)
|
||||
) {
|
||||
goto isset_in_scope;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['isset']) {
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
isset_in_scope:
|
||||
|
||||
if (null === $scope) {
|
||||
return isset($this->$name);
|
||||
}
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
|
||||
return $accessor['isset']($this, $name);
|
||||
}
|
||||
|
||||
public function __unset($name): void
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope);
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if ($state && ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"]))
|
||||
&& LazyObjectState::STATUS_INITIALIZED_FULL !== $state->status
|
||||
) {
|
||||
if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $state->status) {
|
||||
$state->initialize($this, $name, $readonlyScope ?? $scope);
|
||||
}
|
||||
goto unset_in_scope;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['unset']) {
|
||||
parent::__unset($name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unset_in_scope:
|
||||
|
||||
if (null === $scope) {
|
||||
unset($this->$name);
|
||||
} else {
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
$accessor['unset']($this, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public function __clone(): void
|
||||
{
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$this->lazyObjectState = clone $state;
|
||||
}
|
||||
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) {
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
$class = self::class;
|
||||
|
||||
if ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) {
|
||||
$properties = parent::__serialize();
|
||||
} else {
|
||||
$this->initializeLazyObject();
|
||||
$properties = (array) $this;
|
||||
}
|
||||
unset($properties["\0$class\0lazyObjectState"]);
|
||||
|
||||
if (Registry::$parentMethods[$class]['serialize'] || !Registry::$parentMethods[$class]['sleep']) {
|
||||
return $properties;
|
||||
}
|
||||
|
||||
$scope = get_parent_class($class);
|
||||
$data = [];
|
||||
|
||||
foreach (parent::__sleep() as $name) {
|
||||
$value = $properties[$k = $name] ?? $properties[$k = "\0*\0$name"] ?? $properties[$k = "\0$class\0$name"] ?? $properties[$k = "\0$scope\0$name"] ?? $k = null;
|
||||
|
||||
if (null === $k) {
|
||||
trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $name), \E_USER_NOTICE);
|
||||
} else {
|
||||
$data[$k] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if ($state && \in_array($state->status, [LazyObjectState::STATUS_UNINITIALIZED_FULL, LazyObjectState::STATUS_UNINITIALIZED_PARTIAL], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['destruct']) {
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
private function setLazyObjectAsInitialized(bool $initialized): void
|
||||
{
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if ($state && !\is_array($state->initializer)) {
|
||||
$state->status = $initialized ? LazyObjectState::STATUS_INITIALIZED_FULL : LazyObjectState::STATUS_UNINITIALIZED_FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +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 Symfony\Component\VarExporter;
|
||||
|
||||
interface LazyObjectInterface
|
||||
{
|
||||
/**
|
||||
* Returns whether the object is initialized.
|
||||
*
|
||||
* @param $partial Whether partially initialized objects should be considered as initialized
|
||||
*/
|
||||
public function isLazyObjectInitialized(bool $partial = false): bool;
|
||||
|
||||
/**
|
||||
* Forces initialization of a lazy object and returns it.
|
||||
*/
|
||||
public function initializeLazyObject(): object;
|
||||
|
||||
/**
|
||||
* @return bool Returns false when the object cannot be reset, ie when it's not a lazy object
|
||||
*/
|
||||
public function resetLazyObject(): bool;
|
||||
}
|
||||
349
vendor/symfony/var-exporter/LazyProxyTrait.php
vendored
349
vendor/symfony/var-exporter/LazyProxyTrait.php
vendored
@@ -1,349 +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 Symfony\Component\VarExporter;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Ignore;
|
||||
use Symfony\Component\VarExporter\Hydrator as PublicHydrator;
|
||||
use Symfony\Component\VarExporter\Internal\Hydrator;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectRegistry as Registry;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectState;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectTrait;
|
||||
|
||||
trait LazyProxyTrait
|
||||
{
|
||||
use LazyObjectTrait;
|
||||
|
||||
/**
|
||||
* Creates a lazy-loading virtual proxy.
|
||||
*
|
||||
* @param \Closure():object $initializer Returns the proxied object
|
||||
* @param static|null $instance
|
||||
*/
|
||||
public static function createLazyProxy(\Closure $initializer, ?object $instance = null): static
|
||||
{
|
||||
if (self::class !== $class = $instance ? $instance::class : static::class) {
|
||||
$skippedProperties = ["\0".self::class."\0lazyObjectState" => true];
|
||||
} elseif (\defined($class.'::LAZY_OBJECT_PROPERTY_SCOPES')) {
|
||||
Hydrator::$propertyScopes[$class] ??= $class::LAZY_OBJECT_PROPERTY_SCOPES;
|
||||
}
|
||||
|
||||
$instance ??= (Registry::$classReflectors[$class] ??= new \ReflectionClass($class))->newInstanceWithoutConstructor();
|
||||
$instance->lazyObjectState = new LazyObjectState($initializer);
|
||||
|
||||
foreach (Registry::$classResetters[$class] ??= Registry::getClassResetters($class) as $reset) {
|
||||
$reset($instance, $skippedProperties ??= []);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is initialized.
|
||||
*
|
||||
* @param $partial Whether partially initialized objects should be considered as initialized
|
||||
*/
|
||||
#[Ignore]
|
||||
public function isLazyObjectInitialized(bool $partial = false): bool
|
||||
{
|
||||
return !isset($this->lazyObjectState) || isset($this->lazyObjectState->realInstance) || Registry::$noInitializerState === $this->lazyObjectState->initializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces initialization of a lazy object and returns it.
|
||||
*/
|
||||
public function initializeLazyObject(): parent
|
||||
{
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
return $state->realInstance ??= ($state->initializer)();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Returns false when the object cannot be reset, ie when it's not a lazy object
|
||||
*/
|
||||
public function resetLazyObject(): bool
|
||||
{
|
||||
if (!isset($this->lazyObjectState) || Registry::$noInitializerState === $this->lazyObjectState->initializer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->lazyObjectState->realInstance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function &__get($name): mixed
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
$instance = $this;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name);
|
||||
|
||||
if (null === $scope || isset($propertyScopes["\0$scope\0$name"])) {
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
}
|
||||
$parent = 2;
|
||||
goto get_in_scope;
|
||||
}
|
||||
}
|
||||
$parent = (Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['get'];
|
||||
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
} else {
|
||||
if (2 === $parent) {
|
||||
return parent::__get($name);
|
||||
}
|
||||
$value = parent::__get($name);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$parent && null === $class && !\array_key_exists($name, (array) $instance)) {
|
||||
$frame = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
|
||||
trigger_error(sprintf('Undefined property: %s::$%s in %s on line %s', $instance::class, $name, $frame['file'], $frame['line']), \E_USER_NOTICE);
|
||||
}
|
||||
|
||||
get_in_scope:
|
||||
|
||||
try {
|
||||
if (null === $scope) {
|
||||
if (null === $readonlyScope && 1 !== $parent) {
|
||||
return $instance->$name;
|
||||
}
|
||||
$value = $instance->$name;
|
||||
|
||||
return $value;
|
||||
}
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
|
||||
return $accessor['get']($instance, $name, null !== $readonlyScope || 1 === $parent);
|
||||
} catch (\Error $e) {
|
||||
if (\Error::class !== $e::class || !str_starts_with($e->getMessage(), 'Cannot access uninitialized non-nullable property')) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try {
|
||||
if (null === $scope) {
|
||||
$instance->$name = [];
|
||||
|
||||
return $instance->$name;
|
||||
}
|
||||
|
||||
$accessor['set']($instance, $name, []);
|
||||
|
||||
return $accessor['get']($instance, $name, null !== $readonlyScope || 1 === $parent);
|
||||
} catch (\Error) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __set($name, $value): void
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
$instance = $this;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope);
|
||||
|
||||
if ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"])) {
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
}
|
||||
goto set_in_scope;
|
||||
}
|
||||
}
|
||||
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
} elseif ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['set']) {
|
||||
parent::__set($name, $value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
set_in_scope:
|
||||
|
||||
if (null === $scope) {
|
||||
$instance->$name = $value;
|
||||
} else {
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
$accessor['set']($instance, $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function __isset($name): bool
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
$instance = $this;
|
||||
|
||||
if ([$class] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name);
|
||||
|
||||
if (null === $scope || isset($propertyScopes["\0$scope\0$name"])) {
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
}
|
||||
goto isset_in_scope;
|
||||
}
|
||||
}
|
||||
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
} elseif ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['isset']) {
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
isset_in_scope:
|
||||
|
||||
if (null === $scope) {
|
||||
return isset($instance->$name);
|
||||
}
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
|
||||
return $accessor['isset']($instance, $name);
|
||||
}
|
||||
|
||||
public function __unset($name): void
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class);
|
||||
$scope = null;
|
||||
$instance = $this;
|
||||
|
||||
if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) {
|
||||
$scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope);
|
||||
|
||||
if ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"])) {
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
}
|
||||
goto unset_in_scope;
|
||||
}
|
||||
}
|
||||
|
||||
if ($state = $this->lazyObjectState ?? null) {
|
||||
$instance = $state->realInstance ??= ($state->initializer)();
|
||||
} elseif ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['unset']) {
|
||||
parent::__unset($name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unset_in_scope:
|
||||
|
||||
if (null === $scope) {
|
||||
unset($instance->$name);
|
||||
} else {
|
||||
$accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
|
||||
$accessor['unset']($instance, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public function __clone(): void
|
||||
{
|
||||
if (!isset($this->lazyObjectState)) {
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) {
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->lazyObjectState = clone $this->lazyObjectState;
|
||||
|
||||
if (isset($this->lazyObjectState->realInstance)) {
|
||||
$this->lazyObjectState->realInstance = clone $this->lazyObjectState->realInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
$class = self::class;
|
||||
$state = $this->lazyObjectState ?? null;
|
||||
|
||||
if (!$state && (Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) {
|
||||
$properties = parent::__serialize();
|
||||
} else {
|
||||
$properties = (array) $this;
|
||||
|
||||
if ($state) {
|
||||
unset($properties["\0$class\0lazyObjectState"]);
|
||||
$properties["\0$class\0lazyObjectReal"] = $state->realInstance ??= ($state->initializer)();
|
||||
}
|
||||
}
|
||||
|
||||
if ($state || Registry::$parentMethods[$class]['serialize'] || !Registry::$parentMethods[$class]['sleep']) {
|
||||
return $properties;
|
||||
}
|
||||
|
||||
$scope = get_parent_class($class);
|
||||
$data = [];
|
||||
|
||||
foreach (parent::__sleep() as $name) {
|
||||
$value = $properties[$k = $name] ?? $properties[$k = "\0*\0$name"] ?? $properties[$k = "\0$class\0$name"] ?? $properties[$k = "\0$scope\0$name"] ?? $k = null;
|
||||
|
||||
if (null === $k) {
|
||||
trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $name), \E_USER_NOTICE);
|
||||
} else {
|
||||
$data[$k] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
$class = self::class;
|
||||
|
||||
if ($instance = $data["\0$class\0lazyObjectReal"] ?? null) {
|
||||
unset($data["\0$class\0lazyObjectReal"]);
|
||||
|
||||
foreach (Registry::$classResetters[$class] ??= Registry::getClassResetters($class) as $reset) {
|
||||
$reset($this, $data);
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
PublicHydrator::hydrate($this, $data);
|
||||
}
|
||||
$this->lazyObjectState = new LazyObjectState(Registry::$noInitializerState ??= static fn () => throw new \LogicException('Lazy proxy has no initializer.'));
|
||||
$this->lazyObjectState->realInstance = $instance;
|
||||
} elseif ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['unserialize']) {
|
||||
parent::__unserialize($data);
|
||||
} else {
|
||||
PublicHydrator::hydrate($this, $data);
|
||||
|
||||
if (Registry::$parentMethods[$class]['wakeup']) {
|
||||
parent::__wakeup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (isset($this->lazyObjectState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['destruct']) {
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
413
vendor/symfony/var-exporter/ProxyHelper.php
vendored
413
vendor/symfony/var-exporter/ProxyHelper.php
vendored
@@ -1,413 +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 Symfony\Component\VarExporter;
|
||||
|
||||
use Symfony\Component\VarExporter\Exception\LogicException;
|
||||
use Symfony\Component\VarExporter\Internal\Hydrator;
|
||||
use Symfony\Component\VarExporter\Internal\LazyObjectRegistry;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
final class ProxyHelper
|
||||
{
|
||||
/**
|
||||
* Helps generate lazy-loading ghost objects.
|
||||
*
|
||||
* @throws LogicException When the class is incompatible with ghost objects
|
||||
*/
|
||||
public static function generateLazyGhost(\ReflectionClass $class): string
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80300 && $class->isReadOnly()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost with PHP < 8.3: class "%s" is readonly.', $class->name));
|
||||
}
|
||||
if ($class->isFinal()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is final.', $class->name));
|
||||
}
|
||||
if ($class->isInterface() || $class->isAbstract()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost: "%s" is not a concrete class.', $class->name));
|
||||
}
|
||||
if (\stdClass::class !== $class->name && $class->isInternal()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is internal.', $class->name));
|
||||
}
|
||||
if ($class->hasMethod('__get') && 'mixed' !== (self::exportType($class->getMethod('__get')) ?? 'mixed')) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost: return type of method "%s::__get()" should be "mixed".', $class->name));
|
||||
}
|
||||
|
||||
static $traitMethods;
|
||||
$traitMethods ??= (new \ReflectionClass(LazyGhostTrait::class))->getMethods();
|
||||
|
||||
foreach ($traitMethods as $method) {
|
||||
if ($class->hasMethod($method->name) && $class->getMethod($method->name)->isFinal()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost: method "%s::%s()" is final.', $class->name, $method->name));
|
||||
}
|
||||
}
|
||||
|
||||
$parent = $class;
|
||||
while ($parent = $parent->getParentClass()) {
|
||||
if (\stdClass::class !== $parent->name && $parent->isInternal()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" extends "%s" which is internal.', $class->name, $parent->name));
|
||||
}
|
||||
}
|
||||
$propertyScopes = self::exportPropertyScopes($class->name);
|
||||
|
||||
return <<<EOPHP
|
||||
extends \\{$class->name} implements \Symfony\Component\VarExporter\LazyObjectInterface
|
||||
{
|
||||
use \Symfony\Component\VarExporter\LazyGhostTrait;
|
||||
|
||||
private const LAZY_OBJECT_PROPERTY_SCOPES = {$propertyScopes};
|
||||
}
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
|
||||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
|
||||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
|
||||
|
||||
EOPHP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helps generate lazy-loading virtual proxies.
|
||||
*
|
||||
* @param \ReflectionClass[] $interfaces
|
||||
*
|
||||
* @throws LogicException When the class is incompatible with virtual proxies
|
||||
*/
|
||||
public static function generateLazyProxy(?\ReflectionClass $class, array $interfaces = []): string
|
||||
{
|
||||
if (!class_exists($class?->name ?? \stdClass::class, false)) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy proxy: "%s" is not a class.', $class->name));
|
||||
}
|
||||
if ($class?->isFinal()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy proxy: class "%s" is final.', $class->name));
|
||||
}
|
||||
if (\PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80300 && $class?->isReadOnly()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy proxy with PHP < 8.3: class "%s" is readonly.', $class->name));
|
||||
}
|
||||
|
||||
$methodReflectors = [$class?->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) ?? []];
|
||||
foreach ($interfaces as $interface) {
|
||||
if (!$interface->isInterface()) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy proxy: "%s" is not an interface.', $interface->name));
|
||||
}
|
||||
$methodReflectors[] = $interface->getMethods();
|
||||
}
|
||||
$methodReflectors = array_merge(...$methodReflectors);
|
||||
|
||||
$extendsInternalClass = false;
|
||||
if ($parent = $class) {
|
||||
do {
|
||||
$extendsInternalClass = \stdClass::class !== $parent->name && $parent->isInternal();
|
||||
} while (!$extendsInternalClass && $parent = $parent->getParentClass());
|
||||
}
|
||||
$methodsHaveToBeProxied = $extendsInternalClass;
|
||||
$methods = [];
|
||||
|
||||
foreach ($methodReflectors as $method) {
|
||||
if ('__get' !== strtolower($method->name) || 'mixed' === ($type = self::exportType($method) ?? 'mixed')) {
|
||||
continue;
|
||||
}
|
||||
$methodsHaveToBeProxied = true;
|
||||
$trait = new \ReflectionMethod(LazyProxyTrait::class, '__get');
|
||||
$body = \array_slice(file($trait->getFileName()), $trait->getStartLine() - 1, $trait->getEndLine() - $trait->getStartLine());
|
||||
$body[0] = str_replace('): mixed', '): '.$type, $body[0]);
|
||||
$methods['__get'] = strtr(implode('', $body).' }', [
|
||||
'Hydrator' => '\\'.Hydrator::class,
|
||||
'Registry' => '\\'.LazyObjectRegistry::class,
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($methodReflectors as $method) {
|
||||
if (($method->isStatic() && !$method->isAbstract()) || isset($methods[$lcName = strtolower($method->name)])) {
|
||||
continue;
|
||||
}
|
||||
if ($method->isFinal()) {
|
||||
if ($extendsInternalClass || $methodsHaveToBeProxied || method_exists(LazyProxyTrait::class, $method->name)) {
|
||||
throw new LogicException(sprintf('Cannot generate lazy proxy: method "%s::%s()" is final.', $class->name, $method->name));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (method_exists(LazyProxyTrait::class, $method->name) || ($method->isProtected() && !$method->isAbstract())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$signature = self::exportSignature($method, true, $args);
|
||||
$parentCall = $method->isAbstract() ? "throw new \BadMethodCallException('Cannot forward abstract method \"{$method->class}::{$method->name}()\".')" : "parent::{$method->name}({$args})";
|
||||
|
||||
if ($method->isStatic()) {
|
||||
$body = " $parentCall;";
|
||||
} elseif (str_ends_with($signature, '): never') || str_ends_with($signature, '): void')) {
|
||||
$body = <<<EOPHP
|
||||
if (isset(\$this->lazyObjectState)) {
|
||||
(\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
|
||||
} else {
|
||||
{$parentCall};
|
||||
}
|
||||
EOPHP;
|
||||
} else {
|
||||
if (!$methodsHaveToBeProxied && !$method->isAbstract()) {
|
||||
// Skip proxying methods that might return $this
|
||||
foreach (preg_split('/[()|&]++/', self::exportType($method) ?? 'static') as $type) {
|
||||
if (\in_array($type = ltrim($type, '?'), ['static', 'object'], true)) {
|
||||
continue 2;
|
||||
}
|
||||
foreach ([$class, ...$interfaces] as $r) {
|
||||
if ($r && is_a($r->name, $type, true)) {
|
||||
continue 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$body = <<<EOPHP
|
||||
if (isset(\$this->lazyObjectState)) {
|
||||
return (\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args});
|
||||
}
|
||||
|
||||
return {$parentCall};
|
||||
EOPHP;
|
||||
}
|
||||
$methods[$lcName] = " {$signature}\n {\n{$body}\n }";
|
||||
}
|
||||
|
||||
$types = $interfaces = array_unique(array_column($interfaces, 'name'));
|
||||
$interfaces[] = LazyObjectInterface::class;
|
||||
$interfaces = implode(', \\', $interfaces);
|
||||
$parent = $class ? ' extends \\'.$class->name : '';
|
||||
array_unshift($types, $class ? 'parent' : '');
|
||||
$type = ltrim(implode('&\\', $types), '&');
|
||||
|
||||
if (!$class) {
|
||||
$trait = new \ReflectionMethod(LazyProxyTrait::class, 'initializeLazyObject');
|
||||
$body = \array_slice(file($trait->getFileName()), $trait->getStartLine() - 1, $trait->getEndLine() - $trait->getStartLine());
|
||||
$body[0] = str_replace('): parent', '): '.$type, $body[0]);
|
||||
$methods = ['initializeLazyObject' => implode('', $body).' }'] + $methods;
|
||||
}
|
||||
$body = $methods ? "\n".implode("\n\n", $methods)."\n" : '';
|
||||
$propertyScopes = $class ? self::exportPropertyScopes($class->name) : '[]';
|
||||
|
||||
if (
|
||||
$class?->hasMethod('__unserialize')
|
||||
&& !$class->getMethod('__unserialize')->getParameters()[0]->getType()
|
||||
) {
|
||||
// fix contravariance type problem when $class declares a `__unserialize()` method without typehint.
|
||||
$lazyProxyTraitStatement = <<<EOPHP
|
||||
use \Symfony\Component\VarExporter\LazyProxyTrait {
|
||||
__unserialize as private __doUnserialize;
|
||||
}
|
||||
EOPHP;
|
||||
|
||||
$body .= <<<EOPHP
|
||||
|
||||
public function __unserialize(\$data): void
|
||||
{
|
||||
\$this->__doUnserialize(\$data);
|
||||
}
|
||||
|
||||
EOPHP;
|
||||
} else {
|
||||
$lazyProxyTraitStatement = <<<EOPHP
|
||||
use \Symfony\Component\VarExporter\LazyProxyTrait;
|
||||
EOPHP;
|
||||
}
|
||||
|
||||
return <<<EOPHP
|
||||
{$parent} implements \\{$interfaces}
|
||||
{
|
||||
{$lazyProxyTraitStatement}
|
||||
|
||||
private const LAZY_OBJECT_PROPERTY_SCOPES = {$propertyScopes};
|
||||
{$body}}
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
|
||||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
|
||||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
|
||||
|
||||
EOPHP;
|
||||
}
|
||||
|
||||
public static function exportSignature(\ReflectionFunctionAbstract $function, bool $withParameterTypes = true, ?string &$args = null): string
|
||||
{
|
||||
$byRefIndex = 0;
|
||||
$args = '';
|
||||
$param = null;
|
||||
$parameters = [];
|
||||
$namespace = $function instanceof \ReflectionMethod ? $function->class : $function->getNamespaceName().'\\';
|
||||
$namespace = substr($namespace, 0, strrpos($namespace, '\\') ?: 0);
|
||||
foreach ($function->getParameters() as $param) {
|
||||
$parameters[] = ($param->getAttributes(\SensitiveParameter::class) ? '#[\SensitiveParameter] ' : '')
|
||||
.($withParameterTypes && $param->hasType() ? self::exportType($param).' ' : '')
|
||||
.($param->isPassedByReference() ? '&' : '')
|
||||
.($param->isVariadic() ? '...' : '').'$'.$param->name
|
||||
.($param->isOptional() && !$param->isVariadic() ? ' = '.self::exportDefault($param, $namespace) : '');
|
||||
if ($param->isPassedByReference()) {
|
||||
$byRefIndex = 1 + $param->getPosition();
|
||||
}
|
||||
$args .= ($param->isVariadic() ? '...$' : '$').$param->name.', ';
|
||||
}
|
||||
|
||||
if (!$param || !$byRefIndex) {
|
||||
$args = '...\func_get_args()';
|
||||
} elseif ($param->isVariadic()) {
|
||||
$args = substr($args, 0, -2);
|
||||
} else {
|
||||
$args = explode(', ', $args, 1 + $byRefIndex);
|
||||
$args[$byRefIndex] = sprintf('...\array_slice(\func_get_args(), %d)', $byRefIndex);
|
||||
$args = implode(', ', $args);
|
||||
}
|
||||
|
||||
$signature = 'function '.($function->returnsReference() ? '&' : '')
|
||||
.($function->isClosure() ? '' : $function->name).'('.implode(', ', $parameters).')';
|
||||
|
||||
if ($function instanceof \ReflectionMethod) {
|
||||
$signature = ($function->isPublic() ? 'public ' : ($function->isProtected() ? 'protected ' : 'private '))
|
||||
.($function->isStatic() ? 'static ' : '').$signature;
|
||||
}
|
||||
if ($function->hasReturnType()) {
|
||||
$signature .= ': '.self::exportType($function);
|
||||
}
|
||||
|
||||
static $getPrototype;
|
||||
$getPrototype ??= (new \ReflectionMethod(\ReflectionMethod::class, 'getPrototype'))->invoke(...);
|
||||
|
||||
while ($function) {
|
||||
if ($function->hasTentativeReturnType()) {
|
||||
return '#[\ReturnTypeWillChange] '.$signature;
|
||||
}
|
||||
|
||||
try {
|
||||
$function = $function instanceof \ReflectionMethod && $function->isAbstract() ? false : $getPrototype($function);
|
||||
} catch (\ReflectionException) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $signature;
|
||||
}
|
||||
|
||||
public static function exportType(\ReflectionFunctionAbstract|\ReflectionProperty|\ReflectionParameter $owner, bool $noBuiltin = false, ?\ReflectionType $type = null): ?string
|
||||
{
|
||||
if (!$type ??= $owner instanceof \ReflectionFunctionAbstract ? $owner->getReturnType() : $owner->getType()) {
|
||||
return null;
|
||||
}
|
||||
$class = null;
|
||||
$types = [];
|
||||
if ($type instanceof \ReflectionUnionType) {
|
||||
$reflectionTypes = $type->getTypes();
|
||||
$glue = '|';
|
||||
} elseif ($type instanceof \ReflectionIntersectionType) {
|
||||
$reflectionTypes = $type->getTypes();
|
||||
$glue = '&';
|
||||
} else {
|
||||
$reflectionTypes = [$type];
|
||||
$glue = null;
|
||||
}
|
||||
|
||||
foreach ($reflectionTypes as $type) {
|
||||
if ($type instanceof \ReflectionIntersectionType) {
|
||||
if ('' !== $name = '('.self::exportType($owner, $noBuiltin, $type).')') {
|
||||
$types[] = $name;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$name = $type->getName();
|
||||
|
||||
if ($noBuiltin && $type->isBuiltin()) {
|
||||
continue;
|
||||
}
|
||||
if (\in_array($name, ['parent', 'self'], true) && $class ??= $owner->getDeclaringClass()) {
|
||||
$name = 'parent' === $name ? ($class->getParentClass() ?: null)?->name ?? 'parent' : $class->name;
|
||||
}
|
||||
|
||||
$types[] = ($noBuiltin || $type->isBuiltin() || 'static' === $name ? '' : '\\').$name;
|
||||
}
|
||||
|
||||
if (!$types) {
|
||||
return '';
|
||||
}
|
||||
if (null === $glue) {
|
||||
return (!$noBuiltin && $type->allowsNull() && !\in_array($name, ['mixed', 'null'], true) ? '?' : '').$types[0];
|
||||
}
|
||||
sort($types);
|
||||
|
||||
return implode($glue, $types);
|
||||
}
|
||||
|
||||
private static function exportPropertyScopes(string $parent): string
|
||||
{
|
||||
$propertyScopes = Hydrator::$propertyScopes[$parent] ??= Hydrator::getPropertyScopes($parent);
|
||||
uksort($propertyScopes, 'strnatcmp');
|
||||
foreach ($propertyScopes as $k => $v) {
|
||||
unset($propertyScopes[$k][3]);
|
||||
}
|
||||
$propertyScopes = VarExporter::export($propertyScopes);
|
||||
$propertyScopes = str_replace(VarExporter::export($parent), 'parent::class', $propertyScopes);
|
||||
$propertyScopes = preg_replace("/(?|(,)\n( ) |\n |,\n (\]))/", '$1$2', $propertyScopes);
|
||||
$propertyScopes = str_replace("\n", "\n ", $propertyScopes);
|
||||
|
||||
return $propertyScopes;
|
||||
}
|
||||
|
||||
private static function exportDefault(\ReflectionParameter $param, $namespace): string
|
||||
{
|
||||
$default = rtrim(substr(explode('$'.$param->name.' = ', (string) $param, 2)[1] ?? '', 0, -2));
|
||||
|
||||
if (\in_array($default, ['<default>', 'NULL'], true)) {
|
||||
return 'null';
|
||||
}
|
||||
if (str_ends_with($default, "...'") && preg_match("/^'(?:[^'\\\\]*+(?:\\\\.)*+)*+'$/", $default)) {
|
||||
return VarExporter::export($param->getDefaultValue());
|
||||
}
|
||||
|
||||
$regexp = "/(\"(?:[^\"\\\\]*+(?:\\\\.)*+)*+\"|'(?:[^'\\\\]*+(?:\\\\.)*+)*+')/";
|
||||
$parts = preg_split($regexp, $default, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$regexp = '/([\[\( ]|^)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z0-9_\x7f-\xff]++)*+)(\(?)(?!: )/';
|
||||
$callback = (false !== strpbrk($default, "\\:('") && $class = $param->getDeclaringClass())
|
||||
? fn ($m) => $m[1].match ($m[2]) {
|
||||
'new', 'false', 'true', 'null' => $m[2],
|
||||
'NULL' => 'null',
|
||||
'self' => '\\'.$class->name,
|
||||
'namespace\\parent',
|
||||
'parent' => ($parent = $class->getParentClass()) ? '\\'.$parent->name : 'parent',
|
||||
default => self::exportSymbol($m[2], '(' !== $m[3], $namespace),
|
||||
}.$m[3]
|
||||
: fn ($m) => $m[1].match ($m[2]) {
|
||||
'new', 'false', 'true', 'null', 'self', 'parent' => $m[2],
|
||||
'NULL' => 'null',
|
||||
default => self::exportSymbol($m[2], '(' !== $m[3], $namespace),
|
||||
}.$m[3];
|
||||
|
||||
return implode('', array_map(fn ($part) => match ($part[0]) {
|
||||
'"' => $part, // for internal classes only
|
||||
"'" => false !== strpbrk($part, "\\\0\r\n") ? '"'.substr(str_replace(['$', "\0", "\r", "\n"], ['\$', '\0', '\r', '\n'], $part), 1, -1).'"' : $part,
|
||||
default => preg_replace_callback($regexp, $callback, $part),
|
||||
}, $parts));
|
||||
}
|
||||
|
||||
private static function exportSymbol(string $symbol, bool $mightBeRootConst, string $namespace): string
|
||||
{
|
||||
if (!$mightBeRootConst
|
||||
|| false === ($ns = strrpos($symbol, '\\'))
|
||||
|| substr($symbol, 0, $ns) !== $namespace
|
||||
|| \defined($symbol)
|
||||
|| !\defined(substr($symbol, $ns + 1))
|
||||
) {
|
||||
return '\\'.$symbol;
|
||||
}
|
||||
|
||||
return '\\'.substr($symbol, $ns + 1);
|
||||
}
|
||||
}
|
||||
137
vendor/symfony/var-exporter/README.md
vendored
137
vendor/symfony/var-exporter/README.md
vendored
@@ -1,137 +0,0 @@
|
||||
VarExporter Component
|
||||
=====================
|
||||
|
||||
The VarExporter component provides various tools to deal with the internal state
|
||||
of objects:
|
||||
|
||||
- `VarExporter::export()` allows exporting any serializable PHP data structure to
|
||||
plain PHP code. While doing so, it preserves all the semantics associated with
|
||||
the serialization mechanism of PHP (`__wakeup`, `__sleep`, `Serializable`,
|
||||
`__serialize`, `__unserialize`);
|
||||
- `Instantiator::instantiate()` creates an object and sets its properties without
|
||||
calling its constructor nor any other methods;
|
||||
- `Hydrator::hydrate()` can set the properties of an existing object;
|
||||
- `Lazy*Trait` can make a class behave as a lazy-loading ghost or virtual proxy.
|
||||
|
||||
VarExporter::export()
|
||||
---------------------
|
||||
|
||||
The reason to use `VarExporter::export()` *vs* `serialize()` or
|
||||
[igbinary](https://github.com/igbinary/igbinary) is performance: thanks to
|
||||
OPcache, the resulting code is significantly faster and more memory efficient
|
||||
than using `unserialize()` or `igbinary_unserialize()`.
|
||||
|
||||
Unlike `var_export()`, this works on any serializable PHP value.
|
||||
|
||||
It also provides a few improvements over `var_export()`/`serialize()`:
|
||||
|
||||
* the output is PSR-2 compatible;
|
||||
* the output can be re-indented without messing up with `\r` or `\n` in the data;
|
||||
* missing classes throw a `ClassNotFoundException` instead of being unserialized
|
||||
to `PHP_Incomplete_Class` objects;
|
||||
* references involving `SplObjectStorage`, `ArrayObject` or `ArrayIterator`
|
||||
instances are preserved;
|
||||
* `Reflection*`, `IteratorIterator` and `RecursiveIteratorIterator` classes
|
||||
throw an exception when being serialized (their unserialized version is broken
|
||||
anyway, see https://bugs.php.net/76737).
|
||||
|
||||
Instantiator and Hydrator
|
||||
-------------------------
|
||||
|
||||
`Instantiator::instantiate($class)` creates an object of the given class without
|
||||
calling its constructor nor any other methods.
|
||||
|
||||
`Hydrator::hydrate()` sets the properties of an existing object, including
|
||||
private and protected ones. For example:
|
||||
|
||||
```php
|
||||
// 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],
|
||||
]);
|
||||
```
|
||||
|
||||
`Lazy*Trait`
|
||||
------------
|
||||
|
||||
The component provides two lazy-loading patterns: ghost objects and virtual
|
||||
proxies (see https://martinfowler.com/eaaCatalog/lazyLoad.html for reference).
|
||||
|
||||
Ghost objects work only with concrete and non-internal classes. In the generic
|
||||
case, they are not compatible with using factories in their initializer.
|
||||
|
||||
Virtual proxies work with concrete, abstract or internal classes. They provide an
|
||||
API that looks like the actual objects and forward calls to them. They can cause
|
||||
identity problems because proxies might not be seen as equivalents to the actual
|
||||
objects they proxy.
|
||||
|
||||
Because of this identity problem, ghost objects should be preferred when
|
||||
possible. Exceptions thrown by the `ProxyHelper` class can help decide when it
|
||||
can be used or not.
|
||||
|
||||
Ghost objects and virtual proxies both provide implementations for the
|
||||
`LazyObjectInterface` which allows resetting them to their initial state or to
|
||||
forcibly initialize them when needed. Note that resetting a ghost object skips
|
||||
its read-only properties. You should use a virtual proxy to reset read-only
|
||||
properties.
|
||||
|
||||
### `LazyGhostTrait`
|
||||
|
||||
By using `LazyGhostTrait` either directly in your classes or by using
|
||||
`ProxyHelper::generateLazyGhost()`, you can make their instances lazy-loadable.
|
||||
This works by creating these instances empty and by computing their state only
|
||||
when accessing a property.
|
||||
|
||||
```php
|
||||
class FooLazyGhost extends Foo
|
||||
{
|
||||
use LazyGhostTrait;
|
||||
}
|
||||
|
||||
$foo = FooLazyGhost::createLazyGhost(initializer: function (Foo $instance): void {
|
||||
// [...] Use whatever heavy logic you need here
|
||||
// to compute the $dependencies of the $instance
|
||||
$instance->__construct(...$dependencies);
|
||||
// [...] Call setters, etc. if needed
|
||||
});
|
||||
|
||||
// $foo is now a lazy-loading ghost object. The initializer will
|
||||
// be called only when and if a *property* is accessed.
|
||||
```
|
||||
|
||||
### `LazyProxyTrait`
|
||||
|
||||
Alternatively, `LazyProxyTrait` can be used to create virtual proxies:
|
||||
|
||||
```php
|
||||
$proxyCode = ProxyHelper::generateLazyProxy(new ReflectionClass(Foo::class));
|
||||
// $proxyCode contains the reference to LazyProxyTrait
|
||||
// and should be dumped into a file in production envs
|
||||
eval('class FooLazyProxy'.$proxyCode);
|
||||
|
||||
$foo = FooLazyProxy::createLazyProxy(initializer: function (): Foo {
|
||||
// [...] Use whatever heavy logic you need here
|
||||
// to compute the $dependencies of the $instance
|
||||
$instance = new Foo(...$dependencies);
|
||||
// [...] Call setters, etc. if needed
|
||||
|
||||
return $instance;
|
||||
});
|
||||
// $foo is now a lazy-loading virtual proxy object. The initializer will
|
||||
// be called only when and if a *method* is called.
|
||||
```
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/var_exporter.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
114
vendor/symfony/var-exporter/VarExporter.php
vendored
114
vendor/symfony/var-exporter/VarExporter.php
vendored
@@ -1,114 +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 Symfony\Component\VarExporter;
|
||||
|
||||
use Symfony\Component\VarExporter\Exception\ExceptionInterface;
|
||||
use Symfony\Component\VarExporter\Internal\Exporter;
|
||||
use Symfony\Component\VarExporter\Internal\Hydrator;
|
||||
use Symfony\Component\VarExporter\Internal\Registry;
|
||||
use Symfony\Component\VarExporter\Internal\Values;
|
||||
|
||||
/**
|
||||
* Exports serializable PHP values to PHP code.
|
||||
*
|
||||
* VarExporter allows serializing PHP data structures to plain PHP code (like var_export())
|
||||
* while preserving all the semantics associated with serialize() (unlike var_export()).
|
||||
*
|
||||
* By leveraging OPcache, the generated PHP code is faster than doing the same with unserialize().
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
final class VarExporter
|
||||
{
|
||||
/**
|
||||
* Exports a serializable PHP value to PHP code.
|
||||
*
|
||||
* @param bool &$isStaticValue Set to true after execution if the provided value is static, false otherwise
|
||||
* @param array &$foundClasses Classes found in the value are added to this list as both keys and values
|
||||
*
|
||||
* @throws ExceptionInterface When the provided value cannot be serialized
|
||||
*/
|
||||
public static function export(mixed $value, ?bool &$isStaticValue = null, array &$foundClasses = []): string
|
||||
{
|
||||
$isStaticValue = true;
|
||||
|
||||
if (!\is_object($value) && !(\is_array($value) && $value) && !\is_resource($value) || $value instanceof \UnitEnum) {
|
||||
return Exporter::export($value);
|
||||
}
|
||||
|
||||
$objectsPool = new \SplObjectStorage();
|
||||
$refsPool = [];
|
||||
$objectsCount = 0;
|
||||
|
||||
try {
|
||||
$value = Exporter::prepare([$value], $objectsPool, $refsPool, $objectsCount, $isStaticValue)[0];
|
||||
} finally {
|
||||
$references = [];
|
||||
foreach ($refsPool as $i => $v) {
|
||||
if ($v[0]->count) {
|
||||
$references[1 + $i] = $v[2];
|
||||
}
|
||||
$v[0] = $v[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($isStaticValue) {
|
||||
return Exporter::export($value);
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
$values = [];
|
||||
$states = [];
|
||||
foreach ($objectsPool as $i => $v) {
|
||||
[, $class, $values[], $wakeup] = $objectsPool[$v];
|
||||
$foundClasses[$class] = $classes[] = $class;
|
||||
|
||||
if (0 < $wakeup) {
|
||||
$states[$wakeup] = $i;
|
||||
} elseif (0 > $wakeup) {
|
||||
$states[-$wakeup] = [$i, array_pop($values)];
|
||||
$values[] = [];
|
||||
}
|
||||
}
|
||||
ksort($states);
|
||||
|
||||
$wakeups = [null];
|
||||
foreach ($states as $v) {
|
||||
if (\is_array($v)) {
|
||||
$wakeups[-$v[0]] = $v[1];
|
||||
} else {
|
||||
$wakeups[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $wakeups[0]) {
|
||||
unset($wakeups[0]);
|
||||
}
|
||||
|
||||
$properties = [];
|
||||
foreach ($values as $i => $vars) {
|
||||
foreach ($vars as $class => $values) {
|
||||
foreach ($values as $name => $v) {
|
||||
$properties[$class][$name][$i] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($classes || $references) {
|
||||
$value = new Hydrator(new Registry($classes), $references ? new Values($references) : null, $properties, $value, $wakeups);
|
||||
} else {
|
||||
$isStaticValue = true;
|
||||
}
|
||||
|
||||
return Exporter::export($value);
|
||||
}
|
||||
}
|
||||
34
vendor/symfony/var-exporter/composer.json
vendored
34
vendor/symfony/var-exporter/composer.json
vendored
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"name": "symfony/var-exporter",
|
||||
"type": "library",
|
||||
"description": "Allows exporting any serializable PHP data structure to plain PHP code",
|
||||
"keywords": ["export", "serialize", "instantiate", "hydrate", "construct", "clone", "lazy-loading", "proxy"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"symfony/deprecation-contracts": "^2.5|^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/property-access": "^6.4|^7.0",
|
||||
"symfony/serializer": "^6.4|^7.0",
|
||||
"symfony/var-dumper": "^5.4|^6.0|^7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\VarExporter\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Reference in New Issue
Block a user