From 2c1a2c58027126b81568cee5dff5655ded91a528 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 17 Dec 2024 19:05:25 +0200 Subject: [PATCH] Fix static analysis --- src/Assets/Asset.php | 7 +++++++ src/Assets/Assets.php | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 48a74f4..ea3face 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -5,6 +5,13 @@ use InvalidArgumentException; use RuntimeException; +/** + * @method self print_assets() + * @method self enqueue_asset() + * @method self register_asset( string $url, array $dependencies = [], string $version = null, mixed $in_footer_or_media ) + * @method self dequeue_asset() + * @method self deregister_asset() + */ class Asset { /** * @var array The asset action. diff --git a/src/Assets/Assets.php b/src/Assets/Assets.php index 0cdd42f..46c81e3 100755 --- a/src/Assets/Assets.php +++ b/src/Assets/Assets.php @@ -726,7 +726,13 @@ public function remove( $slug ) { return false; } - $this->get( $slug )->dequeue_asset()->deregister_asset(); + $asset = $this->get( $slug ); + + if ( ! $asset instanceof Asset ) { + return true; + } + + $asset->dequeue_asset()->deregister_asset(); unset( $this->assets[ $slug ] );