Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ PHAR_BUILD_VERSION
phpunit.xml
phpcs.xml
.phpcs.xml
/build
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"test": [
"@lint",
"@phpcs",
"@phpstan",
"@phpunit",
"@behat"
]
Expand Down
18 changes: 18 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
parameters:
level: 9
paths:
- php
- utils
scanDirectories:
- vendor/wp-cli/wp-cli
scanFiles:
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
- php/boot-phar.php
treatPhpDocTypesAsCertain: false
dynamicConstantNames:
- WP_DEBUG
- WP_DEBUG_LOG
- WP_DEBUG_DISPLAY
ignoreErrors:
- identifier: missingType.parameter
- identifier: missingType.return
2 changes: 1 addition & 1 deletion utils/get-package-require-from-composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exit( 1 );
}

$contents = file_get_contents( $file );
$contents = (string) file_get_contents( $file );
$composer = json_decode( $contents );

if ( empty( $composer ) || ! is_object( $composer ) ) {
Expand Down
16 changes: 11 additions & 5 deletions utils/make-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

define( 'BUILD', isset( $runtime_config['build'] ) ? $runtime_config['build'] : '' );

$current_version = trim( file_get_contents( WP_CLI_ROOT . '/VERSION' ) );
$current_version = trim( (string) file_get_contents( WP_CLI_ROOT . '/VERSION' ) );

if ( isset( $runtime_config['version'] ) ) {
$new_version = $runtime_config['version'];
Expand Down Expand Up @@ -101,9 +101,9 @@ static function ( $v ) {
$strips
);
}
$phar[ $key ] = preg_replace( $strip_res, '', file_get_contents( $path ) );
$phar[ $key ] = preg_replace( $strip_res, '', (string) file_get_contents( $path ) );
} else {
$phar[ $key ] = file_get_contents( $path );
$phar[ $key ] = (string) file_get_contents( $path );
}
}

Expand All @@ -125,6 +125,9 @@ function get_composer_versions( $current_version ) {
return '';
}

/**
* @var null|array{packages: array{name?: string, version?: string, source?: array{reference?: string}, dist?: array{reference?: string}}} $composer_lock
*/
$composer_lock = json_decode( $composer_lock_file, true );
if ( ! $composer_lock ) {
fwrite( STDERR, sprintf( "Warning: Could not decode '%s'." . PHP_EOL, $composer_lock_path ) );
Expand Down Expand Up @@ -286,8 +289,11 @@ function get_composer_versions( $current_version ) {
add_file( $phar, $file );
}
// Any PHP files in the project root
foreach ( glob( WP_CLI_BASE_PATH . '/*.php' ) as $file ) {
add_file( $phar, $file );
$files = glob( WP_CLI_BASE_PATH . '/*.php' );
if ( $files ) {
foreach ( $files as $file ) {
add_file( $phar, $file );
}
}
}
}
Expand Down