Skip to content

Commit 18c83dd

Browse files
committed
Fix wrong return type on get_min_file
1 parent ed08ba9 commit 18c83dd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

inc/Services/Assets.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use BEA\Theme\Framework\Service;
66
use BEA\Theme\Framework\Service_Container;
77
use BEA\Theme\Framework\Tools\Assets as Assets_Tools;
8+
use function json_last_error;
9+
use const JSON_ERROR_NONE;
810

911
/**
1012
* Class Assets
@@ -113,22 +115,22 @@ public function stylesheet_uri( string $stylesheet_uri ): string {
113115
*
114116
* @param string $type
115117
*
116-
* @return bool|null
118+
* @return string
117119
*/
118-
public function get_min_file( string $type ): ?bool {
120+
public function get_min_file( string $type ): string {
119121
if ( empty( $type ) ) {
120-
return false;
122+
return '';
121123
}
122124

123125
if ( ! file_exists( \get_theme_file_path( '/dist/assets/assets.json' ) ) ) {
124-
return false;
126+
return '';
125127
}
126128

127129
$json = file_get_contents( \get_theme_file_path( '/dist/assets/assets.json' ) ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
128130
$assets = json_decode( $json, true );
129131

130-
if ( empty( $assets ) ) {
131-
return false;
132+
if ( empty( $assets ) || JSON_ERROR_NONE !== json_last_error() ) {
133+
return '';
132134
}
133135

134136
switch ( $type ) {
@@ -155,7 +157,7 @@ public function get_min_file( string $type ): ?bool {
155157
}
156158

157159
if ( empty( $file ) ) {
158-
return false;
160+
return '';
159161
}
160162

161163
return $file;

0 commit comments

Comments
 (0)