From e232f6a3d1231b07162e414e3b89846273951d3e Mon Sep 17 00:00:00 2001 From: Krzysztof Grabania Date: Wed, 17 Apr 2024 16:02:04 +0200 Subject: [PATCH] fix: fix phpstan errors --- src/Admin/PostTable.php | 8 +++++++- src/Store/Carrier.php | 8 +++----- src/Store/GlobalMergeTag.php | 5 +---- src/Store/Notification.php | 1 + src/Store/Resolver.php | 3 ++- src/Store/Trigger.php | 6 ++---- src/Traits/Storage.php | 16 +++++++++------- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/Admin/PostTable.php b/src/Admin/PostTable.php index 374c9903a..9586f41e6 100644 --- a/src/Admin/PostTable.php +++ b/src/Admin/PostTable.php @@ -201,8 +201,14 @@ public function adjustTrashLink($rowActions, $post) return $rowActions; } + $deleteUrl = get_delete_post_link($post->ID, '', true); + + if (!is_string($deleteUrl)) { + return $rowActions; + } + $rowActions['trash'] = '' . esc_html__('Remove', 'notification') . ''; diff --git a/src/Store/Carrier.php b/src/Store/Carrier.php index dc3a11afe..f1112c947 100644 --- a/src/Store/Carrier.php +++ b/src/Store/Carrier.php @@ -10,16 +10,14 @@ namespace BracketSpace\Notification\Store; -use BracketSpace\Notification\Interfaces\Storable; +use BracketSpace\Notification\Interfaces; use BracketSpace\Notification\Traits\Storage; /** * Carrier Store - * - * @method static array all() Gets all registered Carriers - * @method static \BracketSpace\Notification\Interfaces\Sendable|null get(string $index) Gets registered Carrier */ -class Carrier implements Storable +class Carrier implements Interfaces\Storable { + /** @use Storage */ use Storage; } diff --git a/src/Store/GlobalMergeTag.php b/src/Store/GlobalMergeTag.php index e1982a92d..ad13bc63f 100644 --- a/src/Store/GlobalMergeTag.php +++ b/src/Store/GlobalMergeTag.php @@ -15,12 +15,9 @@ /** * Global Merge Tag Store - * //phpcs:ignore Generic.Files.LineLength.TooLong - * @method static array all() Gets all registered Global MergeTags - * //phpcs:ignore Generic.Files.LineLength.TooLong - * @method static \BracketSpace\Notification\Interfaces\Taggable|null get(string $index) Gets registered Global MergeTag */ class GlobalMergeTag implements Interfaces\Storable { + /** @use Storage */ use Storage; } diff --git a/src/Store/Notification.php b/src/Store/Notification.php index 3b3babd44..46d755851 100644 --- a/src/Store/Notification.php +++ b/src/Store/Notification.php @@ -20,6 +20,7 @@ class Notification implements Storable { use Casegnostic; + /** @use Storage */ use Storage; /** diff --git a/src/Store/Resolver.php b/src/Store/Resolver.php index eb75e8671..87d23931b 100644 --- a/src/Store/Resolver.php +++ b/src/Store/Resolver.php @@ -18,12 +18,13 @@ */ class Resolver implements Interfaces\Storable { + /** @use Storage */ use Storage; /** * Gets all Resolvers sorted by priority. * - * @return array + * @return array * @since 8.0.0 */ public static function sorted(): array diff --git a/src/Store/Trigger.php b/src/Store/Trigger.php index fe36f7ea9..ccc7b33a2 100644 --- a/src/Store/Trigger.php +++ b/src/Store/Trigger.php @@ -15,18 +15,16 @@ /** * Trigger Store - * - * @method static array all() Gets all registered Triggers - * @method static \BracketSpace\Notification\Interfaces\Triggerable|null get(string $index) Gets registered Trigger */ class Trigger implements Interfaces\Storable { + /** @use Storage */ use Storage; /** * Gets all Triggers grouped. * - * @return array> + * @return array> * @since 8.0.0 */ public static function grouped(): array diff --git a/src/Traits/Storage.php b/src/Traits/Storage.php index 186831fde..96f1bf61d 100644 --- a/src/Traits/Storage.php +++ b/src/Traits/Storage.php @@ -14,20 +14,22 @@ /** * Storage trait + * + * @template TItem */ trait Storage { /** * Stored items * - * @var array + * @var array */ - private static $items = []; + protected static $items = []; /** * Adds an item to the Store * - * @param mixed $item Item to add. + * @param TItem $item Item to add. * @return void * @since 8.0.0 */ @@ -40,7 +42,7 @@ public static function add($item) * Inserts an item at a specific index. * * @param int|string $index Item index. - * @param mixed $item Item to add. + * @param TItem $item Item to add. * @return void * @since 8.0.0 */ @@ -64,7 +66,7 @@ public static function insert($index, $item) /** * Gets all items * - * @return array + * @return array * @since 8.0.0 */ public static function all(): array @@ -87,7 +89,7 @@ public static function clear() * Get item by index * * @param mixed $index Intex of an item. - * @return mixed + * @return TItem|null * @since 8.0.0 */ public static function get($index) @@ -101,7 +103,7 @@ public static function get($index) ) ); - return; + return null; } return static::$items[$index];