Skip to content

Commit

Permalink
PHP 8.4 deprecation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed Sep 26, 2024
1 parent 5b14f82 commit 19ea4aa
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
38 changes: 19 additions & 19 deletions src/acdhOeaw/arche/lib/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ static public function factoryInteractive(?string $cfgLocation = null,
*
* @param string $url
* @param array<mixed> $guzzleOptions
* @param string $realUrl if provided, the final resource URL will be stored
* @param string|null $realUrl if provided, the final resource URL will be stored
* in this variable.
* @param string $metaReadModeHeader header used by the repository to denote
* @param string|null $metaReadModeHeader header used by the repository to denote
* the metadata read mode. Providing this parameter will speed up the
* initialization if the $url points to a repository resource.
* @return self
*/
static public function factoryFromUrl(string $url,
array $guzzleOptions = [],
string &$realUrl = null,
string $metaReadModeHeader = null): self {
?string &$realUrl = null,
?string $metaReadModeHeader = null): self {
$resolveOptions = $guzzleOptions;
$resolveOptions['http_errors'] = false;
$resolveOptions['allow_redirects'] = ['max' => 10, 'strict' => true, 'track_redirects' => true];
Expand Down Expand Up @@ -272,18 +272,18 @@ public function getBaseUrl(): string {
* Creates a repository resource.
*
* @param DatasetNodeInterface $metadata resource metadata
* @param BinaryPayload $payload resource binary payload (can be null)
* @param string $class an optional class of the resulting object representing the resource
* @param BinaryPayload|null $payload resource binary payload (can be null)
* @param string|null $class an optional class of the resulting object representing the resource
* (to be used by extension libraries)
* @param string $readMode scope of the metadata returned by the repository
* - see the META_* constants defined by the RepoResourceInterface
* @param string $parentProperty RDF property to be used by the metadata
* @param string|null $parentProperty RDF property to be used by the metadata
* read mode denoted by the $readMode parameter
* @return RepoResource
*/
public function createResource(DatasetNodeInterface $metadata,
BinaryPayload $payload = null,
string $class = null,
?BinaryPayload $payload = null,
?string $class = null,
string $readMode = RepoResourceInterface::META_RESOURCE,
?string $parentProperty = null): RepoResource {
return $this->createResourceAsync($metadata, $payload, $class, $readMode, $parentProperty)->wait(true) ?? throw new RuntimeException('Promise returned null');
Expand All @@ -293,16 +293,16 @@ public function createResource(DatasetNodeInterface $metadata,
* Asynchronous version of createResource()
*
* @param DatasetNodeInterface $metadata
* @param BinaryPayload $payload
* @param string $class
* @param BinaryPayload|null $payload
* @param string|null $class
* @param string $readMode
* @param string|null $parentProperty
* @return RepoResourcePromise
* @see createResource()
*/
public function createResourceAsync(DatasetNodeInterface $metadata,
BinaryPayload $payload = null,
string $class = null,
?BinaryPayload $payload = null,
?string $class = null,
string $readMode = RepoResourceInterface::META_RESOURCE,
?string $parentProperty = null): RepoResourcePromise {
$sbj = DF::namedNode($this->baseUri);
Expand Down Expand Up @@ -437,37 +437,37 @@ public function map(iterable $iter, callable $func, int $concurrency = 1,
* matching the search, an error is thrown.
*
* @param array<string> $ids an array of identifiers (being strings)
* @param string $class an optional class of the resulting object representing the resource
* @param string $class|null an optional class of the resulting object representing the resource
* (to be used by extension libraries)
* @return RepoResource
* @throws NotFound
* @throws AmbiguousMatch
*/
public function getResourceByIds(array $ids, string $class = null): RepoResource {
public function getResourceByIds(array $ids, ?string $class = null): RepoResource {
return $this->getResourceByIdsAsync($ids, $class)->wait(true) ?? throw new RuntimeException('Promise returned null');
}

/**
* Asynchronous version of getResourceByIds()
*
* @param string $id
* @param string $class
* @param string|null $class
* @return RepoResourcePromise
* @see getResourceByIds()
*/
public function getResourceByIdAsync(string $id, string $class = null): RepoResourcePromise {
public function getResourceByIdAsync(string $id, ?string $class = null): RepoResourcePromise {
return $this->getResourceByIdsAsync([$id], $class);
}

/**
* Asynchronous version of getResourceByIds()
*
* @param array<string> $ids
* @param string $class
* @param string|null $class
* @return RepoResourcePromise
* @see getResourceByIds()
*/
public function getResourceByIdsAsync(array $ids, string $class = null): RepoResourcePromise {
public function getResourceByIdsAsync(array $ids, ?string $class = null): RepoResourcePromise {
$url = $this->baseUrl . 'search';
$headers = [
'Content-Type' => 'application/x-www-form-urlencoded',
Expand Down
4 changes: 2 additions & 2 deletions src/acdhOeaw/arche/lib/RepoDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ public function getSmartSearch(): SmartSearch {
* matching the search, an error is thrown.
*
* @param array<string> $ids an array of identifiers (being strings)
* @param string $class an optional class of the resulting object representing the resource
* @param string|null $class an optional class of the resulting object representing the resource
* (to be used by extension libraries)
* @return RepoResourceDb
* @throws NotFound
* @throws AmbiguousMatch
*/
public function getResourceByIds(array $ids, string $class = null): RepoResourceDb {
public function getResourceByIds(array $ids, ?string $class = null): RepoResourceDb {
$placeholders = substr(str_repeat('?, ', count($ids)), 0, -2);
$query = "SELECT DISTINCT id FROM identifiers WHERE ids IN ($placeholders)";
$query = $this->pdo->prepare($query);
Expand Down
8 changes: 4 additions & 4 deletions src/acdhOeaw/arche/lib/RepoInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public function getSchema(): Schema;
* Throws an error on failure.
*
* @param string $id
* @param string $class an optional class of the resulting object representing the resource
* @param string|null $class an optional class of the resulting object representing the resource
* (to be used by extension libraries)
* @return RepoResourceInterface
*/
public function getResourceById(string $id, string $class = null): RepoResourceInterface;
public function getResourceById(string $id, ?string $class = null): RepoResourceInterface;

/**
* Tries to find a single repository resource matching provided identifiers.
Expand All @@ -72,11 +72,11 @@ public function getResourceById(string $id, string $class = null): RepoResourceI
* matching the search, an error is thrown.
*
* @param array<string> $ids an array of identifiers (being strings)
* @param string $class an optional class of the resulting object representing the resource
* @param string|null $class an optional class of the resulting object representing the resource
* (to be used by extension libraries)
* @return RepoResourceInterface
*/
public function getResourceByIds(array $ids, string $class = null): RepoResourceInterface;
public function getResourceByIds(array $ids, ?string $class = null): RepoResourceInterface;

/**
* Returns repository resources matching a given SQL search query.
Expand Down
8 changes: 4 additions & 4 deletions src/acdhOeaw/arche/lib/RepoResourceDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(string $urlOrId, RepoInterface $repo) {
* or e.g. reset them back to their current state in the repository)
* @param string $mode scope of the metadata returned by the repository - see the
* `RepoDb()::getPdoStatementBySqlQuery()` method
* @param string $parentProperty RDF property name used to find related resources
* @param string|null $parentProperty RDF property name used to find related resources
* - see the getMetadataQuery() method
* @param array<string> $resourceProperties list of RDF properties to be includes
* for a resource (if the list is empty, all exsiting RDF properties are included)
Expand All @@ -83,7 +83,7 @@ public function __construct(string $urlOrId, RepoInterface $repo) {
*/
public function loadMetadata(bool $force = false,
string $mode = self::META_RESOURCE,
string $parentProperty = null,
?string $parentProperty = null,
array $resourceProperties = [],
array $relativesProperties = []): void {
if ($force || count($this->metadata) === 0) {
Expand All @@ -99,7 +99,7 @@ public function loadMetadata(bool $force = false,
*
* @param string $mode scope of the metadata returned by the repository - see the
* `RepoDb()::getPdoStatementBySqlQuery()` method
* @param string $parentProperty RDF property name used to find related resources
* @param string|null $parentProperty RDF property name used to find related resources
* @param array<string> $resourceProperties list of RDF properties to be includes
* for a resource (if the list is empty, all exsiting RDF properties are included)
* @param array<string> $relativesProperties list of RDF properties to be includes
Expand All @@ -108,7 +108,7 @@ public function loadMetadata(bool $force = false,
* @return PDOStatement
*/
public function getMetadataStatement(string $mode = self::META_RESOURCE,
string $parentProperty = null,
?string $parentProperty = null,
array $resourceProperties = [],
array $relativesProperties = []): PDOStatement {
$config = new SearchConfig();
Expand Down
4 changes: 2 additions & 2 deletions src/acdhOeaw/arche/lib/RepoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public function getHeaderName(string $purpose): string {
* Throws an error on failure.
*
* @param string $id
* @param string $class an optional class of the resulting object representing the resource
* @param string|null $class an optional class of the resulting object representing the resource
* (to be used by extension libraries)
* @return RepoResourceInterface
*/
public function getResourceById(string $id, string $class = null): RepoResourceInterface {
public function getResourceById(string $id, ?string $class = null): RepoResourceInterface {
return $this->getResourceByIds([$id], $class);
}

Expand Down

0 comments on commit 19ea4aa

Please sign in to comment.