Skip to content

Commit 97a49f8

Browse files
committed
fix(Svg): psalm issue
1 parent 2d10d9c commit 97a49f8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

inc/Services/Svg.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,17 @@ public function get_sprite_hash( string $sprite_name ): ?string {
124124
$json_file = get_theme_file_path( '/dist/sprite-hashes.json' );
125125

126126
if ( is_readable( $php_file ) ) {
127-
$sprite_hashes = require $php_file;
128-
$sprite_hashes = \is_array( $sprite_hashes ) ? $sprite_hashes : [];
127+
$sprite_hash = require $php_file;
128+
$sprite_hash = \is_array( $sprite_hashes ) ? $sprite_hashes : [];
129129
} elseif ( is_readable( $json_file ) ) {
130-
$json_content = file_get_contents( $json_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
130+
$sprite_hash = file_get_contents( $json_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
131131
try {
132-
$sprite_hashes = json_decode( $json_content, true, 512, JSON_THROW_ON_ERROR );
133-
$sprite_hashes = \is_array( $sprite_hashes ) ? $sprite_hashes : [];
132+
$sprite_hash = json_decode( $json_content, true, 512, JSON_THROW_ON_ERROR );
133+
$sprite_hash = \is_array( $sprite_hashes ) ? $sprite_hashes : [];
134134
} catch ( \JsonException $e ) {
135135
$sprite_hashes = [];
136+
137+
return null;
136138
}
137139
} else {
138140
$sprite_hashes = [];

0 commit comments

Comments
 (0)