Skip to content

Commit

Permalink
Support PHP 8.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 2, 2024
1 parent 77cc0f3 commit 64ee73c
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 23 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ test-container-83:
@-docker-compose run --rm app83 bash
@docker-compose down -v

.PHONY: test-container-84
test-container-84:
@-docker-compose run --rm app84 bash
@docker-compose down -v

.PHONY: lint
lint:
@XDEBUG_MODE=off phpcs -s
Expand Down
2 changes: 1 addition & 1 deletion lib/AuthenticationRequired.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AuthenticationRequired extends ClientError implements SecurityError
public function __construct(
string $message = self::DEFAULT_MESSAGE,
int $code = ResponseStatus::STATUS_UNAUTHORIZED,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ClientError.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class ClientError extends \Exception implements Exception
* @inheritdoc
*/
public function __construct(
string $message = null,
?string $message = null,
int $code = ResponseStatus::STATUS_BAD_REQUEST,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/FileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class FileInfo
* @return string The MIME type of the file, or `application/octet-stream` if it could not
* be determined.
*/
public static function resolve_type(string $pathname, string &$extension = null): string
public static function resolve_type(string $pathname, ?string &$extension = null): string
{
$extension = '.' . \strtolower(\pathinfo($pathname, PATHINFO_EXTENSION));
$types = self::TYPES;
Expand Down
2 changes: 1 addition & 1 deletion lib/ForceRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ForceRedirect extends \Exception implements Exception
public function __construct(
public readonly string $location,
int $code = ResponseStatus::STATUS_FOUND,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($this->format_message($location), $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Headers/CacheControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private function set_cacheable(bool|string|null $value): void
/**
* If they are defined, the object is initialized with the cache directives.
*/
public function __construct(string $cache_directives = null)
public function __construct(?string $cache_directives = null)
{
if ($cache_directives) {
$this->modify($cache_directives);
Expand Down
2 changes: 1 addition & 1 deletion lib/Headers/ContentDisposition.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ContentDisposition extends Header
*
* @inheritdoc
*/
public function __construct(string $value = null, array $attributes = [])
public function __construct(?string $value = null, array $attributes = [])
{
$this->parameters['filename'] = new HeaderParameter('filename');

Expand Down
2 changes: 1 addition & 1 deletion lib/Headers/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ContentType extends Header
*
* @inheritdoc
*/
public function __construct(string $value = null, array $attributes = [])
public function __construct(?string $value = null, array $attributes = [])
{
$this->parameters['charset'] = new HeaderParameter('charset');

Expand Down
2 changes: 1 addition & 1 deletion lib/MethodNotAllowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MethodNotAllowed extends ClientError implements Exception
{
public function __construct(
public readonly string $method,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct(
"Method not allowed: $method.",
Expand Down
2 changes: 1 addition & 1 deletion lib/NotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NotFound extends ClientError implements Exception
public function __construct(
string $message = self::DEFAULT_MESSAGE,
int $code = ResponseStatus::STATUS_NOT_FOUND,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/PermissionRequired.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PermissionRequired extends ClientError implements SecurityError
public function __construct(
string $message = self::DEFAULT_MESSAGE,
int $code = ResponseStatus::STATUS_UNAUTHORIZED,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/RecoverEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RecoverEvent extends Event
public function __construct(
Throwable &$sender,
public readonly Request $request,
Response &$response = null
?Response &$response = null
) {
$this->response = &$response;
$this->exception = &$sender;
Expand Down
2 changes: 1 addition & 1 deletion lib/Responder/WithEvent/BeforeRespondEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BeforeRespondEvent extends Event

public function __construct(
public readonly Request $request,
Response &$response = null
?Response &$response = null
) {
$this->response = &$response;

Expand Down
2 changes: 1 addition & 1 deletion lib/Responder/WithEvent/RespondEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RespondEvent extends Event

public function __construct(
public readonly Request $request,
Response &$response = null
?Response &$response = null
) {
$this->response = &$response;

Expand Down
4 changes: 2 additions & 2 deletions lib/ServerError.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class ServerError extends \Exception implements Exception
* @inheritdoc
*/
public function __construct(
string $message = null,
?string $message = null,
int $code = ResponseStatus::STATUS_INTERNAL_SERVER_ERROR,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ServiceUnavailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ServiceUnavailable extends ServerError implements Exception
public function __construct(
string $message = self::DEFAULT_MESSAGE,
int $code = ResponseStatus::STATUS_SERVICE_UNAVAILABLE,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ protected function get_message(): string
return $message;
}

public function __construct(int $code = ResponseStatus::STATUS_OK, string $message = null)
public function __construct(int $code = ResponseStatus::STATUS_OK, ?string $message = null)
{
self::assert_code_is_valid($code);

Expand Down
4 changes: 2 additions & 2 deletions lib/StatusCodeNotValid.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class StatusCodeNotValid extends InvalidArgumentException implements Exception
{
public function __construct(
public readonly int $status_code,
string $message = null,
?string $message = null,
int $code = ResponseStatus::STATUS_INTERNAL_SERVER_ERROR,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message ?: $this->format_message($status_code), $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FileResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function test_get_is_modified(
bool $expected,
array $request_headers,
false|int $modified_time = false,
string $etag = null
?string $etag = null
): void {
$file = create_file();
if ($modified_time) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Headers/HeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class A extends Header
{
public const VALUE_ALIAS = 'type';

public function __construct($value = null, array $attributes = [])
public function __construct(mixed $value = null, array $attributes = [])
{
$this->parameters['p'] = new HeaderParameter('p');

Expand Down
2 changes: 1 addition & 1 deletion tests/ResponderProvider/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test_chain_with_no_match(): void
$this->assertNull($chain->responder_for_request(Request::from()));
}

public function makeProvider(Responder $responder = null, bool $shouldNotBeCalled = false): ResponderProvider
public function makeProvider(?Responder $responder = null, bool $shouldNotBeCalled = false): ResponderProvider
{
$provider = $this->createMock(ResponderProvider::class);
$provider
Expand Down

0 comments on commit 64ee73c

Please sign in to comment.