From 5f2b2376e0f23d78dc7b2ef6c9a668ec3127fafb Mon Sep 17 00:00:00 2001 From: vladar Date: Sat, 17 Oct 2015 17:35:56 +0600 Subject: [PATCH] Allow custom attributes in type definitions for user-land metadata --- src/Type/Definition/Config.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Type/Definition/Config.php b/src/Type/Definition/Config.php index a2999f9..69ba068 100644 --- a/src/Type/Definition/Config.php +++ b/src/Type/Definition/Config.php @@ -80,7 +80,10 @@ class Config // Make sure there are no unexpected keys in map $unexpectedKeys = array_keys(array_diff_key($map, $definitions)); - Utils::invariant(empty($unexpectedKeys), 'Error in "'.$typeName.'" type definition: Unexpected keys "%s" ' . $suffix, implode(', ', $unexpectedKeys)); + if (!empty($unexpectedKeys)) { + trigger_error(sprintf('"%s" type definition: Unexpected keys "%s" ' . $suffix, $typeName, implode(', ', $unexpectedKeys))); + $map = array_intersect_key($map, $definitions); + } // Make sure that all required keys are present in map $requiredKeys = array_filter($definitions, function($def) {return (self::_getFlags($def) & self::REQUIRED) > 0;});