diff --git a/composer.json b/composer.json index df06f7ca..587c2726 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,15 @@ }, "require-dev": { "wp-cli/extension-command": "^1.2 || ^2", - "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 }, @@ -59,12 +60,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/features/scaffold.feature b/features/scaffold.feature index e194ff31..57ee8f88 100644 --- a/features/scaffold.feature +++ b/features/scaffold.feature @@ -231,7 +231,7 @@ Feature: WordPress code scaffolding """ And the {PLUGIN_DIR}/hello-world/.phpcs.xml.dist file should contain: """ - + """ And the {PLUGIN_DIR}/hello-world/hello-world.php file should contain: """ diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..20dfba73 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,13 @@ +parameters: + level: 9 + paths: + - src + - scaffold-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/Scaffold_Command.php b/src/Scaffold_Command.php index d6d68545..e92a032e 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -875,7 +875,7 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) { $wp_versions_to_test = []; // Parse plugin readme.txt if ( file_exists( "{$target_dir}/readme.txt" ) ) { - $readme_content = file_get_contents( "{$target_dir}/readme.txt" ); + $readme_content = (string) file_get_contents( "{$target_dir}/readme.txt" ); preg_match( '/Requires at least\:(.*)\n/m', $readme_content, $matches ); if ( isset( $matches[1] ) && $matches[1] ) { @@ -1045,7 +1045,7 @@ protected function log_whether_files_written( $files_written, $skip_message, $su /** * Extracts dashicon name when provided or return null otherwise. * - * @param array $assoc_args + * @param array{dashicon?: string} $assoc_args * @return string|null */ private function extract_dashicon( $assoc_args ) { diff --git a/templates/.phpcs.xml.dist b/templates/.phpcs.xml.dist index df58068d..8bbc9b37 100644 --- a/templates/.phpcs.xml.dist +++ b/templates/.phpcs.xml.dist @@ -18,7 +18,7 @@ - +