Do not consider any two @lists equal.

This commit is contained in:
Dave Longley 2013-04-06 00:15:39 -04:00
parent fe470927fb
commit f5337b8118

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP implementation of the JSON-LD API. * PHP implementation of the JSON-LD API.
* Version: 0.0.25 * Version: 0.0.26
* *
* @author Dave Longley * @author Dave Longley
* *
@ -1259,8 +1259,7 @@ class JsonLdProcessor {
* 1. They are both primitives of the same type and value. * 1. They are both primitives of the same type and value.
* 2. They are both @values with the same @value, @type, @language, * 2. They are both @values with the same @value, @type, @language,
* and @index, OR * and @index, OR
* 3. They are both @lists with the same @list and @index, OR * 3. They both have @ids that are the same.
* 4. They both have @ids that are the same.
* *
* @param mixed $v1 the first value. * @param mixed $v1 the first value.
* @param mixed $v2 the second value. * @param mixed $v2 the second value.
@ -1282,27 +1281,7 @@ class JsonLdProcessor {
self::_compareKeyValues($v1, $v2, '@index')); self::_compareKeyValues($v1, $v2, '@index'));
} }
// 3. equal @lists // 3. equal @ids
if(self::_isList($v1) && self::_isList($v2)) {
if(!self::_compareKeyValues($v1, $v2, '@index')) {
return false;
}
$list1 = $v1->{'@list'};
$list2 = $v2->{'@list'};
$count_list1 = count($list1);
$count_list2 = count($list2);
if($count_list1 !== $count_list2) {
return false;
}
for($i = 0; $i < $count_list1; ++$i) {
if(!self::compareValues($list1[$i], $list2[$i])) {
return false;
}
}
return true;
}
// 4. equal @ids
if(is_object($v1) && property_exists($v1, '@id') && if(is_object($v1) && property_exists($v1, '@id') &&
is_object($v2) && property_exists($v2, '@id')) { is_object($v2) && property_exists($v2, '@id')) {
return $v1->{'@id'} === $v2->{'@id'}; return $v1->{'@id'} === $v2->{'@id'};