Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"phpunit/phpunit": "3.7.*",
"roave/security-advisories": "dev-master",
"wimg/php-compatibility": "^8.0",
"wp-coding-standards/wpcs": "^0.13.1"
"phpcompatibility/phpcompatibility-wp": "^1",
"wp-coding-standards/wpcs": "^1"
},
"suggest": {
"psy/psysh": "Enhanced `wp shell` functionality"
Expand Down
171 changes: 110 additions & 61 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion php/WP_CLI/Bootstrap/LoadRequiredCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function process( BootstrapState $state ) {

foreach ( $runner()->config['require'] as $path ) {
if ( ! file_exists( $path ) ) {
$context = '';
$context = '';
$required_files = $runner()->get_required_files();
foreach ( array( 'global', 'project', 'runtime' ) as $scope ) {
if ( in_array( $path, $required_files[ $scope ], true ) ) {
Expand Down
2 changes: 1 addition & 1 deletion php/WP_CLI/Completions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct( $line ) {
}

$is_alias = false;
$is_help = false;
$is_help = false;
if ( ! empty( $this->words[0] ) && preg_match( '/^@/', $this->words[0] ) ) {
array_shift( $this->words );
// `wp @al` is false, but `wp @all ` is true.
Expand Down
12 changes: 6 additions & 6 deletions php/WP_CLI/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public function __construct( $path ) {
$this->spec = include $path;

$defaults = array(
'runtime' => false,
'file' => false,
'runtime' => false,
'file' => false,
'synopsis' => '',
'default' => null,
'default' => null,
'multiple' => false,
);

Expand Down Expand Up @@ -118,7 +118,7 @@ public function get_aliases() {
*/
public function parse_args( $arguments ) {
list( $positional_args, $mixed_args, $global_assoc, $local_assoc ) = self::extract_assoc( $arguments );
list( $assoc_args, $runtime_config ) = $this->unmix_assoc_args( $mixed_args, $global_assoc, $local_assoc );
list( $assoc_args, $runtime_config ) = $this->unmix_assoc_args( $mixed_args, $global_assoc, $local_assoc );
return array( $positional_args, $assoc_args, $runtime_config );
}

Expand Down Expand Up @@ -224,14 +224,14 @@ public function merge_yml( $path, $current_alias = null ) {
foreach ( $yaml as $key => $value ) {
if ( preg_match( '#' . self::ALIAS_REGEX . '#', $key ) ) {
$this->aliases[ $key ] = array();
$is_alias = false;
$is_alias = false;
foreach ( self::$alias_spec as $i ) {
if ( isset( $value[ $i ] ) ) {
if ( 'path' === $i && ! isset( $value['ssh'] ) ) {
self::absolutize( $value[ $i ], $yml_file_dir );
}
$this->aliases[ $key ][ $i ] = $value[ $i ];
$is_alias = true;
$is_alias = true;
}
}
// If it's not an alias, it might be a group of aliases
Expand Down
2 changes: 1 addition & 1 deletion php/WP_CLI/Dispatcher/CommandAddition.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class CommandAddition {
* @param string $reason Reason as to why the addition was aborted.
*/
public function abort( $reason = '' ) {
$this->abort = true;
$this->abort = true;
$this->reason = (string) $reason;
}

Expand Down
18 changes: 9 additions & 9 deletions php/WP_CLI/Dispatcher/CommandFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public static function create( $name, $callable, $parent ) {
if ( ( is_object( $callable ) && ( $callable instanceof \Closure ) )
|| ( is_string( $callable ) && function_exists( $callable ) ) ) {
$reflection = new \ReflectionFunction( $callable );
$command = self::create_subcommand( $parent, $name, $callable, $reflection );
$command = self::create_subcommand( $parent, $name, $callable, $reflection );
} elseif ( is_array( $callable ) && is_callable( $callable ) ) {
$reflection = new \ReflectionClass( $callable[0] );
$command = self::create_subcommand(
$command = self::create_subcommand(
$parent, $name, array( $callable[0], $callable[1] ),
$reflection->getMethod( $callable[1] )
);
Expand All @@ -36,7 +36,7 @@ public static function create( $name, $callable, $parent ) {
if ( $reflection->isSubclassOf( '\WP_CLI\Dispatcher\CommandNamespace' ) ) {
$command = self::create_namespace( $parent, $name, $callable );
} elseif ( $reflection->hasMethod( '__invoke' ) ) {
$class = is_object( $callable ) ? $callable : $reflection->name;
$class = is_object( $callable ) ? $callable : $reflection->name;
$command = self::create_subcommand(
$parent, $name, array( $class, '__invoke' ),
$reflection->getMethod( '__invoke' )
Expand Down Expand Up @@ -68,7 +68,7 @@ public static function clear_file_contents_cache() {
*/
private static function create_subcommand( $parent, $name, $callable, $reflection ) {
$doc_comment = self::get_doc_comment( $reflection );
$docparser = new \WP_CLI\DocParser( $doc_comment );
$docparser = new \WP_CLI\DocParser( $doc_comment );

if ( is_array( $callable ) ) {
if ( ! $name ) {
Expand Down Expand Up @@ -103,7 +103,7 @@ private static function create_subcommand( $parent, $name, $callable, $reflectio
* @param mixed $callable
*/
private static function create_composite_command( $parent, $name, $callable ) {
$reflection = new \ReflectionClass( $callable );
$reflection = new \ReflectionClass( $callable );
$doc_comment = self::get_doc_comment( $reflection );
if ( ! $doc_comment ) {
\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.", 'commandfactory' );
Expand All @@ -117,7 +117,7 @@ private static function create_composite_command( $parent, $name, $callable ) {
continue;
}

$class = is_object( $callable ) ? $callable : $reflection->name;
$class = is_object( $callable ) ? $callable : $reflection->name;
$subcommand = self::create_subcommand( $container, false, array( $class, $method->name ), $method );

$subcommand_name = $subcommand->get_name();
Expand All @@ -136,7 +136,7 @@ private static function create_composite_command( $parent, $name, $callable ) {
* @param mixed $callable
*/
private static function create_namespace( $parent, $name, $callable ) {
$reflection = new \ReflectionClass( $callable );
$reflection = new \ReflectionClass( $callable );
$doc_comment = self::get_doc_comment( $reflection );
if ( ! $doc_comment ) {
\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.", 'commandfactory' );
Expand Down Expand Up @@ -193,7 +193,7 @@ private static function get_doc_comment( $reflection ) {
* @return string|bool The last doc comment if any, or false if none.
*/
private static function extract_last_doc_comment( $content ) {
$content = trim( $content );
$content = trim( $content );
$comment_end_pos = strrpos( $content, '*/' );
if ( false === $comment_end_pos ) {
return false;
Expand All @@ -214,7 +214,7 @@ private static function extract_last_doc_comment( $content ) {
$subcontent = substr( $content, 0, $comment_start_pos );
while ( false !== ( $comment_start2_pos = strrpos( $subcontent, '/**' ) ) && false === strpos( $subcontent, '*/', $comment_start2_pos ) ) {
$comment_start_pos = $comment_start2_pos;
$subcontent = substr( $subcontent, 0, $comment_start_pos );
$subcontent = substr( $subcontent, 0, $comment_start_pos );
}
return substr( $content, $comment_start_pos, $comment_end_pos + 2 );
}
Expand Down
4 changes: 2 additions & 2 deletions php/WP_CLI/Dispatcher/CommandNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CommandNamespace extends CompositeCommand {
public function show_usage() {
$methods = $this->get_subcommands();

$i = 0;
$i = 0;
$count = 0;

foreach ( $methods as $name => $subcommand ) {
Expand All @@ -39,7 +39,7 @@ public function show_usage() {
}

$cmd_name = implode( ' ', array_slice( get_path( $this ), 1 ) );
$message = $count > 0
$message = $count > 0
? "See 'wp help $cmd_name <command>' for more information on a specific command."
: "The namespace $cmd_name does not contain any usable commands in the current context.";

Expand Down
Loading