From dafbac592e955dbffbca00bb016ecea095ed250f Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 16 Aug 2023 14:21:05 +0300 Subject: [PATCH] Making PHPStan happy and adhering to new metagen API --- src/bind.inc.php | 19 ++++++++++--------- tpl/macro.twig | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/bind.inc.php b/src/bind.inc.php index 3bff4e8..706e9dc 100644 --- a/src/bind.inc.php +++ b/src/bind.inc.php @@ -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) diff --git a/tpl/macro.twig b/tpl/macro.twig index 0d91b7d..689f44f 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -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 %}