diff --git a/composer.json b/composer.json index 7d135bef..f89420d5 100644 --- a/composer.json +++ b/composer.json @@ -15,14 +15,15 @@ "wp-cli/wp-cli": "^2.12" }, "require-dev": { - "wp-cli/wp-cli-tests": "^4" + "wp-cli/wp-cli-tests": "^5" }, "config": { "process-timeout": 7200, "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 }, @@ -51,12 +52,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" ] diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..d2fafd10 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,13 @@ +parameters: + level: 9 + paths: + - src + - eval-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/EvalFile_Command.php b/src/EvalFile_Command.php index 5d2d4b2d..7542f497 100644 --- a/src/EvalFile_Command.php +++ b/src/EvalFile_Command.php @@ -72,7 +72,7 @@ private static function execute_eval( $file, $args, $use_include ) { } elseif ( $use_include ) { include $file; } else { - $file_contents = file_get_contents( $file ); + $file_contents = (string) file_get_contents( $file ); // Adjust for __FILE__ and __DIR__ magic constants. $file_contents = Utils\replace_path_consts( $file_contents, $file );