Better check for null default values
Publish PHP Package / docker (push) Successful in 6s
Details
Publish PHP Package / docker (push) Successful in 6s
Details
This commit is contained in:
parent
1ae22cb86d
commit
da88e6b8db
|
@ -419,16 +419,16 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
|
||||
if($default)
|
||||
{
|
||||
$default = is_array($default) ? $default : json_decode($default, true);
|
||||
if(is_array($default))
|
||||
$default_val = is_array($default) ? $default : json_decode($default, true);
|
||||
if(is_array($default_val))
|
||||
{
|
||||
foreach($default as $k => $v)
|
||||
foreach($default_val as $k => $v)
|
||||
{
|
||||
$kf = $type->getField($k);
|
||||
$str .= var_reset("$name." . $kf->getName(), $kf->getType(), $v);
|
||||
}
|
||||
}
|
||||
else if($default === null)
|
||||
else if(is_null_str($default))
|
||||
$str .= "$name = null; ";
|
||||
else
|
||||
throw new Exception("Bad default value for struct: " . var_export($default, true));
|
||||
|
@ -441,7 +441,7 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
|
||||
function is_null_str($default)
|
||||
{
|
||||
return is_string($default) && json_decode($default, true) === null;
|
||||
return is_string($default) && strtolower($default) === 'null';
|
||||
}
|
||||
|
||||
function var_sync($fname, \mtgType $type, $buf, array $tokens, $opts)
|
||||
|
|
Loading…
Reference in New Issue