forked from friendica/php-json-ld
Updated to pass tests.
This commit is contained in:
parent
210b77ea5e
commit
be88eaa0c4
16
jsonld.php
16
jsonld.php
|
@ -1315,9 +1315,18 @@ function _flatten($parent, $parentProperty, $value, $subjects)
|
|||
// drop null values
|
||||
if($v !== null)
|
||||
{
|
||||
if(is_array($v))
|
||||
if(property_exists($subject, $key))
|
||||
{
|
||||
if(!is_array($subject->$key))
|
||||
{
|
||||
$subject->$key = new ArrayObject(array($subject->$key));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$subject->$key = new ArrayObject();
|
||||
}
|
||||
|
||||
_flatten($subject->$key, null, $value->$key, $subjects);
|
||||
$subject->$key = (array)$subject->$key;
|
||||
if(count($subject->$key) === 1)
|
||||
|
@ -1327,11 +1336,6 @@ function _flatten($parent, $parentProperty, $value, $subjects)
|
|||
$subject->$key = $arr[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_flatten($subject, $key, $value->$key, $subjects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue