fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -65,7 +65,7 @@ final class Instantiator
$wrappedInstance = [$reflector->newInstanceWithoutConstructor()];
} elseif (null === Registry::$prototypes[$class]) {
throw new NotInstantiableTypeException($class);
} elseif ($reflector->implementsInterface('Serializable') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize'))) {
} elseif ($reflector->implementsInterface('Serializable') && !method_exists($class, '__unserialize')) {
$wrappedInstance = [unserialize('C:'.\strlen($class).':"'.$class.'":0:{}')];
} else {
$wrappedInstance = [unserialize('O:'.\strlen($class).':"'.$class.'":0:{}')];

View File

@@ -103,7 +103,7 @@ class Registry
}
}
}
if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__serialize'))) {
if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && !method_exists($class, '__serialize')) {
try {
serialize($proto);
} catch (\Exception $e) {
@@ -113,7 +113,7 @@ class Registry
}
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') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize')))) {
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);
}

View File

@@ -32,13 +32,12 @@ final class VarExporter
/**
* Exports a serializable PHP value to PHP code.
*
* @param mixed $value The value to export
* @param bool &$isStaticValue Set to true after execution if the provided value is static, false otherwise
* @param bool &$classes Classes found in the value are added to this list as both keys and values
* @param bool &$isStaticValue Set to true after execution if the provided value is static, false otherwise
* @param bool &$classes 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($value, bool &$isStaticValue = null, array &$foundClasses = []): string
public static function export(mixed $value, bool &$isStaticValue = null, array &$foundClasses = []): string
{
$isStaticValue = true;

View File

@@ -16,11 +16,10 @@
}
],
"require": {
"php": ">=7.2.5",
"symfony/polyfill-php80": "^1.16"
"php": ">=8.0.2"
},
"require-dev": {
"symfony/var-dumper": "^4.4.9|^5.0.9|^6.0"
"symfony/var-dumper": "^5.4|^6.0"
},
"autoload": {
"psr-4": { "Symfony\\Component\\VarExporter\\": "" },