Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
b7725936e6 |
|
@ -304,9 +304,10 @@ function is_null_str($default)
|
|||
return is_string($default) && json_decode($default, true) === null;
|
||||
}
|
||||
|
||||
function get_default_value_arg(\mtgType $type, array $tokens) : string
|
||||
function get_default_value_arg(\mtgType $type, array $tokens, bool &$has_default = true) : string
|
||||
{
|
||||
$default_value_arg = array_key_exists('default', $tokens) ? default_value($tokens['default']) : "null";
|
||||
$has_default = array_key_exists('default', $tokens);
|
||||
$default_value_arg = $has_default ? default_value($tokens['default']) : "null";
|
||||
|
||||
if($type instanceof \mtgMetaStruct)
|
||||
{
|
||||
|
@ -335,13 +336,16 @@ function data_normalize($name, \mtgType $type, $buf, $dst, $tokens = array(), $t
|
|||
{
|
||||
$str = '';
|
||||
|
||||
$default_value_arg = get_default_value_arg($type, $tokens);
|
||||
$has_default = false;
|
||||
$default_value_arg = get_default_value_arg($type, $tokens, $has_default);
|
||||
|
||||
$str .= "\n";
|
||||
|
||||
if($name !== null)
|
||||
{
|
||||
$str .= "{$tmp_val} = {$buf}['{$name}'] ?? {$default_value_arg};\n";
|
||||
if(!$has_default)
|
||||
$str .= "if({$tmp_val} === null) throw new Exception(\"'{$name}' is missing\");\n";
|
||||
$str .= "if(\$check_junk) unset({$buf}['{$name}']);\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue