diff --git a/src/Exception.php b/src/Exception.php index 455419b..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 = null): 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 c01ffef..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 = null) + final public function __construct(Filesystem $filesystem, Response $response, ?Graph $graph = null) { $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']);