Skip to content

Commit

Permalink
Ensure compatibility with PHP 7.4, 8.0, 8.1, 8.2, 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Angatar committed Dec 8, 2023
1 parent 7407d25 commit dcd970a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/Schema/Rdf/RdfGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ public static function fromEasyRdf(EasyRdfGraph $graph): self
/**
* Ensures that any EasyRdf\Graph provided by reference will be wrapped in
* an RdfGraph.
*
* @param EasyRdfGraph|RdfGraph &$graph
*/
public static function ensureGraphClass(EasyRdfGraph|RdfGraph &$graph): void
public static function ensureGraphClass(&$graph): void
{
$graph = ($graph instanceof EasyRdfGraph) ? self::fromEasyRdf($graph) : $graph;
}
Expand All @@ -147,7 +149,7 @@ public static function ensureGraphClass(EasyRdfGraph|RdfGraph &$graph): void
*/
public static function ensureGraphsClass(array &$graphs): void
{
array_walk($graphs, 'self::ensureGraphClass');
array_walk($graphs, self::class.'::ensureGraphClass');
}

/**
Expand Down
25 changes: 15 additions & 10 deletions src/Schema/Rdf/RdfResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class RdfResource implements \ArrayAccess
/**
* Constructor, creates the RdfResource decorating a freshly created
* or given EasyRdf\Resource with new resource naming capabilities.
*
* @param EasyRdfGraph|RdfGraph|null $graph
*/
public function __construct(?string $uri, EasyRdfGraph|RdfGraph|null $graph = null, ?EasyRdfResource $resource = null)
public function __construct(?string $uri, $graph = null, ?EasyRdfResource $resource = null)
{
$graph = ($graph instanceof RdfGraph) ? $graph->getEasyGraph() : $graph;
$this->resource = $resource ?? new EasyRdfResource($uri, $graph);
Expand Down Expand Up @@ -281,7 +283,7 @@ public static function fromEasyRdf(EasyRdfResource $resource): self
* Turns any EasyRdf\Resource, provided by reference, into an RdfResource.
* Any form of resource is accepted but only EasyRdf\Resources are impacted.
*
* @param mixed &$resource
* @param &$resource mixed resource types
*/
public static function ensureResourceClass(&$resource): void
{
Expand All @@ -294,18 +296,18 @@ public static function ensureResourceClass(&$resource): void
*/
public static function ensureResourcesClass(array &$resources): void
{
array_walk($resources, 'self::ensureResourceClass');
array_walk($resources, self::class.'::ensureResourceClass');
}

/**
* Extends the capabilities of any EasyRdf\Resource provided by turning it
* into an RdfResource.
*
* @param mixed $resource
* @param $resource mixed resource types
*
* @return mixed $resource
* @return $resource mixed but EasyRdf\Resource is wrapped into an RdfResource
*/
public static function wrapEasyRdfResource($resource): mixed
public static function wrapEasyRdfResource($resource)
{
$resource = ($resource instanceof EasyRdfResource) ? self::fromEasyRdf($resource) : $resource;

Expand All @@ -318,15 +320,17 @@ public static function wrapEasyRdfResource($resource): mixed
*/
public static function wrapEasyRdfResources(array $resources): array
{
array_walk($resources, 'self::ensureResourceClass');
array_walk($resources, self::class.'::ensureResourceClass');

return $resources;
}

/**
* Returns the corresponding EasyRdf\Resource for any RdfResource provided.
*
* @param mixed $resource
* @param $resource mixed resource types
*
* @return $resource mixed but any RdfResource will return its contained EasyRdf\resource
*/
public static function fromRdftoEasyRdfResource($resource)
{
Expand All @@ -341,7 +345,7 @@ public static function fromRdftoEasyRdfResource($resource)
*/
public static function fromRdftoEasyRdfResources(array $resources): array
{
array_walk($resources, 'self::ensureEasyResourceClass');
array_walk($resources, self::class.'::ensureEasyResourceClass');

return $resources;
}
Expand Down Expand Up @@ -401,7 +405,8 @@ public function offsetExists($offset): bool
/**
* Array Access Interface: perform get at using array syntax.
*/
public function offsetGet($offset): mixed
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->resource->offsetGet($offset);
}
Expand Down

0 comments on commit dcd970a

Please sign in to comment.