From 2a84410faf9d9e6ce92dcfdd2fe7ea40db5b5ca0 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 14 Apr 2025 15:19:35 -0500 Subject: [PATCH 01/14] Tweak docblocks --- src/Assets/Asset.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 72dba3f..5fcbe5f 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -78,28 +78,28 @@ class Asset { protected array $groups = []; /** - * Should the asset be loaded in the footer? + * Whether the asset be loaded in the footer. * * @var bool */ protected bool $in_footer = true; /** - * Should the asset be marked as async? + * Whether the asset be marked as async. * * @var bool */ protected bool $is_async = false; /** - * Should the asset be marked as deferred? + * Whether the asset be marked as deferred. * * @var bool */ protected bool $is_deferred = false; /** - * Is the asset enqueued? + * Whether the asset has been enqueued. * * @var bool */ @@ -113,21 +113,21 @@ class Asset { protected bool $is_module = false; /** - * Is the asset printed? + * Whether the asset has been printed. * * @var bool */ protected bool $is_printed = false; /** - * Is the asset registered? + * Whether the asset has been registered. * * @var bool */ protected bool $is_registered = false; /** - * Is the asset a vendor asset? + * Whether this is a vendor asset. * * @var bool */ @@ -534,7 +534,7 @@ protected function build_asset_url(): string { $url = $plugin_base_url . $resource_path . $resource; /** - * Filters the asset URL + * Filters the asset URL. * * @param string $url Asset URL. * @param string $slug Asset slug. From aaa344f30c4c41c90412bbee1fa553786a2d97f1 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 14 Apr 2025 15:19:56 -0500 Subject: [PATCH 02/14] Remove unnecessary leading slash for InvalidArgumentException --- src/Assets/Asset.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 5fcbe5f..1ef014a 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -681,11 +681,11 @@ public function clone_to( string $clone_type, ...$dependencies ) { $source_type = $this->get_type(); if ( $clone_type === $source_type ) { - throw new \InvalidArgumentException( 'The clone type must be different from the source type.' ); + throw new InvalidArgumentException( 'The clone type must be different from the source type.' ); } if ( ! in_array( $clone_type, [ 'css', 'js' ], true ) ) { - throw new \InvalidArgumentException( 'The clone type must be either "css" or "js".' ); + throw new InvalidArgumentException( 'The clone type must be either "css" or "js".' ); } $slug = $this->slug; From 5c2735f12b2827571b4d39e1fb933890e438b0c4 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 14 Apr 2025 17:08:38 -0500 Subject: [PATCH 03/14] Create VendorAsset class --- src/Assets/VendorAsset.php | 129 +++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 src/Assets/VendorAsset.php diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php new file mode 100644 index 0000000..735f4bc --- /dev/null +++ b/src/Assets/VendorAsset.php @@ -0,0 +1,129 @@ +url = $filtered; + $this->slug = sanitize_key( $slug ); + $this->type = strtolower( $type ); + } + + /** + * Set the asset version. + * + * @param string $version The asset version. + * + * @return $this + */ + public function set_version( string $version ): self { + $this->version = $version; + return $this; + } + + /** + * Get the asset version. + * + * @since 1.0.0 + * + * @return string The asset version. + */ + public function get_version(): string { + return $this->version ?? ''; + } + + /** + * Get the asset url. + * + * If the version has been provided, then it will be used to format the URL. + * + * @since 1.0.0 + * + * @param bool $use_min_if_available (Unused) Use the minified version of the asset if available. + * + * @return string + * @throws LogicException If the URL has a placeholder but no version is provided. + */ + public function get_url( bool $use_min_if_available = true ): string { + $has_version = null !== $this->version; + if ( ! $has_version && $this->url_has_placeholder( $this->url ) ) { + throw new LogicException( 'A URL with a placeholder must have a version provided.' ); + } + + $url = $has_version + ? $this->get_formatted_url() + : $this->url; + + $hook_prefix = Config::get_hook_prefix(); + + /** + * Filters the asset URL. + * + * @param string $url Asset URL. + * @param string $slug Asset slug. + * @param Asset $asset The Asset object. + */ + return (string) apply_filters( "stellarwp/assets/{$hook_prefix}/resource_url", $url, $this->slug, $this ); + } + + /** + * Get the minified version of the URL. + * + * @return string + */ + public function get_min_url(): string { + return $this->get_url(); + } + + /** + * Get the formatted version of the URL. + * + * This will replace the version placeholder in the URL with the actual version. If there + * is no placeholder, it will append the version as a query string. + * + * @return string + */ + protected function get_formatted_url() { + return $this->url_has_placeholder( $this->url ) + ? sprintf( $this->url, $this->version ) + : add_query_arg( 'ver', $this->version, $this->url ); + } + + /** + * Determine if the URL has a placeholder for the version. + * + * @param string $url The URL to check. + * + * @return bool True if the URL has a placeholder, false otherwise. + */ + protected function url_has_placeholder( string $url ): bool { + return false !== strpos( $url, '%s' ); + } +} From aec89464ee936d9221f31c1d1c0c02ee579d80aa Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 14 Apr 2025 17:27:42 -0500 Subject: [PATCH 04/14] Add test suite for VendorAsset --- tests/wpunit/VendorAssetTest.php | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/wpunit/VendorAssetTest.php diff --git a/tests/wpunit/VendorAssetTest.php b/tests/wpunit/VendorAssetTest.php new file mode 100644 index 0000000..c49e736 --- /dev/null +++ b/tests/wpunit/VendorAssetTest.php @@ -0,0 +1,67 @@ +assertEquals( 'test-script', $asset->get_slug() ); + $this->assertEquals( 'https://example.com/fake.js', $asset->get_url() ); + $this->assertEquals( 'js', $asset->get_type() ); + } + + public function test_invalid_url_throws_exception(): void { + $this->expectException( InvalidArgumentException::class ); + + new VendorAsset( 'test-script', 'invalid-url' ); + } + + public function test_can_set_version(): void { + $asset = new VendorAsset( 'test-script', 'https://example.com/fake.js' ); + $asset->set_version( '1.0.0' ); + + $this->assertEquals( '1.0.0', $asset->get_version() ); + $this->assertEquals( 'https://example.com/fake.js?ver=1.0.0', $asset->get_url() ); + } + + public function test_can_set_version_with_url_placeholder(): void { + $asset = new VendorAsset( 'test-script', 'https://example.com/path/to/version/%s/fake.js' ); + $asset->set_version( '1.2.3' ); + $this->assertEquals( '1.2.3', $asset->get_version() ); + $this->assertEquals( 'https://example.com/path/to/version/1.2.3/fake.js', $asset->get_url() ); + } + + public function test_placeholder_without_version_throws_error(): void { + $this->expectException( LogicException::class ); + $this->expectExceptionMessage( 'A URL with a placeholder must have a version provided.' ); + + $asset = new VendorAsset( 'test-script', 'https://example.com/path/to/version/%s/fake.js' ); + $asset->get_url(); + } + + public function test_version_with_query_string_has_ver_appended_correctly(): void { + $asset = new VendorAsset( 'test-script', 'https://example.com/path/to/version?query=string' ); + $asset->set_version( '1.2.3' ); + + $this->assertEquals( '1.2.3', $asset->get_version() ); + $this->assertEquals( 'https://example.com/path/to/version?query=string&ver=1.2.3', $asset->get_url() ); + } +} From 113fc17a8a04d85bd3ad7fe00ed3d1408590d67c Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 14 Apr 2025 17:31:07 -0500 Subject: [PATCH 05/14] Add no-op and empty string placeholder methods These methods aren't applicable to this class --- src/Assets/VendorAsset.php | 109 ++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index 735f4bc..d605c17 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -66,12 +66,12 @@ public function get_version(): string { * * @since 1.0.0 * - * @param bool $use_min_if_available (Unused) Use the minified version of the asset if available. + * @param bool $_unused (Unused) Use the minified version of the asset if available. * * @return string * @throws LogicException If the URL has a placeholder but no version is provided. */ - public function get_url( bool $use_min_if_available = true ): string { + public function get_url( bool $_unused = true ): string { $has_version = null !== $this->version; if ( ! $has_version && $this->url_has_placeholder( $this->url ) ) { throw new LogicException( 'A URL with a placeholder must have a version provided.' ); @@ -126,4 +126,109 @@ protected function get_formatted_url() { protected function url_has_placeholder( string $url ): bool { return false !== strpos( $url, '%s' ); } + + // --------------------------------------------- + // NO-OP or UNUSED METHODS + // --------------------------------------------- + + /** + * Get the asset asset file path. + * + * @return string + */ + public function get_asset_file_path(): string { + return ''; + } + + /** + * Get the asset min path. + * + * @return string + */ + public function get_min_path(): string { + return ''; + } + + /** + * Get the asset min path. + * + * @return string + */ + public function get_path(): string { + return ''; + } + + /** + * Gets the root path for the resource. + * + * @return ?string + */ + public function get_root_path(): ?string { + return ''; + } + + /** + * Get the asset translation path. + * + * @return string + */ + public function get_translation_path(): string { + return ''; + } + + /** + * Get the asset's full path - considering if minified exists. + * + * @param bool $_unused + * + * @return string + */ + public function get_full_resource_path( bool $_unused = true ): string { + return $this->get_url( $_unused ); + } + + /** + * Set the asset file path for the asset. + * + * @param string $path The partial path to the asset. + * + * @return static + */ + public function set_asset_file( string $path ) { + return $this; + } + + /** + * Set the directory where asset should be retrieved. + * + * @param ?string $path The path to the minified file. + * @param ?bool $prefix Whether to prefix files automatically by type (e.g. js/ for JS). Defaults to true. + * + * @return $this + */ + public function set_path( ?string $path = null, $prefix = null ) { + return $this; + } + + /** + * Set the directory where min files should be retrieved. + * + * @param ?string $path The path to the minified file. + * + * @return $this + */ + public function set_min_path( ?string $path = null ) { + return $this; + } + + /** + * Set whether or not to use an .asset.php file. + * + * @param boolean $_unused Whether to use an .asset.php file. + * + * @return self + */ + public function use_asset_file( bool $_unused = true ): self { + return $this; + } } From 8b32008c0252c2fb06b211dc15a35a9d538ce847 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 14 Apr 2025 20:07:55 -0500 Subject: [PATCH 06/14] Add $use_asset_file and get_file() --- src/Assets/VendorAsset.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index d605c17..83db8b8 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -16,6 +16,13 @@ class VendorAsset extends Asset { */ protected bool $is_vendor = true; + /** + * Whether to attempt to load an .asset.php file. + * + * @var bool + */ + protected bool $use_asset_file = false; + /** * VendorAsset constructor. * @@ -140,6 +147,15 @@ public function get_asset_file_path(): string { return ''; } + /** + * Get the asset file. + * + * @return string + */ + public function get_file(): string { + return ''; + } + /** * Get the asset min path. * From 959408be47ccb1a07b397b58c2d237b871d22222 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 09:39:25 -0500 Subject: [PATCH 07/14] Add missing word to docblocks --- src/Assets/Asset.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 1ef014a..215ae7d 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -78,21 +78,21 @@ class Asset { protected array $groups = []; /** - * Whether the asset be loaded in the footer. + * Whether the asset should be loaded in the footer. * * @var bool */ protected bool $in_footer = true; /** - * Whether the asset be marked as async. + * Whether the asset should be marked as async. * * @var bool */ protected bool $is_async = false; /** - * Whether the asset be marked as deferred. + * Whether the asset should be marked as deferred. * * @var bool */ From b02993c18b664616317972930ea01a2a8c906214 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 10:02:03 -0500 Subject: [PATCH 08/14] Override add() method in VendorAsset --- src/Assets/VendorAsset.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index 83db8b8..148a6d7 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -43,6 +43,24 @@ public function __construct( string $slug, string $url, string $type = 'js' ) { $this->type = strtolower( $type ); } + /** + * Registers a vendor asset. + * + * @param string $slug The asset slug. + * @param string $url The asset file path. + * @param ?string $type The asset type. + * @param ?string $version The asset version. + */ + public static function add( string $slug, string $url, ?string $type = null, ?string $version = null ) { + $instance = new self( $slug, $url, $type ?? 'js' ); + + if ( null !== $version ) { + $instance->set_version( $version ); + } + + return Assets::init()->add( $instance ); + } + /** * Set the asset version. * From 8374ccbd7071782fb80319c1929ccb7dd9770b24 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 10:06:03 -0500 Subject: [PATCH 09/14] Match parameter type to parent and cast to string if not null --- src/Assets/VendorAsset.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index 148a6d7..9972d13 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -51,11 +51,11 @@ public function __construct( string $slug, string $url, string $type = 'js' ) { * @param ?string $type The asset type. * @param ?string $version The asset version. */ - public static function add( string $slug, string $url, ?string $type = null, ?string $version = null ) { + public static function add( string $slug, string $url, ?string $type = null, $version = null ) { $instance = new self( $slug, $url, $type ?? 'js' ); if ( null !== $version ) { - $instance->set_version( $version ); + $instance->set_version( (string) $version ); } return Assets::init()->add( $instance ); From 56f4ec4a34da5d2ed5416980b4fcab110b03818c Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 10:13:31 -0500 Subject: [PATCH 10/14] Fix the comments to match what is actually happening --- src/Assets/Assets.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Assets/Assets.php b/src/Assets/Assets.php index f389b04..07c029f 100755 --- a/src/Assets/Assets.php +++ b/src/Assets/Assets.php @@ -114,17 +114,16 @@ public static function asset( string $slug, string $file, string $version = null * */ public function add( Asset $asset ) { - // Prevent weird stuff here. + // Check if the slug is registered, and if so return the previously-registerd Asset. $slug = $asset->get_slug(); if ( $this->exists( $slug ) ) { return $this->get( $slug ); } - // Set the Asset on the array of notices. + // Add the asset to the array of assets. $this->assets[ $slug ] = $asset; - // Return the Slug because it might be modified. return $asset; } From cc59804b6bd314368ab9dd9420ea1d1cc1126dc5 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 10:13:46 -0500 Subject: [PATCH 11/14] Update the method return values --- src/Assets/Asset.php | 2 ++ src/Assets/Assets.php | 4 ++-- src/Assets/VendorAsset.php | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 215ae7d..949c210 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -344,6 +344,8 @@ public function add_to_group_path( string $group_path_name ) { * @param string $file The asset file path. * @param string|null $version The asset version. * @param string|null $root_path The path to the root of the plugin. + * + * @return self */ public static function add( string $slug, string $file, string $version = null, $root_path = null ) { return Assets::init()->add( new self( $slug, $file, $version, $root_path ) ); diff --git a/src/Assets/Assets.php b/src/Assets/Assets.php index 07c029f..ca3188c 100755 --- a/src/Assets/Assets.php +++ b/src/Assets/Assets.php @@ -109,7 +109,7 @@ public static function asset( string $slug, string $file, string $version = null * * @param Asset $asset Register an asset. * - * @return Asset|false The registered object or false on error. + * @return Asset|VendorAsset The registered object or false on error. * @since 1.0.0 * */ @@ -192,7 +192,7 @@ public function filter_print_before_after_script( $tag, $handle ): string { * @param string|array $slug Slug of the Asset. * @param boolean $sort If we should do any sorting before returning. * - * @return array|Asset Array of asset objects, single asset object, or null if looking for a single asset but + * @return array|Asset|VendorAsset Array of asset objects, single asset object, or null if looking for a single asset but * it was not in the array of objects. * @since 1.0.0 * diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index 9972d13..296da72 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -50,6 +50,8 @@ public function __construct( string $slug, string $url, string $type = 'js' ) { * @param string $url The asset file path. * @param ?string $type The asset type. * @param ?string $version The asset version. + * + * @return self */ public static function add( string $slug, string $url, ?string $type = null, $version = null ) { $instance = new self( $slug, $url, $type ?? 'js' ); From 88fffb5d9e22b01efc706c6c14e290289c129efe Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 10:15:44 -0500 Subject: [PATCH 12/14] Type-hint static instead of self --- src/Assets/Asset.php | 2 +- src/Assets/VendorAsset.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 949c210..da7d3b8 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -345,7 +345,7 @@ public function add_to_group_path( string $group_path_name ) { * @param string|null $version The asset version. * @param string|null $root_path The path to the root of the plugin. * - * @return self + * @return static */ public static function add( string $slug, string $file, string $version = null, $root_path = null ) { return Assets::init()->add( new self( $slug, $file, $version, $root_path ) ); diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index 296da72..baa8873 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -51,7 +51,7 @@ public function __construct( string $slug, string $url, string $type = 'js' ) { * @param ?string $type The asset type. * @param ?string $version The asset version. * - * @return self + * @return static */ public static function add( string $slug, string $url, ?string $type = null, $version = null ) { $instance = new self( $slug, $url, $type ?? 'js' ); From 35139ae0f9810bff1403b47601f4dffeada7f2c8 Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Tue, 15 Apr 2025 10:35:54 -0500 Subject: [PATCH 13/14] Finally fix return types --- src/Assets/Asset.php | 2 +- src/Assets/VendorAsset.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index da7d3b8..949c210 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -345,7 +345,7 @@ public function add_to_group_path( string $group_path_name ) { * @param string|null $version The asset version. * @param string|null $root_path The path to the root of the plugin. * - * @return static + * @return self */ public static function add( string $slug, string $file, string $version = null, $root_path = null ) { return Assets::init()->add( new self( $slug, $file, $version, $root_path ) ); diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index baa8873..e042421 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use LogicException; +use RuntimeException; class VendorAsset extends Asset { @@ -51,7 +52,7 @@ public function __construct( string $slug, string $url, string $type = 'js' ) { * @param ?string $type The asset type. * @param ?string $version The asset version. * - * @return static + * @return self */ public static function add( string $slug, string $url, ?string $type = null, $version = null ) { $instance = new self( $slug, $url, $type ?? 'js' ); @@ -60,7 +61,12 @@ public static function add( string $slug, string $url, ?string $type = null, $ve $instance->set_version( (string) $version ); } - return Assets::init()->add( $instance ); + $registered = Assets::init()->add( $instance ); + if ( ! $registered instanceof self ) { + throw new RuntimeException( 'The asset was already registered as a different type.' ); + } + + return $registered; } /** From 5e9f06360f258566880a51943e098825272c326e Mon Sep 17 00:00:00 2001 From: Jeremy Pry Date: Mon, 21 Apr 2025 12:21:45 -0500 Subject: [PATCH 14/14] Comment updates from PR feedback --- src/Assets/Assets.php | 4 ++-- src/Assets/VendorAsset.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Assets/Assets.php b/src/Assets/Assets.php index ca3188c..dc7d51e 100755 --- a/src/Assets/Assets.php +++ b/src/Assets/Assets.php @@ -109,12 +109,12 @@ public static function asset( string $slug, string $file, string $version = null * * @param Asset $asset Register an asset. * - * @return Asset|VendorAsset The registered object or false on error. + * @return Asset|VendorAsset The registered object. * @since 1.0.0 * */ public function add( Asset $asset ) { - // Check if the slug is registered, and if so return the previously-registerd Asset. + // Check if the slug is registered, and if so return the previously-registered Asset. $slug = $asset->get_slug(); if ( $this->exists( $slug ) ) { diff --git a/src/Assets/VendorAsset.php b/src/Assets/VendorAsset.php index e042421..0df9b49 100644 --- a/src/Assets/VendorAsset.php +++ b/src/Assets/VendorAsset.php @@ -74,7 +74,7 @@ public static function add( string $slug, string $url, ?string $type = null, $ve * * @param string $version The asset version. * - * @return $this + * @return static */ public function set_version( string $version ): self { $this->version = $version; @@ -138,8 +138,8 @@ public function get_min_url(): string { /** * Get the formatted version of the URL. * - * This will replace the version placeholder in the URL with the actual version. If there - * is no placeholder, it will append the version as a query string. + * This will replace the version placeholder in the URL with the actual version. + * If there is no placeholder, it will append the version as a query string. * * @return string */ @@ -246,7 +246,7 @@ public function set_asset_file( string $path ) { * @param ?string $path The path to the minified file. * @param ?bool $prefix Whether to prefix files automatically by type (e.g. js/ for JS). Defaults to true. * - * @return $this + * @return static */ public function set_path( ?string $path = null, $prefix = null ) { return $this; @@ -257,7 +257,7 @@ public function set_path( ?string $path = null, $prefix = null ) { * * @param ?string $path The path to the minified file. * - * @return $this + * @return static */ public function set_min_path( ?string $path = null ) { return $this; @@ -268,7 +268,7 @@ public function set_min_path( ?string $path = null ) { * * @param boolean $_unused Whether to use an .asset.php file. * - * @return self + * @return static */ public function use_asset_file( bool $_unused = true ): self { return $this;