Skip to content

Commit f3f5993

Browse files
Run system check on before_invoke
1 parent c6849d9 commit f3f5993

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

server-command.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
require_once $autoload;
1010
}
1111

12-
WP_CLI::add_command( 'server', 'Server_Command', array() );
12+
WP_CLI::add_command( 'server', 'Server_Command', array(
13+
'before_invoke' => function() {
14+
$min_version = '5.4';
15+
if ( version_compare( PHP_VERSION, $min_version, '<' ) ) {
16+
WP_CLI::error( "The `wp server` command requires PHP {$min_version} or newer." );
17+
}
18+
}
19+
) );

src/Server_Command.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ class Server_Command extends WP_CLI_Command {
5555
* @when before_wp_load
5656
*/
5757
function __invoke( $_, $assoc_args ) {
58-
$min_version = '5.4';
59-
if ( version_compare( PHP_VERSION, $min_version, '<' ) ) {
60-
WP_CLI::error( "The `wp server` command requires PHP $min_version or newer." );
61-
}
62-
6358
$defaults = array(
6459
'host' => 'localhost',
6560
'port' => 8080,

0 commit comments

Comments
 (0)