From 5e9b4ce217cf43cd400127a76be73fd4fadd54c1 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 6 Jun 2023 18:12:16 +0200 Subject: [PATCH] misc: avoid using `unserialize` when caching `NULL` default values --- .../Cache/Compiler/ParameterDefinitionCompiler.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php b/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php index d39d7f30..d273b384 100644 --- a/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php +++ b/src/Definition/Repository/Cache/Compiler/ParameterDefinitionCompiler.php @@ -6,8 +6,6 @@ use CuyZ\Valinor\Definition\ParameterDefinition; -use function is_scalar; - /** @internal */ final class ParameterDefinitionCompiler { @@ -42,8 +40,8 @@ private function defaultValue(ParameterDefinition $parameter): string { $defaultValue = $parameter->defaultValue(); - return is_scalar($defaultValue) - ? var_export($parameter->defaultValue(), true) - : 'unserialize(' . var_export(serialize($defaultValue), true) . ')'; + return is_object($defaultValue) + ? 'unserialize(' . var_export(serialize($defaultValue), true) . ')' + : var_export($defaultValue, true); } }