Skip to content

Commit dcd970a

Browse files
committed
Ensure compatibility with PHP 7.4, 8.0, 8.1, 8.2, 8.3
1 parent 7407d25 commit dcd970a

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/Schema/Rdf/RdfGraph.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ public static function fromEasyRdf(EasyRdfGraph $graph): self
135135
/**
136136
* Ensures that any EasyRdf\Graph provided by reference will be wrapped in
137137
* an RdfGraph.
138+
*
139+
* @param EasyRdfGraph|RdfGraph &$graph
138140
*/
139-
public static function ensureGraphClass(EasyRdfGraph|RdfGraph &$graph): void
141+
public static function ensureGraphClass(&$graph): void
140142
{
141143
$graph = ($graph instanceof EasyRdfGraph) ? self::fromEasyRdf($graph) : $graph;
142144
}
@@ -147,7 +149,7 @@ public static function ensureGraphClass(EasyRdfGraph|RdfGraph &$graph): void
147149
*/
148150
public static function ensureGraphsClass(array &$graphs): void
149151
{
150-
array_walk($graphs, 'self::ensureGraphClass');
152+
array_walk($graphs, self::class.'::ensureGraphClass');
151153
}
152154

153155
/**

src/Schema/Rdf/RdfResource.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ class RdfResource implements \ArrayAccess
3838
/**
3939
* Constructor, creates the RdfResource decorating a freshly created
4040
* or given EasyRdf\Resource with new resource naming capabilities.
41+
*
42+
* @param EasyRdfGraph|RdfGraph|null $graph
4143
*/
42-
public function __construct(?string $uri, EasyRdfGraph|RdfGraph|null $graph = null, ?EasyRdfResource $resource = null)
44+
public function __construct(?string $uri, $graph = null, ?EasyRdfResource $resource = null)
4345
{
4446
$graph = ($graph instanceof RdfGraph) ? $graph->getEasyGraph() : $graph;
4547
$this->resource = $resource ?? new EasyRdfResource($uri, $graph);
@@ -281,7 +283,7 @@ public static function fromEasyRdf(EasyRdfResource $resource): self
281283
* Turns any EasyRdf\Resource, provided by reference, into an RdfResource.
282284
* Any form of resource is accepted but only EasyRdf\Resources are impacted.
283285
*
284-
* @param mixed &$resource
286+
* @param &$resource mixed resource types
285287
*/
286288
public static function ensureResourceClass(&$resource): void
287289
{
@@ -294,18 +296,18 @@ public static function ensureResourceClass(&$resource): void
294296
*/
295297
public static function ensureResourcesClass(array &$resources): void
296298
{
297-
array_walk($resources, 'self::ensureResourceClass');
299+
array_walk($resources, self::class.'::ensureResourceClass');
298300
}
299301

300302
/**
301303
* Extends the capabilities of any EasyRdf\Resource provided by turning it
302304
* into an RdfResource.
303305
*
304-
* @param mixed $resource
306+
* @param $resource mixed resource types
305307
*
306-
* @return mixed $resource
308+
* @return $resource mixed but EasyRdf\Resource is wrapped into an RdfResource
307309
*/
308-
public static function wrapEasyRdfResource($resource): mixed
310+
public static function wrapEasyRdfResource($resource)
309311
{
310312
$resource = ($resource instanceof EasyRdfResource) ? self::fromEasyRdf($resource) : $resource;
311313

@@ -318,15 +320,17 @@ public static function wrapEasyRdfResource($resource): mixed
318320
*/
319321
public static function wrapEasyRdfResources(array $resources): array
320322
{
321-
array_walk($resources, 'self::ensureResourceClass');
323+
array_walk($resources, self::class.'::ensureResourceClass');
322324

323325
return $resources;
324326
}
325327

326328
/**
327329
* Returns the corresponding EasyRdf\Resource for any RdfResource provided.
328330
*
329-
* @param mixed $resource
331+
* @param $resource mixed resource types
332+
*
333+
* @return $resource mixed but any RdfResource will return its contained EasyRdf\resource
330334
*/
331335
public static function fromRdftoEasyRdfResource($resource)
332336
{
@@ -341,7 +345,7 @@ public static function fromRdftoEasyRdfResource($resource)
341345
*/
342346
public static function fromRdftoEasyRdfResources(array $resources): array
343347
{
344-
array_walk($resources, 'self::ensureEasyResourceClass');
348+
array_walk($resources, self::class.'::ensureEasyResourceClass');
345349

346350
return $resources;
347351
}
@@ -401,7 +405,8 @@ public function offsetExists($offset): bool
401405
/**
402406
* Array Access Interface: perform get at using array syntax.
403407
*/
404-
public function offsetGet($offset): mixed
408+
#[\ReturnTypeWillChange]
409+
public function offsetGet($offset)
405410
{
406411
return $this->resource->offsetGet($offset);
407412
}

0 commit comments

Comments
 (0)