Skip to content

Commit

Permalink
misc: avoid using unserialize when caching NULL default values
Browse files Browse the repository at this point in the history
  • Loading branch information
danog authored Jun 6, 2023
1 parent 0a8f37b commit 5e9b4ce
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use CuyZ\Valinor\Definition\ParameterDefinition;

use function is_scalar;

/** @internal */
final class ParameterDefinitionCompiler
{
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 5e9b4ce

Please sign in to comment.