Implement CS checking based on the WP_CLI_CS ruleset#36
Implement CS checking based on the WP_CLI_CS ruleset#36schlessera merged 6 commits intowp-cli:masterfrom
WP_CLI_CS ruleset#36Conversation
| </property> | ||
| </properties> | ||
| </rule> | ||
| <!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. --> |
There was a problem hiding this comment.
Let's add a line break here for better readability.
| <!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. --> | |
| <!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. --> |
phpcs.xml.dist
Outdated
| <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound"> | ||
| <exclude-pattern>*/src/Super_Admin_Command\.php$</exclude-pattern> | ||
| </rule> | ||
| </ruleset> No newline at end of file |
There was a problem hiding this comment.
All texts files should end with a line break.
| </ruleset> | |
| </ruleset> | |
src/Super_Admin_Command.php
Outdated
|
|
||
| public function __construct() { | ||
| $this->fetcher = new \WP_CLI\Fetchers\User; | ||
| $this->fetcher = new \WP_CLI\Fetchers\User(); |
There was a problem hiding this comment.
While we're make CS changes, let's import classes like these so we can see the dependencies at the top of the file and have clean class names in the code.
As the pure class name here is not very telling without the preceding namespace (User), I'd add an alias to the import at the top:
use WP_CLI\Fetchers\User as UserFetcher;Then, the code becomes clear and nice here:
| $this->fetcher = new \WP_CLI\Fetchers\User(); | |
| $this->fetcher = new UserFetcher(); |
src/Super_Admin_Command.php
Outdated
| * @subcommand list | ||
| */ | ||
| public function _list( $_, $assoc_args ) { | ||
| public function list_( $_, $assoc_args ) { |
There was a problem hiding this comment.
I'd go for something more meaningful here, as ending in an underscore is still "weird" in terms of method name.
| public function list_( $_, $assoc_args ) { | |
| public function list_subcommand( $_, $assoc_args ) { |
| // Exclude numeric and email-like logins (login names can be email-like but ignore this given the circumstances). | ||
| return ! isset( $flipped_user_logins[ $v ] ) && ! is_numeric( $v ) && ! is_email( $v ); | ||
| } ) ) ); | ||
| $user_logins = array_merge( |
There was a problem hiding this comment.
For a future iteration, I'd like to suggest splitting these nested function calls to separate lines to improve readability.
$filtered_args = array_filter(
$args,
function ( $v ) use ( $flipped_user_logins ) {
// Exclude numeric and email-like logins (login names can be email-like but ignore this given the circumstances).
return ! isset( $flipped_user_logins[ $v ] ) && ! is_numeric( $v ) && ! is_email( $v );
}
);
$filtered_args = array_unique( $filtered_args );
$user_logins = array_merge( $user_logins, $filtered_args );Implement CS checking based on the `WP_CLI_CS` ruleset
Add a PHPCS ruleset using the new
WP_CLI_CSstandard.Fixes #34
Related wp-cli/wp-cli#5179