From a5d604218162b28f57dadba6a11db6837eee3440 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:29:32 +0000 Subject: [PATCH 1/3] Update wp-cli/wp-cli-tests requirement from ^4.3.9 to ^5.0.0 Updates the requirements on [wp-cli/wp-cli-tests](https://github.com/wp-cli/wp-cli-tests) to permit the latest version. - [Release notes](https://github.com/wp-cli/wp-cli-tests/releases) - [Commits](https://github.com/wp-cli/wp-cli-tests/compare/v4.3.9...v5.0.0) --- updated-dependencies: - dependency-name: wp-cli/wp-cli-tests dependency-version: 5.0.0 dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 88f2f30..dab1334 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "wp-cli/wp-cli": "^2.12" }, "require-dev": { - "wp-cli/wp-cli-tests": "^4.3.9" + "wp-cli/wp-cli-tests": "^5.0.0" }, "config": { "process-timeout": 7200, From 8794d2bde16ad5a40e51251a3970419b0e46a95a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 4 Jul 2025 15:50:39 +0200 Subject: [PATCH 2/3] Update Composer config --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dab1334..da4eba6 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, - "johnpbloch/wordpress-core-installer": true + "johnpbloch/wordpress-core-installer": true, + "phpstan/extension-installer": true }, "lock": false }, @@ -34,12 +35,14 @@ "behat-rerun": "rerun-behat-tests", "lint": "run-linter-tests", "phpcs": "run-phpcs-tests", + "phpstan": "run-phpstan-tests", "phpcbf": "run-phpcbf-cleanup", "phpunit": "run-php-unit-tests", "prepare-tests": "install-package-tests", "test": [ "@lint", "@phpcs", + "@phpstan", "@phpunit", "@behat" ] From 8e8276e3cb390ca4f9a5dd944ef37d097987106d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 4 Jul 2025 15:50:47 +0200 Subject: [PATCH 3/3] PHPStan level 9 --- phpstan.neon.dist | 13 +++++++++++++ src/Find_Command.php | 24 ++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 phpstan.neon.dist diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..910c8e0 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,13 @@ +parameters: + level: 9 + paths: + - src + - find-command.php + scanDirectories: + - vendor/wp-cli/wp-cli/php + scanFiles: + - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php + treatPhpDocTypesAsCertain: false + ignoreErrors: + - identifier: missingType.parameter + - identifier: missingType.return diff --git a/src/Find_Command.php b/src/Find_Command.php index 4498397..f2a0fe5 100644 --- a/src/Find_Command.php +++ b/src/Find_Command.php @@ -8,7 +8,7 @@ class Find_Command { /** * Paths we can probably ignore recursion into. * - * @var array + * @var array */ private $ignored_paths = [ // System directories @@ -94,21 +94,21 @@ class Find_Command { /** * Start time for the script. * - * @var integer + * @var float */ - private $start_time = false; + private $start_time; /** * Resolved alias paths * - * @var array + * @var array */ private $resolved_aliases = []; /** * Found WordPress installations. * - * @var array + * @var array> */ private $found_wp = []; @@ -190,7 +190,7 @@ class Find_Command { */ public function __invoke( $args, $assoc_args ) { list( $path ) = $args; - $this->base_path = realpath( $path ); + $this->base_path = (string) realpath( $path ); if ( ! $this->base_path ) { WP_CLI::error( 'Invalid path specified.' ); } @@ -235,7 +235,7 @@ private function recurse_directory( $path ) { // Don't recurse directories that probably don't have a WordPress installation. if ( ! $this->skip_ignored_paths ) { // Assume base path doesn't need comparison - $compared_path = preg_replace( '#^' . preg_quote( $this->base_path, '#' ) . '#', '', $path ); + $compared_path = (string) preg_replace( '#^' . preg_quote( $this->base_path, '#' ) . '#', '', $path ); // Ignore all hidden system directories $bits = explode( '/', trim( $compared_path, '/' ) ); $current_dir = array_pop( $bits ); @@ -276,7 +276,7 @@ private function recurse_directory( $path ) { try { $transformer = new WPConfigTransformer( $config_path ); foreach ( [ 'db_host', 'db_name', 'db_user' ] as $constant ) { - $value = $transformer->get_value( 'constant', strtoupper( $constant ) ); + $value = (string) $transformer->get_value( 'constant', strtoupper( $constant ) ); // Clean up strings. $first = substr( $value, 0, 1 ); $last = substr( $value, -1 ); @@ -309,6 +309,10 @@ private function recurse_directory( $path ) { return; } $this->log( "Recursing into '{$path}'" ); + + /** + * @var SplFileInfo $file_info + */ foreach ( $iterator as $file_info ) { if ( $file_info->isDir() ) { ++$this->current_depth; @@ -322,7 +326,7 @@ private function recurse_directory( $path ) { * Get the WordPress version for the installation, without executing the file. */ private static function get_wp_version( $path ) { - $contents = file_get_contents( $path ); + $contents = (string) file_get_contents( $path ); preg_match( '#\$wp_version\s?=\s?[\'"]([^\'"]+)[\'"]#', $contents, $matches ); return ! empty( $matches[1] ) ? $matches[1] : ''; } @@ -359,7 +363,7 @@ private function log( $message ) { /** * Format a log timestamp into something human-readable. * - * @param integer $s Log time in seconds + * @param int|float $s Log time in seconds * @return string */ private static function format_log_timestamp( $s ) {