Skip to content

Commit

Permalink
fix: fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartui committed Apr 17, 2024
1 parent 5872243 commit e232f6a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
8 changes: 7 additions & 1 deletion src/Admin/PostTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = '<a href="' .
esc_url(get_delete_post_link($post->ID, '', true))
esc_url($deleteUrl)
. '" class="submitdelete notification-delete-post">'
. esc_html__('Remove', 'notification') . '</a>';

Expand Down
8 changes: 3 additions & 5 deletions src/Store/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, \BracketSpace\Notification\Interfaces\Sendable> 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<Interfaces\Sendable> */
use Storage;
}
5 changes: 1 addition & 4 deletions src/Store/GlobalMergeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@

/**
* Global Merge Tag Store
* //phpcs:ignore Generic.Files.LineLength.TooLong
* @method static array<string, \BracketSpace\Notification\Interfaces\Taggable> 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<Interfaces\Taggable> */
use Storage;
}
1 change: 1 addition & 0 deletions src/Store/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class Notification implements Storable
{
use Casegnostic;
/** @use Storage<mixed> */
use Storage;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Store/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*/
class Resolver implements Interfaces\Storable
{
/** @use Storage<Interfaces\Resolvable> */
use Storage;

/**
* Gets all Resolvers sorted by priority.
*
* @return array<string, \BracketSpace\Notification\Interfaces\Resolvable>
* @return array<Interfaces\Resolvable>
* @since 8.0.0
*/
public static function sorted(): array
Expand Down
6 changes: 2 additions & 4 deletions src/Store/Trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@

/**
* Trigger Store
*
* @method static array<string, \BracketSpace\Notification\Interfaces\Triggerable> 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<Interfaces\Triggerable> */
use Storage;

/**
* Gets all Triggers grouped.
*
* @return array<string, array<string, \BracketSpace\Notification\Interfaces\Triggerable>>
* @return array<string, array<string, Interfaces\Triggerable>>
* @since 8.0.0
*/
public static function grouped(): array
Expand Down
16 changes: 9 additions & 7 deletions src/Traits/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@

/**
* Storage trait
*
* @template TItem
*/
trait Storage
{
/**
* Stored items
*
* @var array<mixed>
* @var array<TItem>
*/
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
*/
Expand All @@ -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
*/
Expand All @@ -64,7 +66,7 @@ public static function insert($index, $item)
/**
* Gets all items
*
* @return array<mixed>
* @return array<TItem>
* @since 8.0.0
*/
public static function all(): array
Expand All @@ -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)
Expand All @@ -101,7 +103,7 @@ public static function get($index)
)
);

return;
return null;
}

return static::$items[$index];
Expand Down

0 comments on commit e232f6a

Please sign in to comment.