3737
3838define ( 'BUILD ' , isset ( $ runtime_config ['build ' ] ) ? $ runtime_config ['build ' ] : '' );
3939
40- $ current_version = trim ( file_get_contents ( WP_CLI_ROOT . '/VERSION ' ) );
40+ $ current_version = trim ( ( string ) file_get_contents ( WP_CLI_ROOT . '/VERSION ' ) );
4141
4242if ( isset ( $ runtime_config ['version ' ] ) ) {
4343 $ new_version = $ runtime_config ['version ' ];
@@ -101,9 +101,9 @@ static function ( $v ) {
101101 $ strips
102102 );
103103 }
104- $ phar [ $ key ] = preg_replace ( $ strip_res , '' , file_get_contents ( $ path ) );
104+ $ phar [ $ key ] = preg_replace ( $ strip_res , '' , ( string ) file_get_contents ( $ path ) );
105105 } else {
106- $ phar [ $ key ] = file_get_contents ( $ path );
106+ $ phar [ $ key ] = ( string ) file_get_contents ( $ path );
107107 }
108108}
109109
@@ -125,6 +125,9 @@ function get_composer_versions( $current_version ) {
125125 return '' ;
126126 }
127127
128+ /**
129+ * @var null|array{packages: array{name?: string, version?: string, source?: array{reference?: string}, dist?: array{reference?: string}}} $composer_lock
130+ */
128131 $ composer_lock = json_decode ( $ composer_lock_file , true );
129132 if ( ! $ composer_lock ) {
130133 fwrite ( STDERR , sprintf ( "Warning: Could not decode '%s'. " . PHP_EOL , $ composer_lock_path ) );
@@ -286,8 +289,11 @@ function get_composer_versions( $current_version ) {
286289 add_file ( $ phar , $ file );
287290 }
288291 // 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+ }
291297 }
292298 }
293299}
0 commit comments