mirror of
https://ghproxy.net/https://github.com/wp-cli/wp-cli-bundle.git
synced 2025-08-18 05:51:10 +08:00
PHPStan level 9
This commit is contained in:
parent
a0ea11e9be
commit
ccebd37467
5 changed files with 32 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,3 +11,4 @@ PHAR_BUILD_VERSION
|
|||
phpunit.xml
|
||||
phpcs.xml
|
||||
.phpcs.xml
|
||||
/build
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
"test": [
|
||||
"@lint",
|
||||
"@phpcs",
|
||||
"@phpstan",
|
||||
"@phpunit",
|
||||
"@behat"
|
||||
]
|
||||
|
|
18
phpstan.neon.dist
Normal file
18
phpstan.neon.dist
Normal file
|
@ -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
|
|
@ -6,7 +6,7 @@ if ( ! file_exists( $file ) ) {
|
|||
exit( 1 );
|
||||
}
|
||||
|
||||
$contents = file_get_contents( $file );
|
||||
$contents = (string) file_get_contents( $file );
|
||||
$composer = json_decode( $contents );
|
||||
|
||||
if ( empty( $composer ) || ! is_object( $composer ) ) {
|
||||
|
|
|
@ -37,7 +37,7 @@ define( 'BE_QUIET', isset( $runtime_config['quiet'] ) && $runtime_config['quiet'
|
|||
|
||||
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'];
|
||||
|
@ -101,9 +101,9 @@ function add_file( $phar, $path ) {
|
|||
$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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 ) );
|
||||
|
@ -286,8 +289,11 @@ if ( 'cli' !== BUILD ) {
|
|||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue