From 4f9e38bd0bed44eac02e74d101d6ab5b3e5acb23 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Thu, 24 Apr 2025 13:21:36 +0000 Subject: [PATCH 1/2] fix nullable values --- src/Exception.php | 2 +- src/Server.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Exception.php b/src/Exception.php index 455419b..18d3a76 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -4,7 +4,7 @@ class Exception extends \Exception { - public static function create(string $error, array $context, \Exception $previous = null): Exception + public static function create(string $error, array $context, ?\Exception $previous): Exception { return new self(vsprintf($error, $context), 0, $previous); } diff --git a/src/Server.php b/src/Server.php index c01ffef..00cb538 100644 --- a/src/Server.php +++ b/src/Server.php @@ -96,7 +96,7 @@ final public function setNotifications(SolidNotificationsInterface $notification //////////////////////////////// PUBLIC API \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // @TODO: The Graph should be injected by the caller - final public function __construct(Filesystem $filesystem, Response $response, Graph $graph = null) + final public function __construct(Filesystem $filesystem, Response $response, ?Graph $graph) { $this->basePath = ''; $this->baseUrl = ''; @@ -588,6 +588,10 @@ private function handleCreateDirectoryRequest(Response $response, string $path): private function sendNotificationUpdate($path, $type) { + if (!isset($this->notifications)) { + return; + } + $baseUrl = $this->baseUrl; $this->notifications->send($baseUrl . $path, $type); @@ -788,7 +792,7 @@ private function listDirectoryAsTurtle($path) // ACL and meta files should not be listed in directory overview if ( $item['basename'] !== '.meta' - && in_array($item['extension'], ['acl', 'meta']) === false + && in_array($item['extension']??'', ['acl', 'meta']) === false ) { try { $linkMetadataResponse = $this->handleLinkMetadata(clone $this->response, $item['path']); From c9408ef9b4f1943e65e755b5bd0187958b553667 Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Mon, 5 May 2025 12:36:59 +0200 Subject: [PATCH 2/2] Change optional parameters back to optional. --- src/Exception.php | 2 +- src/Server.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Exception.php b/src/Exception.php index 18d3a76..faaa0f6 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -4,7 +4,7 @@ class Exception extends \Exception { - public static function create(string $error, array $context, ?\Exception $previous): Exception + public static function create(string $error, array $context, ?\Exception $previous = null): Exception { return new self(vsprintf($error, $context), 0, $previous); } diff --git a/src/Server.php b/src/Server.php index 00cb538..e2f0309 100644 --- a/src/Server.php +++ b/src/Server.php @@ -96,7 +96,7 @@ final public function setNotifications(SolidNotificationsInterface $notification //////////////////////////////// PUBLIC API \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // @TODO: The Graph should be injected by the caller - final public function __construct(Filesystem $filesystem, Response $response, ?Graph $graph) + final public function __construct(Filesystem $filesystem, Response $response, ?Graph $graph = null) { $this->basePath = ''; $this->baseUrl = '';