Skip to content

Commit 35139ae

Browse files
committed
Finally fix return types
1 parent 88fffb5 commit 35139ae

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: src/Assets/Asset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public function add_to_group_path( string $group_path_name ) {
345345
* @param string|null $version The asset version.
346346
* @param string|null $root_path The path to the root of the plugin.
347347
*
348-
* @return static
348+
* @return self
349349
*/
350350
public static function add( string $slug, string $file, string $version = null, $root_path = null ) {
351351
return Assets::init()->add( new self( $slug, $file, $version, $root_path ) );

Diff for: src/Assets/VendorAsset.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use InvalidArgumentException;
88
use LogicException;
9+
use RuntimeException;
910

1011
class VendorAsset extends Asset {
1112

@@ -51,7 +52,7 @@ public function __construct( string $slug, string $url, string $type = 'js' ) {
5152
* @param ?string $type The asset type.
5253
* @param ?string $version The asset version.
5354
*
54-
* @return static
55+
* @return self
5556
*/
5657
public static function add( string $slug, string $url, ?string $type = null, $version = null ) {
5758
$instance = new self( $slug, $url, $type ?? 'js' );
@@ -60,7 +61,12 @@ public static function add( string $slug, string $url, ?string $type = null, $ve
6061
$instance->set_version( (string) $version );
6162
}
6263

63-
return Assets::init()->add( $instance );
64+
$registered = Assets::init()->add( $instance );
65+
if ( ! $registered instanceof self ) {
66+
throw new RuntimeException( 'The asset was already registered as a different type.' );
67+
}
68+
69+
return $registered;
6470
}
6571

6672
/**

0 commit comments

Comments
 (0)