From 5c5ab819d7116eb674226b22c52b7cc4d50cda54 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Mon, 11 Feb 2013 14:24:55 -0500 Subject: [PATCH] Simplify term definition creation, disallow @type in property generator. --- jsonld.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/jsonld.php b/jsonld.php index b696e40..79c5498 100644 --- a/jsonld.php +++ b/jsonld.php @@ -4147,18 +4147,16 @@ class JsonLdProcessor { $property_generator = array(); $ids = $id; foreach($ids as $id) { - if(!is_string($id)) { + if(!is_string($id) || $id === '@type') { throw new JsonLdException( 'Invalid JSON-LD syntax; property generators must consist of ' . - 'an @id array containing only strings.', + 'an @id array containing only strings and no string can be ' . + '"@type".', 'jsonld.SyntaxError', array('context' => $local_ctx)); } - // expand @id if it is not @type - if($id !== '@type') { - $id = $this->_expandIri( - $active_ctx, $id, array('base' => true), $local_ctx, $defined); - } - $property_generator[] = $id; + // expand @id + $property_generator[] = $this->_expandIri( + $active_ctx, $id, array('base' => true), $local_ctx, $defined); } // add sorted property generator as @id in mapping sort($property_generator); @@ -4172,13 +4170,9 @@ class JsonLdProcessor { 'jsonld.SyntaxError', array('context' => $local_ctx)); } else { - // add @id to mapping, expanding it if it is not @type - if($id !== '@type') { - // expand @id to full IRI - $id = $this->_expandIri( - $active_ctx, $id, array('base' => true), $local_ctx, $defined); - } - $mapping->{'@id'} = $id; + // add @id to mapping + $mapping->{'@id'} = $this->_expandIri( + $active_ctx, $id, array('base' => true), $local_ctx, $defined); } } else {