37
37
38
38
define ( 'BUILD ' , isset ( $ runtime_config ['build ' ] ) ? $ runtime_config ['build ' ] : '' );
39
39
40
- $ current_version = trim ( file_get_contents ( WP_CLI_ROOT . '/VERSION ' ) );
40
+ $ current_version = trim ( ( string ) file_get_contents ( WP_CLI_ROOT . '/VERSION ' ) );
41
41
42
42
if ( isset ( $ runtime_config ['version ' ] ) ) {
43
43
$ new_version = $ runtime_config ['version ' ];
@@ -101,9 +101,9 @@ static function ( $v ) {
101
101
$ strips
102
102
);
103
103
}
104
- $ phar [ $ key ] = preg_replace ( $ strip_res , '' , file_get_contents ( $ path ) );
104
+ $ phar [ $ key ] = preg_replace ( $ strip_res , '' , ( string ) file_get_contents ( $ path ) );
105
105
} else {
106
- $ phar [ $ key ] = file_get_contents ( $ path );
106
+ $ phar [ $ key ] = ( string ) file_get_contents ( $ path );
107
107
}
108
108
}
109
109
@@ -125,6 +125,9 @@ function get_composer_versions( $current_version ) {
125
125
return '' ;
126
126
}
127
127
128
+ /**
129
+ * @var null|array{packages: array{name?: string, version?: string, source?: array{reference?: string}, dist?: array{reference?: string}}} $composer_lock
130
+ */
128
131
$ composer_lock = json_decode ( $ composer_lock_file , true );
129
132
if ( ! $ composer_lock ) {
130
133
fwrite ( STDERR , sprintf ( "Warning: Could not decode '%s'. " . PHP_EOL , $ composer_lock_path ) );
@@ -286,8 +289,11 @@ function get_composer_versions( $current_version ) {
286
289
add_file ( $ phar , $ file );
287
290
}
288
291
// Any PHP files in the project root
289
- foreach ( glob ( WP_CLI_BASE_PATH . '/*.php ' ) as $ file ) {
290
- add_file ( $ phar , $ file );
292
+ $ files = glob ( WP_CLI_BASE_PATH . '/*.php ' );
293
+ if ( $ files ) {
294
+ foreach ( $ files as $ file ) {
295
+ add_file ( $ phar , $ file );
296
+ }
291
297
}
292
298
}
293
299
}
0 commit comments