Compare commits

..

No commits in common. "master" and "v2.4.0" have entirely different histories.

1 changed files with 3 additions and 7 deletions

View File

@ -304,10 +304,9 @@ function is_null_str($default)
return is_string($default) && json_decode($default, true) === null;
}
function get_default_value_arg(\mtgType $type, array $tokens, bool &$has_default = true) : string
function get_default_value_arg(\mtgType $type, array $tokens) : string
{
$has_default = array_key_exists('default', $tokens);
$default_value_arg = $has_default ? default_value($tokens['default']) : "null";
$default_value_arg = array_key_exists('default', $tokens) ? default_value($tokens['default']) : "null";
if($type instanceof \mtgMetaStruct)
{
@ -336,16 +335,13 @@ function data_normalize($name, \mtgType $type, $buf, $dst, $tokens = array(), $t
{
$str = '';
$has_default = false;
$default_value_arg = get_default_value_arg($type, $tokens, $has_default);
$default_value_arg = get_default_value_arg($type, $tokens);
$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";
}