Skip to content

Commit

Permalink
fix Object namespace bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Lambourne committed Oct 14, 2018
1 parent da8efc5 commit e4fc97b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
6 changes: 3 additions & 3 deletions Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;
use ML\IRI\IRI;

/**
Expand Down Expand Up @@ -191,14 +191,14 @@ public function toJsonLd($useNativeTypes = true)
}

foreach ($this->namedGraphs as $graphName => $graph) {
$namedGraph = new Object();
$namedGraph = new stdClass();
$namedGraph->{'@id'} = $graphName;
$namedGraph->{'@graph'} = $graph->toJsonLd($useNativeTypes);

$defGraph[] = $namedGraph;
}

$document = new Object();
$document = new stdClass();
$document->{'@graph'} = $defGraph;

return array($document);
Expand Down
6 changes: 3 additions & 3 deletions JsonLD.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;
use ML\JsonLD\Exception\JsonLdException;
use ML\JsonLD\Exception\InvalidQuadException;
use ML\IRI\IRI;
Expand Down Expand Up @@ -274,7 +274,7 @@ private static function doCompact($input, $context, $options, $alwaysGraph = fal

$processor->compact($input, $activectx, $inversectx);

$compactedDocument = new Object();
$compactedDocument = new stdClass();
if (null !== $context) {
$compactedDocument->{'@context'} = $context;
}
Expand Down Expand Up @@ -534,7 +534,7 @@ public static function frame($input, $frame, $options = null)
$processor = new Processor($options);

// Store the frame's context as $frame gets modified
$frameContext = new Object();
$frameContext = new stdClass();
if (property_exists($frame, '@context')) {
$frameContext->{'@context'} = $frame->{'@context'};
}
Expand Down
4 changes: 2 additions & 2 deletions LanguageTaggedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;

/**
* A LanguageTaggedString is a string which is tagged with a language.
Expand Down Expand Up @@ -74,7 +74,7 @@ public function getLanguage()
*/
public function toJsonLd($useNativeTypes = true)
{
$result = new Object();
$result = new stdClass();
$result->{'@value'} = $this->value;
$result->{'@language'} = $this->language;

Expand Down
4 changes: 2 additions & 2 deletions Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;

/**
* A Node represents a node in a JSON-LD graph.
Expand Down Expand Up @@ -412,7 +412,7 @@ public function toJsonLd($useNativeTypes = true)
} elseif (is_object($value)) { // language-tagged string or typed value
$node->{$prop}[] = $value->toJsonLd($useNativeTypes);
} else {
$val = new Object();
$val = new stdClass();
$val->{'@value'} = $value;
$node->{$prop}[] = $val;
}
Expand Down
64 changes: 32 additions & 32 deletions Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;
use ML\JsonLD\Exception\JsonLdException;
use ML\JsonLD\Exception\InvalidQuadException;
use ML\IRI\IRI;
Expand Down Expand Up @@ -238,8 +238,8 @@ public static function parse($document)
*/
public function getDocument($input)
{
$nodeMap = new Object();
$nodeMap->{'-' . JsonLD::DEFAULT_GRAPH} = new Object();
$nodeMap = new stdClass();
$nodeMap->{'-' . JsonLD::DEFAULT_GRAPH} = new stdClass();
$this->generateNodeMap($nodeMap, $input);

// We need to keep track of blank nodes as they are renamed when
Expand Down Expand Up @@ -365,7 +365,7 @@ public function expand(&$element, $activectx = array(), $activeprty = null, $fra
$properties = get_object_vars($element);
ksort($properties);

$element = new Object();
$element = new stdClass();

foreach ($properties as $property => $value) {
$expProperty = $this->expandIri($property, $activectx, false, true);
Expand Down Expand Up @@ -465,15 +465,15 @@ public function expand(&$element, $activectx = array(), $activeprty = null, $fra
$value = array($value);
}

$obj = new Object();
$obj = new stdClass();
$obj->{'@list'} = $value;
$value = $obj;
}

$target = $element;
if ($this->getPropertyDefinition($activectx, $property, '@reverse')) {
if (false === property_exists($target, '@reverse')) {
$target->{'@reverse'} = new Object();
$target->{'@reverse'} = new stdClass();
}
$target = $target->{'@reverse'};

Expand Down Expand Up @@ -749,7 +749,7 @@ private function expandKeywordValue(&$element, $activeprty, $keyword, $value, $a
$value = get_object_vars($value);

if ((count($value) > 0) && (false === property_exists($element, $keyword))) {
$element->{$keyword} = new Object();
$element->{$keyword} = new stdClass();
}

foreach ($value as $prop => $val) {
Expand Down Expand Up @@ -789,7 +789,7 @@ private function expandValue($value, $activectx, $activeprty)
{
$def = $this->getPropertyDefinition($activectx, $activeprty);

$result = new Object();
$result = new stdClass();

if ('@id' === $def['@type']) {
$result->{'@id'} = $this->expandIri($value, $activectx, true);
Expand Down Expand Up @@ -961,7 +961,7 @@ public function compact(&$element, $activectx = array(), $inversectx = array(),
ksort($properties);

$inReverse = ('@reverse' === $activeprty);
$element = new Object();
$element = new stdClass();

foreach ($properties as $property => $value) {
if (in_array($property, self::$keywords)) {
Expand Down Expand Up @@ -1041,7 +1041,7 @@ public function compact(&$element, $activectx = array(), $inversectx = array(),

if (in_array($def['@container'], array('@language', '@index'))) {
if (false === property_exists($element, $activeprty)) {
$element->{$activeprty} = new Object();
$element->{$activeprty} = new stdClass();
}

$def[$def['@container']] = $item->{$def['@container']};
Expand Down Expand Up @@ -1074,7 +1074,7 @@ public function compact(&$element, $activectx = array(), $inversectx = array(),

continue; // ... continue with next value
} else {
$result = new Object();
$result = new stdClass();

$alias = $this->compactIri('@list', $activectx, $inversectx, null, true);
$result->{$alias} = $item->{'@list'};
Expand Down Expand Up @@ -1941,7 +1941,7 @@ private function generateNodeMap(
}
} elseif (property_exists($element, '@list')) {
// lists
$result = new Object();
$result = new stdClass();
$result->{'@list'} = array();

$this->generateNodeMap($nodeMap, $element->{'@list'}, $activegraph, $activeid, $activeprty, $result);
Expand All @@ -1965,7 +1965,7 @@ private function generateNodeMap(

// Create node in node map if it doesn't exist yet
if (false === property_exists($nodeMap->{'-' . $activegraph}, '-' . $id)) {
$node = new Object();
$node = new stdClass();
$node->{'@id'} = $id;
$nodeMap->{'-' . $activegraph}->{'-' . $id} = $node;
} else {
Expand All @@ -1976,7 +1976,7 @@ private function generateNodeMap(
if (is_object($activeid)) {
$this->mergeIntoProperty($node, $activeprty, $activeid, true, true);
} elseif (null !== $activeprty) {
$reference = new Object();
$reference = new stdClass();
$reference->{'@id'} = $id;

if (null === $list) {
Expand Down Expand Up @@ -2025,7 +2025,7 @@ private function generateNodeMap(
if (property_exists($element, '@graph')) {
if (JsonLD::MERGED_GRAPH !== $activegraph) {
if (false === property_exists($nodeMap, '-' . $id)) {
$nodeMap->{'-' . $id} = new Object();
$nodeMap->{'-' . $id} = new stdClass();
}

$this->generateNodeMap($nodeMap, $element->{'@graph'}, $id);
Expand Down Expand Up @@ -2087,8 +2087,8 @@ private function getBlankNodeId($id = null)
*/
public function flatten($element)
{
$nodeMap = new Object();
$nodeMap->{'-' . JsonLD::DEFAULT_GRAPH} = new Object();
$nodeMap = new stdClass();
$nodeMap->{'-' . JsonLD::DEFAULT_GRAPH} = new stdClass();

$this->generateNodeMap($nodeMap, $element);

Expand All @@ -2099,7 +2099,7 @@ public function flatten($element)
// the graph in the default graph
foreach ($nodeMap as $graphName => $graph) {
if (!isset($defaultGraph->{$graphName})) {
$defaultGraph->{$graphName} = new Object();
$defaultGraph->{$graphName} = new stdClass();
$defaultGraph->{$graphName}->{'@id'} = substr($graphName, 1);
}

Expand Down Expand Up @@ -2129,8 +2129,8 @@ public function flatten($element)
*/
public function toRdf(array $document)
{
$nodeMap = new Object();
$nodeMap->{'-' . JsonLD::DEFAULT_GRAPH} = new Object();
$nodeMap = new stdClass();
$nodeMap->{'-' . JsonLD::DEFAULT_GRAPH} = new stdClass();

$this->generateNodeMap($nodeMap, $document);

Expand Down Expand Up @@ -2273,9 +2273,9 @@ private function listToRdf(array $entries, array &$quads, IRI $graph = null)
*/
public function fromRdf(array $quads)
{
$graphs = new Object();
$graphs->{JsonLD::DEFAULT_GRAPH} = new Object();
$usages = new Object();
$graphs = new stdClass();
$graphs->{JsonLD::DEFAULT_GRAPH} = new stdClass();
$usages = new stdClass();

foreach ($quads as $quad) {
$graphName = JsonLD::DEFAULT_GRAPH;
Expand All @@ -2292,7 +2292,7 @@ public function fromRdf(array $quads)
}

if (false === isset($graphs->{$graphName})) {
$graphs->{$graphName} = new Object();
$graphs->{$graphName} = new stdClass();
}
$graph = $graphs->{$graphName};

Expand Down Expand Up @@ -2487,7 +2487,7 @@ public function frame($element, $frame)

$frame = $frame[0];

$options = new Object();
$options = new stdClass();
$options->{'@embed'} = true;
$options->{'@embedChildren'} = true; // TODO Change this as soon as the tests haven been updated

Expand All @@ -2500,7 +2500,7 @@ public function frame($element, $frame)
}
}

$procOptions = new Object();
$procOptions = new stdClass();
$procOptions->base = (string) $this->baseIri; // TODO Check which base IRI to use
$procOptions->compactArrays = $this->compactArrays;
$procOptions->optimize = $this->optimize;
Expand All @@ -2517,8 +2517,8 @@ public function frame($element, $frame)
$graph = JsonLD::DEFAULT_GRAPH;
}

$nodeMap = new Object();
$nodeMap->{'-' . $graph} = new Object();
$nodeMap = new stdClass();
$nodeMap->{'-' . $graph} = new stdClass();
$processor->generateNodeMap($nodeMap, $element, $graph);

// Sort the node map to ensure a deterministic output
Expand Down Expand Up @@ -2565,7 +2565,7 @@ private function nodeMatchesFrame($node, $frame, $options, $nodeMap, $graph, &$p
$filter = get_object_vars($frame);
}

$result = new Object();
$result = new stdClass();

// Make sure that @id is always in the result if the node matches the filter
if (property_exists($node, '@id')) {
Expand Down Expand Up @@ -2648,7 +2648,7 @@ private function nodeMatchesFrame($node, $frame, $options, $nodeMap, $graph, &$p
foreach ($validValues as $validValue) {
if (is_object($validValue) && property_exists($validValue, '@default')) {
if (null === $validValue->{'@default'}) {
$result->{$property} = new Object();
$result->{$property} = new stdClass();
$result->{$property}->{'@null'} = true;
} else {
$result->{$property} = (is_array($validValue->{'@default'}))
Expand Down Expand Up @@ -2749,7 +2749,7 @@ private function nodeMatchesFrame($node, $frame, $options, $nodeMap, $graph, &$p

// Discard subtree if this object should not be embedded
if ((false === $options->{'@embed'}) && property_exists($node, '@id')) {
$result = new Object();
$result = new stdClass();
$result->{'@id'} = $node->{'@id'};
$parent[] = $result;

Expand Down Expand Up @@ -2941,7 +2941,7 @@ private static function sortTerms($a, $b)
private static function objectToJsonLd($object, $useNativeTypes = true)
{
if ($object instanceof IRI) {
$result = new Object();
$result = new stdClass();
$result->{'@id'} = (string) $object;

return $result;
Expand Down
4 changes: 2 additions & 2 deletions TypedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;

/**
* A typed value represents a value with an associated type.
Expand Down Expand Up @@ -81,7 +81,7 @@ public function getType()
*/
public function toJsonLd($useNativeTypes = true)
{
$result = new Object();
$result = new stdClass();

if (RdfConstants::XSD_STRING === $this->type) {
$result->{'@value'} = $this->value;
Expand Down
2 changes: 1 addition & 1 deletion Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass;

/**
* Value is the abstract base class used for typed values and
Expand Down

0 comments on commit e4fc97b

Please sign in to comment.