From 09f41b7ef02e07b80694b077f59e793fd89807c8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Aug 2026 11:10:35 +0200 Subject: [PATCH 1/2] Fix newly reported PHPStan errors --- src/Server_Command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Server_Command.php b/src/Server_Command.php index 1e33023..4b18dd9 100644 --- a/src/Server_Command.php +++ b/src/Server_Command.php @@ -127,15 +127,15 @@ public function __invoke( $args, $assoc_args ) { // Add the server flags $cmd_format .= ' -S %s -t %s -c %s %s'; $cmd_args[] = $assoc_args['host'] . ':' . $assoc_args['port']; - $cmd_args[] = $docroot; - $cmd_args[] = $assoc_args['config']; + $cmd_args[] = (string) $docroot; + $cmd_args[] = is_string( $assoc_args['config'] ) ? $assoc_args['config'] : ''; $cmd_args[] = Utils\extract_from_phar( $router_path ); $cmd = Utils\esc_cmd( $cmd_format, ...$cmd_args ); $descriptors = array( STDIN, STDOUT, STDERR ); - if ( Utils\get_flag_value( $assoc_args, 'adapt-scheme', false ) ) { // @phpstan-ignore argument.type + if ( Utils\get_flag_value( $assoc_args, 'adapt-scheme', false ) ) { putenv( 'WPCLI_SERVER_ADAPT_SCHEME=1' ); } From 3709828d902573ca7423af4ad022f8f7c7c61597 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Aug 2026 12:41:24 +0200 Subject: [PATCH 2/2] Address code review feedback --- features/server.feature | 18 ++++++++++++++++++ src/Server_Command.php | 10 ++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/features/server.feature b/features/server.feature index badb0f2..ba3f573 100644 --- a/features/server.feature +++ b/features/server.feature @@ -32,6 +32,24 @@ Feature: Serve WordPress locally 256M """ + Scenario: Custom ini configuration + Given a WP install + And a mem.php file: + """ + + """ + And a custom.ini file: + """ + memory_limit = 512M + """ + And I launch in the background `wp server --host=localhost --port=8188 --config=custom.ini` + + When I run `curl -sS localhost:8188/mem.php` + Then STDOUT should be: + """ + 512M + """ + Scenario: Access wp-login.php Given a WP install And I launch in the background `wp server --host=localhost --port=8185` diff --git a/src/Server_Command.php b/src/Server_Command.php index 4b18dd9..0faa860 100644 --- a/src/Server_Command.php +++ b/src/Server_Command.php @@ -125,10 +125,16 @@ public function __invoke( $args, $assoc_args ) { } // Add the server flags - $cmd_format .= ' -S %s -t %s -c %s %s'; + $cmd_format .= ' -S %s -t %s'; $cmd_args[] = $assoc_args['host'] . ':' . $assoc_args['port']; $cmd_args[] = (string) $docroot; - $cmd_args[] = is_string( $assoc_args['config'] ) ? $assoc_args['config'] : ''; + + if ( ! empty( $assoc_args['config'] ) && is_string( $assoc_args['config'] ) ) { + $cmd_format .= ' -c %s'; + $cmd_args[] = $assoc_args['config']; + } + + $cmd_format .= ' %s'; $cmd_args[] = Utils\extract_from_phar( $router_path ); $cmd = Utils\esc_cmd( $cmd_format, ...$cmd_args );