Skip to content

Commit fee3546

Browse files
whiklojlanthaler
authored andcommitted
Rename Object to JsonObject to fix conflict with PHP 7.2
Closes #79, #92
1 parent da8efc5 commit fee3546

9 files changed

+167
-161
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ php:
66
- 5.6
77
- 7.0
88
- 7.1
9+
- 7.2
910
- hhvm
1011

1112
matrix:

Document.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ML\JsonLD;
1111

12-
use stdClass as Object;
12+
use stdClass as JsonObject;
1313
use ML\IRI\IRI;
1414

1515
/**
@@ -55,8 +55,8 @@ class Document implements DocumentInterface, JsonLdSerializable
5555
*
5656
* - <em>base</em> The base IRI of the input document.
5757
*
58-
* @param string|array|object $document The JSON-LD document to process.
59-
* @param null|array|object $options Options to configure the processing.
58+
* @param string|array|JsonObject $document The JSON-LD document to process.
59+
* @param null|array|JsonObject $options Options to configure the processing.
6060
*
6161
* @return Document The parsed JSON-LD document.
6262
*
@@ -191,14 +191,14 @@ public function toJsonLd($useNativeTypes = true)
191191
}
192192

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

198198
$defGraph[] = $namedGraph;
199199
}
200200

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

204204
return array($document);

FileGetContentsLoader.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ function ($code, $severity, $msg, $msgCode, $bytesTx, $bytesMax) use (
6767

6868
// Extract HTTP Link headers
6969
$linkHeaderValues = array();
70-
for ($i = count($http_response_header) - 1; $i > $httpHeadersOffset; $i--) {
71-
if (0 === substr_compare($http_response_header[$i], 'Link:', 0, 5, true)) {
72-
$value = substr($http_response_header[$i], 5);
73-
$linkHeaderValues[] = $value;
70+
if (is_array($http_response_header)) {
71+
for ($i = count($http_response_header) - 1; $i > $httpHeadersOffset; $i--) {
72+
if (0 === substr_compare($http_response_header[$i], 'Link:', 0, 5, true)) {
73+
$value = substr($http_response_header[$i], 5);
74+
$linkHeaderValues[] = $value;
75+
}
7476
}
7577
}
7678

JsonLD.php

+43-43
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ML\JsonLD;
1111

12-
use stdClass as Object;
12+
use stdClass as JsonObject;
1313
use ML\JsonLD\Exception\JsonLdException;
1414
use ML\JsonLD\Exception\InvalidQuadException;
1515
use ML\IRI\IRI;
@@ -72,8 +72,8 @@ class JsonLD
7272
* The options parameter might be passed as associative array or as
7373
* object.
7474
*
75-
* @param string|object|array $input The JSON-LD document to process.
76-
* @param null|array|object $options Options to configure the processing.
75+
* @param string|JsonObject|array $input The JSON-LD document to process.
76+
* @param null|array|JsonObject $options Options to configure the processing.
7777
*
7878
* @return Document The parsed JSON-LD document.
7979
*
@@ -121,9 +121,9 @@ public static function getDocument($input, $options = null)
121121
* The options parameter might be passed as associative array or as
122122
* object.
123123
*
124-
* @param string|object|array $input The JSON-LD document to expand.
125-
* @param null|array|object $options Options to configure the expansion
126-
* process.
124+
* @param string|JsonObject|array $input The JSON-LD document to expand.
125+
* @param null|array|JsonObject $options Options to configure the expansion
126+
* process.
127127
*
128128
* @return array The expanded JSON-LD document.
129129
*
@@ -209,13 +209,13 @@ public static function expand($input, $options = null)
209209
* The options parameter might be passed as associative array or as
210210
* object.
211211
*
212-
* @param string|object|array $input The JSON-LD document to
212+
* @param string|JsonObject|array $input The JSON-LD document to
213213
* compact.
214-
* @param null|string|object|array $context The context.
215-
* @param null|array|object $options Options to configure the
214+
* @param null|string|JsonObject|array $context The context.
215+
* @param null|array|JsonObject $options Options to configure the
216216
* compaction process.
217217
*
218-
* @return object The compacted JSON-LD document.
218+
* @return JsonObject The compacted JSON-LD document.
219219
*
220220
* @throws JsonLdException
221221
*
@@ -236,17 +236,17 @@ public static function compact($input, $context = null, $options = null)
236236
* In contrast to {@link compact()}, this method assumes that the input
237237
* has already been expanded.
238238
*
239-
* @param array $input The JSON-LD document to
240-
* compact.
241-
* @param null|string|object|array $context The context.
242-
* @param object $options Options to configure the
243-
* compaction process.
244-
* @param bool $alwaysGraph If set to true, the resulting
245-
* document will always explicitly
246-
* contain the default graph at
247-
* the top-level.
239+
* @param array $input The JSON-LD document to
240+
* compact.
241+
* @param null|string|JsonObject|array $context The context.
242+
* @param JsonObject $options Options to configure the
243+
* compaction process.
244+
* @param bool $alwaysGraph If set to true, the resulting
245+
* document will always explicitly
246+
* contain the default graph at
247+
* the top-level.
248248
*
249-
* @return object The compacted JSON-LD document.
249+
* @return JsonObject The compacted JSON-LD document.
250250
*
251251
* @throws JsonLdException
252252
*/
@@ -274,7 +274,7 @@ private static function doCompact($input, $context, $options, $alwaysGraph = fal
274274

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

277-
$compactedDocument = new Object();
277+
$compactedDocument = new JsonObject();
278278
if (null !== $context) {
279279
$compactedDocument->{'@context'} = $context;
280280
}
@@ -335,15 +335,15 @@ private static function doCompact($input, $context, $options, $alwaysGraph = fal
335335
* The options parameter might be passed as associative array or as
336336
* object.
337337
*
338-
* @param string|object|array $input The JSON-LD document to flatten.
339-
* @param null|string|object|array $context The context to compact the
340-
* flattened document. If
341-
* <em>null</em> is passed, the
342-
* result will not be compacted.
343-
* @param null|array|object $options Options to configure the
344-
* flattening process.
338+
* @param string|JsonObject|array $input The JSON-LD document to flatten.
339+
* @param null|string|JsonObject|array $context The context to compact the
340+
* flattened document. If
341+
* <em>null</em> is passed, the
342+
* result will not be compacted.
343+
* @param null|array|JsonObject $options Options to configure the
344+
* flattening process.
345345
*
346-
* @return object The flattened JSON-LD document.
346+
* @return JsonObject The flattened JSON-LD document.
347347
*
348348
* @throws JsonLdException
349349
*
@@ -394,9 +394,9 @@ public static function flatten($input, $context = null, $options = null)
394394
* The options parameter might be passed as associative array or as
395395
* object.
396396
*
397-
* @param string|object|array $input The JSON-LD document to expand.
398-
* @param null|array|object $options Options to configure the expansion
399-
* process.
397+
* @param string|JsonObject|array $input The JSON-LD document to expand.
398+
* @param null|array|JsonObject $options Options to configure the expansion
399+
* process.
400400
*
401401
* @return Quad[] The extracted quads.
402402
*
@@ -445,9 +445,9 @@ public static function toRdf($input, $options = null)
445445
* The options parameter might be passed as associative array or as
446446
* object.
447447
*
448-
* @param Quad[] $quads Array of quads.
449-
* @param null|array|object $options Options to configure the expansion
450-
* process.
448+
* @param Quad[] $quads Array of quads.
449+
* @param null|array|JsonObject $options Options to configure the expansion
450+
* process.
451451
*
452452
* @return array The JSON-LD document in expanded form.
453453
*
@@ -503,12 +503,12 @@ public static function fromRdf(array $quads, $options = null)
503503
* The options parameter might be passed as associative array or as
504504
* object.
505505
*
506-
* @param string|object|array $input The JSON-LD document to compact.
507-
* @param string|object $frame The frame.
508-
* @param null|array|object $options Options to configure the framing
509-
* process.
506+
* @param string|JsonObject|array $input The JSON-LD document to compact.
507+
* @param string|JsonObject $frame The frame.
508+
* @param null|array|JsonObject $options Options to configure the framing
509+
* process.
510510
*
511-
* @return object The framed JSON-LD document.
511+
* @return JsonObject The framed JSON-LD document.
512512
*
513513
* @throws JsonLdException
514514
*
@@ -534,7 +534,7 @@ public static function frame($input, $frame, $options = null)
534534
$processor = new Processor($options);
535535

536536
// Store the frame's context as $frame gets modified
537-
$frameContext = new Object();
537+
$frameContext = new JsonObject();
538538
if (property_exists($frame, '@context')) {
539539
$frameContext->{'@context'} = $frame->{'@context'};
540540
}
@@ -604,9 +604,9 @@ function ($match) {
604604
/**
605605
* Merge the passed options with the options' default values.
606606
*
607-
* @param null|array|object $options The options.
607+
* @param null|array|JsonObject $options The options.
608608
*
609-
* @return object The merged options.
609+
* @return JsonObject The merged options.
610610
*/
611611
private static function mergeOptions($options)
612612
{

LanguageTaggedString.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ML\JsonLD;
1111

12-
use stdClass as Object;
12+
use stdClass as JsonObject;
1313

1414
/**
1515
* A LanguageTaggedString is a string which is tagged with a language.
@@ -74,7 +74,7 @@ public function getLanguage()
7474
*/
7575
public function toJsonLd($useNativeTypes = true)
7676
{
77-
$result = new Object();
77+
$result = new JsonObject();
7878
$result->{'@value'} = $this->value;
7979
$result->{'@language'} = $this->language;
8080

Node.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ML\JsonLD;
1111

12-
use stdClass as Object;
12+
use stdClass as JsonObject;
1313

1414
/**
1515
* A Node represents a node in a JSON-LD graph.
@@ -412,7 +412,7 @@ public function toJsonLd($useNativeTypes = true)
412412
} elseif (is_object($value)) { // language-tagged string or typed value
413413
$node->{$prop}[] = $value->toJsonLd($useNativeTypes);
414414
} else {
415-
$val = new Object();
415+
$val = new JsonObject();
416416
$val->{'@value'} = $value;
417417
$node->{$prop}[] = $val;
418418
}

0 commit comments

Comments
 (0)