Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename Object to JsonObject to fix conflict with PHP 7.2
Closes #79, #92
  • Loading branch information
whikloj authored and lanthaler committed Nov 18, 2018
1 parent da8efc5 commit fee3546
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 161 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -6,6 +6,7 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

matrix:
Expand Down
10 changes: 5 additions & 5 deletions Document.php
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

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

/**
Expand Down Expand Up @@ -55,8 +55,8 @@ class Document implements DocumentInterface, JsonLdSerializable
*
* - <em>base</em> The base IRI of the input document.
*
* @param string|array|object $document The JSON-LD document to process.
* @param null|array|object $options Options to configure the processing.
* @param string|array|JsonObject $document The JSON-LD document to process.
* @param null|array|JsonObject $options Options to configure the processing.
*
* @return Document The parsed JSON-LD document.
*
Expand Down Expand Up @@ -191,14 +191,14 @@ public function toJsonLd($useNativeTypes = true)
}

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

$defGraph[] = $namedGraph;
}

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

return array($document);
Expand Down
10 changes: 6 additions & 4 deletions FileGetContentsLoader.php
Expand Up @@ -67,10 +67,12 @@ function ($code, $severity, $msg, $msgCode, $bytesTx, $bytesMax) use (

// Extract HTTP Link headers
$linkHeaderValues = array();
for ($i = count($http_response_header) - 1; $i > $httpHeadersOffset; $i--) {
if (0 === substr_compare($http_response_header[$i], 'Link:', 0, 5, true)) {
$value = substr($http_response_header[$i], 5);
$linkHeaderValues[] = $value;
if (is_array($http_response_header)) {
for ($i = count($http_response_header) - 1; $i > $httpHeadersOffset; $i--) {
if (0 === substr_compare($http_response_header[$i], 'Link:', 0, 5, true)) {
$value = substr($http_response_header[$i], 5);
$linkHeaderValues[] = $value;
}
}
}

Expand Down
86 changes: 43 additions & 43 deletions JsonLD.php
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass as JsonObject;
use ML\JsonLD\Exception\JsonLdException;
use ML\JsonLD\Exception\InvalidQuadException;
use ML\IRI\IRI;
Expand Down Expand Up @@ -72,8 +72,8 @@ class JsonLD
* The options parameter might be passed as associative array or as
* object.
*
* @param string|object|array $input The JSON-LD document to process.
* @param null|array|object $options Options to configure the processing.
* @param string|JsonObject|array $input The JSON-LD document to process.
* @param null|array|JsonObject $options Options to configure the processing.
*
* @return Document The parsed JSON-LD document.
*
Expand Down Expand Up @@ -121,9 +121,9 @@ public static function getDocument($input, $options = null)
* The options parameter might be passed as associative array or as
* object.
*
* @param string|object|array $input The JSON-LD document to expand.
* @param null|array|object $options Options to configure the expansion
* process.
* @param string|JsonObject|array $input The JSON-LD document to expand.
* @param null|array|JsonObject $options Options to configure the expansion
* process.
*
* @return array The expanded JSON-LD document.
*
Expand Down Expand Up @@ -209,13 +209,13 @@ public static function expand($input, $options = null)
* The options parameter might be passed as associative array or as
* object.
*
* @param string|object|array $input The JSON-LD document to
* @param string|JsonObject|array $input The JSON-LD document to
* compact.
* @param null|string|object|array $context The context.
* @param null|array|object $options Options to configure the
* @param null|string|JsonObject|array $context The context.
* @param null|array|JsonObject $options Options to configure the
* compaction process.
*
* @return object The compacted JSON-LD document.
* @return JsonObject The compacted JSON-LD document.
*
* @throws JsonLdException
*
Expand All @@ -236,17 +236,17 @@ public static function compact($input, $context = null, $options = null)
* In contrast to {@link compact()}, this method assumes that the input
* has already been expanded.
*
* @param array $input The JSON-LD document to
* compact.
* @param null|string|object|array $context The context.
* @param object $options Options to configure the
* compaction process.
* @param bool $alwaysGraph If set to true, the resulting
* document will always explicitly
* contain the default graph at
* the top-level.
* @param array $input The JSON-LD document to
* compact.
* @param null|string|JsonObject|array $context The context.
* @param JsonObject $options Options to configure the
* compaction process.
* @param bool $alwaysGraph If set to true, the resulting
* document will always explicitly
* contain the default graph at
* the top-level.
*
* @return object The compacted JSON-LD document.
* @return JsonObject The compacted JSON-LD document.
*
* @throws JsonLdException
*/
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 JsonObject();
if (null !== $context) {
$compactedDocument->{'@context'} = $context;
}
Expand Down Expand Up @@ -335,15 +335,15 @@ private static function doCompact($input, $context, $options, $alwaysGraph = fal
* The options parameter might be passed as associative array or as
* object.
*
* @param string|object|array $input The JSON-LD document to flatten.
* @param null|string|object|array $context The context to compact the
* flattened document. If
* <em>null</em> is passed, the
* result will not be compacted.
* @param null|array|object $options Options to configure the
* flattening process.
* @param string|JsonObject|array $input The JSON-LD document to flatten.
* @param null|string|JsonObject|array $context The context to compact the
* flattened document. If
* <em>null</em> is passed, the
* result will not be compacted.
* @param null|array|JsonObject $options Options to configure the
* flattening process.
*
* @return object The flattened JSON-LD document.
* @return JsonObject The flattened JSON-LD document.
*
* @throws JsonLdException
*
Expand Down Expand Up @@ -394,9 +394,9 @@ public static function flatten($input, $context = null, $options = null)
* The options parameter might be passed as associative array or as
* object.
*
* @param string|object|array $input The JSON-LD document to expand.
* @param null|array|object $options Options to configure the expansion
* process.
* @param string|JsonObject|array $input The JSON-LD document to expand.
* @param null|array|JsonObject $options Options to configure the expansion
* process.
*
* @return Quad[] The extracted quads.
*
Expand Down Expand Up @@ -445,9 +445,9 @@ public static function toRdf($input, $options = null)
* The options parameter might be passed as associative array or as
* object.
*
* @param Quad[] $quads Array of quads.
* @param null|array|object $options Options to configure the expansion
* process.
* @param Quad[] $quads Array of quads.
* @param null|array|JsonObject $options Options to configure the expansion
* process.
*
* @return array The JSON-LD document in expanded form.
*
Expand Down Expand Up @@ -503,12 +503,12 @@ public static function fromRdf(array $quads, $options = null)
* The options parameter might be passed as associative array or as
* object.
*
* @param string|object|array $input The JSON-LD document to compact.
* @param string|object $frame The frame.
* @param null|array|object $options Options to configure the framing
* process.
* @param string|JsonObject|array $input The JSON-LD document to compact.
* @param string|JsonObject $frame The frame.
* @param null|array|JsonObject $options Options to configure the framing
* process.
*
* @return object The framed JSON-LD document.
* @return JsonObject The framed JSON-LD document.
*
* @throws JsonLdException
*
Expand All @@ -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 JsonObject();
if (property_exists($frame, '@context')) {
$frameContext->{'@context'} = $frame->{'@context'};
}
Expand Down Expand Up @@ -604,9 +604,9 @@ function ($match) {
/**
* Merge the passed options with the options' default values.
*
* @param null|array|object $options The options.
* @param null|array|JsonObject $options The options.
*
* @return object The merged options.
* @return JsonObject The merged options.
*/
private static function mergeOptions($options)
{
Expand Down
4 changes: 2 additions & 2 deletions LanguageTaggedString.php
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass as JsonObject;

/**
* 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 JsonObject();
$result->{'@value'} = $this->value;
$result->{'@language'} = $this->language;

Expand Down
4 changes: 2 additions & 2 deletions Node.php
Expand Up @@ -9,7 +9,7 @@

namespace ML\JsonLD;

use stdClass as Object;
use stdClass as JsonObject;

/**
* 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 JsonObject();
$val->{'@value'} = $value;
$node->{$prop}[] = $val;
}
Expand Down

0 comments on commit fee3546

Please sign in to comment.