From 3da2b92a59e641da747cf1a74b384c3d4c927411 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 31 May 2024 20:51:47 +0300 Subject: [PATCH] Adding validation of type refs pointing to named functions --- metagen.inc.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/metagen.inc.php b/metagen.inc.php index 7e1a48e..0c57110 100644 --- a/metagen.inc.php +++ b/metagen.inc.php @@ -54,7 +54,9 @@ class mtgTypeRef implements mtgType while(sizeof(self::$unresolved) > 0) { $ref = array_shift(self::$unresolved); - $ref->resolve(); + $resolved = $ref->resolve(); + if($resolved instanceof mtgMetaFunc && $resolved->getName()) + throw new Exception("Invalid resolving of named function as type: " . $resolved->getName() . " at " . $ref->origin); } } @@ -303,6 +305,11 @@ class mtgMetaStruct extends mtgUserType throw new Exception("{$this->origin} : Duplicate interface reference '{$imp->getName()}'"); $s->attach($imp); } + + foreach($this->funcs as $func) + { + $func->validate($meta); + } } function getParent() @@ -456,7 +463,8 @@ class mtgMetaFunc extends mtgMetaUnit implements mtgType $this->name = $name; } - function validate(mtgMetaInfo $meta) {} + function validate(mtgMetaInfo $meta) + {} function getMetaId() { @@ -894,6 +902,7 @@ class mtgMetaField { return $this->hasToken($name) ? $this->tokens[$name] : null; } + } class mtgMetaPacket extends mtgMetaStruct