From bc40ecbc33b57e4cb85bb00b58d86f685e51355d Mon Sep 17 00:00:00 2001 From: bnomei Date: Fri, 2 Feb 2024 10:58:06 +0000 Subject: [PATCH] Fix styling --- classes/Bolt.php | 4 ++-- classes/BoostIndex.php | 2 +- classes/ModelHasBoost.php | 14 +++++++------- index.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/Bolt.php b/classes/Bolt.php index af30c3c..57b7304 100644 --- a/classes/Bolt.php +++ b/classes/Bolt.php @@ -35,7 +35,7 @@ final class Bolt */ private static $idToPage; - public function __construct(Page $parent = null) + public function __construct(?Page $parent = null) { $kirby = kirby(); $this->root = $kirby->root('content'); @@ -232,7 +232,7 @@ public function findByID(string $id, bool $cache = true, bool $extend = true): ? return $page; } - public static function page(string $id, Page $parent = null, bool $cache = true, bool $extend = true): ?Page + public static function page(string $id, ?Page $parent = null, bool $cache = true, bool $extend = true): ?Page { return (new self($parent))->findByID($id, $cache, $extend); } diff --git a/classes/BoostIndex.php b/classes/BoostIndex.php index 9d00f97..e74b02e 100644 --- a/classes/BoostIndex.php +++ b/classes/BoostIndex.php @@ -70,7 +70,7 @@ public function write(): bool return false; } - public function index(bool $force = false, Page $target = null): int + public function index(bool $force = false, ?Page $target = null): int { $count = $this->index ? count($this->index) : 0; diff --git a/classes/ModelHasBoost.php b/classes/ModelHasBoost.php index 3fff3bf..d24f77a 100644 --- a/classes/ModelHasBoost.php +++ b/classes/ModelHasBoost.php @@ -24,12 +24,12 @@ public function setBoostWillBeDeleted(bool $value): void $this->boostWillBeDeleted = $value; } - public function isContentBoosted(string $languageCode = null): bool + public function isContentBoosted(?string $languageCode = null): bool { return $this->readContentCache($languageCode) !== null; } - public function contentBoostedKey(string $languageCode = null): string + public function contentBoostedKey(?string $languageCode = null): string { $key = hash(BoostCache::hashalgo(), $this->id()); // can not use UUID since content not loaded yet if (! $languageCode) { @@ -42,7 +42,7 @@ public function contentBoostedKey(string $languageCode = null): string return $key; } - public function isContentCacheExpiredByModified(string $languageCode = null): bool + public function isContentCacheExpiredByModified(?string $languageCode = null): bool { $cache = BoostCache::singleton(); if (! $cache) { @@ -70,7 +70,7 @@ public function isContentCacheExpiredByModified(string $languageCode = null): bo return false; } - public function readContentCache(string $languageCode = null): ?array + public function readContentCache(?string $languageCode = null): ?array { if ($this->checkModifiedTimestampForContentBoost()) { if ($this->isContentCacheExpiredByModified($languageCode)) { @@ -84,7 +84,7 @@ public function readContentCache(string $languageCode = null): ?array ); } - public function readContent(string $languageCode = null): array + public function readContent(?string $languageCode = null): array { // read from boostedCache if exists $data = option('bnomei.boost.read') === false || option('debug') ? null : $this->readContentCache($languageCode); @@ -100,7 +100,7 @@ public function readContent(string $languageCode = null): array return $data; } - public function writeContentCache(array $data = null, string $languageCode = null): bool + public function writeContentCache(?array $data = null, ?string $languageCode = null): bool { $cache = BoostCache::singleton(); if (! $cache || option('bnomei.boost.write') === false) { @@ -129,7 +129,7 @@ public function writeContentCache(array $data = null, string $languageCode = nul ); } - public function writeContent(array $data, string $languageCode = null): bool + public function writeContent(array $data, ?string $languageCode = null): bool { // write to file and cache return parent::writeContent($data, $languageCode) && diff --git a/index.php b/index.php index 70c18fd..ea0649f 100644 --- a/index.php +++ b/index.php @@ -25,7 +25,7 @@ ], __DIR__); if (! function_exists('bolt')) { - function bolt(string $id, Page $parent = null, bool $cache = true, bool $extend = true) + function bolt(string $id, ?Page $parent = null, bool $cache = true, bool $extend = true) { $id = str_replace('page://', '', $id); $cacheKey = 'page/'.Str::substr($id, 0, 2).'/'.Str::substr($id, 2);