Skip to content

Commit 11363dc

Browse files
committed
Fix phpstan issues in create-entry
1 parent 071cc0a commit 11363dc

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

packages/create-entry/templates/entry/index.php.mustache

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
/**
1717
* Register the {{slug}} entry point assets so that they can be enqueued.
1818
*/
19-
function {{nameSpaceSnakeCase}}_register_{{slugUnderscore}}_scripts() {
20-
// Automatically load dependencies and version.
19+
function {{nameSpaceSnakeCase}}_register_{{slugUnderscore}}_scripts(): void {
20+
/**
21+
* Asset file generated by wp-scripts.
22+
*
23+
* @var array{dependencies: string[], version: string}|false $asset_file
24+
*/
2125
$asset_file = include __DIR__ . '/index.asset.php';
2226

27+
if ( ! $asset_file ) {
28+
return;
29+
}
30+
2331
// Register the {{slug}} script.
2432
wp_register_script(
2533
'{{prefixNameSpace}}-{{slug}}-js',
@@ -45,7 +53,7 @@ add_action( 'init', '{{nameSpaceSnakeCase}}_register_{{slugUnderscore}}_scripts'
4553
/**
4654
* Enqueue scripts for the {{slug}} entry point.
4755
*/
48-
function {{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}}_scripts() {
56+
function {{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}}_scripts(): void {
4957
wp_enqueue_script( '{{prefixNameSpace}}-{{slug}}-js' );
5058
}
5159
add_action( '{{enqueueHook}}', '{{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}}_scripts' );
@@ -54,9 +62,9 @@ add_action( '{{enqueueHook}}', '{{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}
5462
/**
5563
* Enqueue styles for the {{slug}} entry point.
5664
*/
57-
function {{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}}_styles() {
65+
function {{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}}_styles(): void {
5866
wp_enqueue_style( '{{prefixNameSpace}}-{{slug}}-css' );
5967
}
6068
add_action( '{{enqueueStyleHook}}', '{{nameSpaceSnakeCase}}_enqueue_{{slugUnderscore}}_styles' );
6169
{{/hasStyles}}
62-
{{/hasEnqueue}}
70+
{{/hasEnqueue}}

0 commit comments

Comments
 (0)