Making PHPStan happy

This commit is contained in:
Pavel Shevaev 2023-08-16 14:18:21 +03:00
parent 97db32ffc7
commit a1900d7e23
2 changed files with 7 additions and 10 deletions

View File

@ -221,7 +221,7 @@ function data2value($name, \mtgType $type, $buf, $prefix = '', $tokens = array()
$str .= $cond_indent."{$pname} = \metagen_php\\val_enum('$type', {$tmp_val}, false);\n";
}
else
throw new Exception("Unknown type '{$type}'");
throw new Exception("Unknown type '{$type->getName()}'");
if($postfix)
$str .= $cond_indent.$postfix."\n";
@ -286,7 +286,7 @@ function value2data($name, \mtgType $type, $buf, $prefix = '', $tokens = array()
$str .= $indent."\metagen_php\array_set_value({$buf}, \$assoc, '$name', \$arr_tmp__);\n";
}
else
throw new Exception("Unknown type '{$type}'");
throw new Exception("Unknown type '{$type->getName()}'");
return $str;
}

View File

@ -76,13 +76,8 @@ class {{o.name}} {{o.parent ? 'extends ' ~ o.parent.name}}
}
catch(Exception $e)
{
if($IDX > -1)
{
$FIELDS = self::CLASS_FIELDS();
throw new Exception($e->getMessage() . " < {$FIELDS[$IDX]}");
}
else
throw $e;
$FIELDS = self::CLASS_FIELDS();
throw new Exception($e->getMessage() . " < {$FIELDS[$IDX]}");
}
if($root && $assoc && sizeof($data) > 0)
throw new Exception("Junk fields: " . implode(',', array_keys($data)));
@ -128,7 +123,9 @@ class {{o.name}} {{o.parent ? 'extends ' ~ o.parent.name}}
{% endmacro %}
{% macro decl_struct_field(o, f) ~%}
/** @var {{f.type}}*/
{%- if f.type is instanceof('\\mtgMetaStruct') ~%}
/** @var {{f.type}}|null*/
{%- endif -%}
{%- if f.type is instanceof('\\mtgBuiltinType') and f.type.isstring ~%}
public ${{f.name}} = '';
{%- elseif f.type is instanceof('\\mtgArrType') ~%}