Making PHPStan happy and adhering to new metagen API

This commit is contained in:
Pavel Shevaev 2023-08-16 14:21:05 +03:00
parent 30d7ef8fbe
commit dafbac592e
2 changed files with 11 additions and 10 deletions

View File

@ -372,7 +372,7 @@ function bhl_type_ref(\mtgType $type = null)
}
//fallback
return 'types.T("' . $type. '")';
return 'types.T("' . $type->getName() . '")';
}
function bhl_type(\mtgType $type = null)
@ -410,13 +410,13 @@ function bhl_type(\mtgType $type = null)
return "[]" . bhl_type($type->getValue());
//fallback
return ''.$type;
return $type->getName();
}
function native_type(\mtgType $type)
{
//any special case
if($type == "any")
if($type->getName() == "any")
return "bhl.Val";
if($type instanceof \mtgArrType)
@ -435,17 +435,18 @@ function native_type(\mtgType $type)
if($type instanceof \mtgUserType)
$alias = $type->getToken('bhl_native_class');
if($type instanceof \mtgArrType)
$orig_name = $type->getValue()->getName();
else
//TODO: looks suspicious
$orig_name = null;
if($alias && $type instanceof \mtgUserType)
{
$orig_name = $type->getName();
if($alias)
$type->setName($alias);
}
$ntype = cs_type($type);
//TODO: looks suspicious
if($alias)
if($alias && $type instanceof \mtgUserType)
$type->setName($orig_name);
return $ntype;
@ -458,7 +459,7 @@ function cs_type(\mtgType $type)
else if($type instanceof \mtgArrType)
return "List<" . cs_simple_type($type->getValue()) . ">";
else
throw new Exception("Unknown type '{$type}'");
throw new Exception("Unknown type '{$type->getName()}'");
}
function cs_simple_type(\mtgType $type)

View File

@ -608,7 +608,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
v.Encode(o);
{% else %}
{% if has_token(o, 'POD') %}
o.reset();
o.Reset();
{% endif %}
v.SetObj(o, type);
{% endif %}