Skip to content

Commit

Permalink
[PHP 8.4] Fixes for implicit nullability deprecation
Browse files Browse the repository at this point in the history
Fixes all issues that emits a deprecation notice on PHP 8.4.

See:
 - [RFC](https://wiki.php.net/rfc/deprecate-implicitly-nullable-types)
 - [PHP 8.4: Implicitly nullable parameter declarations deprecated](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated)
  • Loading branch information
Ayesh authored and theseer committed Mar 21, 2024
1 parent 951f615 commit 2ee7543
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Factory.php
Expand Up @@ -31,7 +31,7 @@ class Factory {
/** @var null|PharRegistry */
private $registry;

public function __construct(Cli\Request $request, PhiveVersion $version = null) {
public function __construct(Cli\Request $request, ?PhiveVersion $version = null) {
$this->request = $request;
$this->version = $version;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/skel/SkelCommand.php
Expand Up @@ -31,7 +31,7 @@ class SkelCommand implements Cli\Command {
/** @var Output */
private $output;

public function __construct(SkelCommandConfig $config, Cli\Output $output, PhiveVersion $version, DateTimeImmutable $now = null) {
public function __construct(SkelCommandConfig $config, Cli\Output $output, PhiveVersion $version, ?DateTimeImmutable $now = null) {
$this->config = $config;
$this->version = $version;

Expand Down
2 changes: 1 addition & 1 deletion src/shared/XmlFile.php
Expand Up @@ -68,7 +68,7 @@ public function createElement(string $name, string $text = ''): DOMElement {
return $this->getDom()->createElementNS($this->namespace, $name, $text);
}

public function query(string $xpath, DOMNode $ctx = null): DOMNodeList {
public function query(string $xpath, ?DOMNode $ctx = null): DOMNodeList {
if ($ctx === null) {
$ctx = $this->getDom()->documentElement;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/cli/Runner.php
Expand Up @@ -137,7 +137,7 @@ public function shutdownHandler(): void {
/**
* @param array<int, array<string, mixed>> $trace
*/
private function showErrorWithTrace(string $error, string $file, int $line, array $trace = null): void {
private function showErrorWithTrace(string $error, string $file, int $line, ?array $trace = null): void {
$baseLen = strlen(dirname(__DIR__, 3) . '') + 1;

$message = [$error];
Expand Down
2 changes: 1 addition & 1 deletion src/shared/config/Config.php
Expand Up @@ -33,7 +33,7 @@ class Config {
public function __construct(
Environment $environment,
Options $cliOptions,
DateTimeImmutable $now = null
?DateTimeImmutable $now = null
) {
$this->environment = $environment;
$this->cliOptions = $cliOptions;
Expand Down
4 changes: 2 additions & 2 deletions src/shared/http/CurlHttpClient.php
Expand Up @@ -55,7 +55,7 @@ public function __construct(
/**
* @throws HttpException
*/
public function head(Url $url, ETag $etag = null): HttpResponse {
public function head(Url $url, ?ETag $etag = null): HttpResponse {
$this->url = $url;
$this->etag = $etag;

Expand All @@ -69,7 +69,7 @@ public function head(Url $url, ETag $etag = null): HttpResponse {
/**
* @throws HttpException
*/
public function get(Url $url, ETag $etag = null): HttpResponse {
public function get(Url $url, ?ETag $etag = null): HttpResponse {
$this->url = $url;
$this->etag = $etag;

Expand Down
4 changes: 2 additions & 2 deletions src/shared/http/HttpClient.php
Expand Up @@ -11,7 +11,7 @@
namespace PharIo\Phive;

interface HttpClient {
public function get(Url $url, ETag $etag = null): HttpResponse;
public function get(Url $url, ?ETag $etag = null): HttpResponse;

public function head(Url $url, ETag $etag = null): HttpResponse;
public function head(Url $url, ?ETag $etag = null): HttpResponse;
}
2 changes: 1 addition & 1 deletion src/shared/http/HttpResponse.php
Expand Up @@ -23,7 +23,7 @@ class HttpResponse {
/** @var null|RateLimit */
private $rateLimit;

public function __construct(int $httpCode, string $responseBody, ETag $etag = null, RateLimit $rateLimit = null) {
public function __construct(int $httpCode, string $responseBody, ?ETag $etag = null, ?RateLimit $rateLimit = null) {
$this->responseBody = $responseBody;
$this->httpCode = $httpCode;
$this->etag = $etag;
Expand Down
6 changes: 3 additions & 3 deletions src/shared/http/RetryingHttpClient.php
Expand Up @@ -46,19 +46,19 @@ public function __construct(Cli\Output $output, HttpClient $client, int $maxTrie
$this->output = $output;
}

public function head(Url $url, ETag $etag = null): HttpResponse {
public function head(Url $url, ?ETag $etag = null): HttpResponse {
$this->triesPerformed = 0;

return $this->doTry('head', $url, $etag);
}

public function get(Url $url, ETag $etag = null): HttpResponse {
public function get(Url $url, ?ETag $etag = null): HttpResponse {
$this->triesPerformed = 0;

return $this->doTry('get', $url, $etag);
}

private function doTry(string $method, Url $url, ETag $etag = null): HttpResponse {
private function doTry(string $method, Url $url, ?ETag $etag = null): HttpResponse {
try {
$this->triesPerformed++;

Expand Down
4 changes: 2 additions & 2 deletions src/shared/http/RingdownCurlHttpClient.php
Expand Up @@ -40,11 +40,11 @@ public function __construct(HttpClient $client, CurlConfig $config, Output $outp
$this->output = $output;
}

public function get(Url $url, ETag $etag = null): HttpResponse {
public function get(Url $url, ?ETag $etag = null): HttpResponse {
return $this->execWrapper('get', $url, $etag);
}

public function head(Url $url, ETag $etag = null): HttpResponse {
public function head(Url $url, ?ETag $etag = null): HttpResponse {
return $this->execWrapper('head', $url, $etag);
}

Expand Down
6 changes: 3 additions & 3 deletions src/shared/phar/ConfiguredPhar.php
Expand Up @@ -36,9 +36,9 @@ class ConfiguredPhar {
public function __construct(
string $name,
VersionConstraint $versionConstraint,
Version $installedVersion = null,
Filename $location = null,
PharUrl $url = null,
?Version $installedVersion = null,
?Filename $location = null,
?PharUrl $url = null,
bool $copy = false
) {
$this->name = $name;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/phar/Phar.php
Expand Up @@ -30,7 +30,7 @@ class Phar {
/** @var null|string */
private $signatureFingerprint;

public function __construct(string $name, Version $version, File $file, string $signatureFingerprint = null) {
public function __construct(string $name, Version $version, File $file, ?string $signatureFingerprint = null) {
$this->name = $name;
$this->file = $file;
$this->version = $version;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/phar/RequestedPhar.php
Expand Up @@ -34,7 +34,7 @@ public function __construct(
PharIdentifier $identifier,
VersionConstraint $versionConstraint,
VersionConstraint $lockedVersion,
Filename $location = null,
?Filename $location = null,
bool $makeCopy = false
) {
$this->identifier = $identifier;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/phar/SupportedRelease.php
Expand Up @@ -28,7 +28,7 @@ class SupportedRelease implements Release {
/** @var null|Url */
private $signatureUrl;

public function __construct(string $name, Version $version, PharUrl $url, Url $signatureUrl = null, Hash $expectedHash = null) {
public function __construct(string $name, Version $version, PharUrl $url, ?Url $signatureUrl = null, ?Hash $expectedHash = null) {
$this->name = $name;
$this->version = $version;
$this->url = $url;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/phar/UsedPhar.php
Expand Up @@ -22,7 +22,7 @@ public function __construct(
Version $version,
File $file,
array $usages,
string $signatureFingerprint = null
?string $signatureFingerprint = null
) {
parent::__construct($name, $version, $file, $signatureFingerprint);
$this->usages = $usages;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/repository/UrlRepository.php
Expand Up @@ -20,7 +20,7 @@ class UrlRepository implements SourceRepository {
/**
* UrlRepository constructor.
*/
public function __construct(Url $url = null, Url $sigUrl = null) {
public function __construct(?Url $url = null, ?Url $sigUrl = null) {
$this->url = $url;
$this->sigUrl = $sigUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/RegressionTestCase.php
Expand Up @@ -80,7 +80,7 @@ protected function changeWorkingDirectory(Directory $directory): void {
* @param string $version
* @param string $filename
*/
protected function addPharToRegistry($name, $version, $filename, Filename $usage = null): void {
protected function addPharToRegistry($name, $version, $filename, ?Filename $usage = null): void {
$phar = new Phar($name, new Version($version), new File(new Filename($filename), 'foo'));
$this->getPharRegistry()->addPhar($phar);

Expand Down

0 comments on commit 2ee7543

Please sign in to comment.