diff --git a/composer.json b/composer.json index 9a9eefab..783271d1 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,15 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^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 }, @@ -54,12 +55,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..64d88315 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,13 @@ +parameters: + level: 9 + paths: + - src + - super-admin-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/Super_Admin_Command.php b/src/Super_Admin_Command.php index 55ecada5..b05dce35 100644 --- a/src/Super_Admin_Command.php +++ b/src/Super_Admin_Command.php @@ -24,10 +24,16 @@ */ class Super_Admin_Command extends WP_CLI_Command { + /** + * @var array + */ private $fields = [ 'user_login', ]; + /** + * @var \WP_CLI\Fetchers\User + */ private $fetcher; public function __construct() { @@ -84,6 +90,9 @@ public function list_subcommand( $_, $assoc_args ) { $user_ids = []; foreach ( $super_admins as $user_login ) { + /** + * @var \WP_User $user_obj + */ $user_obj = get_user_by( 'login', $user_login ); $user_ids[] = $user_obj->ID; }