Skip to content

Commit 20d13ff

Browse files
Copilotswissspidy
andcommitted
Address review feedback: improve test, simplify loop, add PHPDoc params
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent bfee089 commit 20d13ff

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎features/server.feature‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ Feature: Serve WordPress locally
1818

1919
Scenario: Passthrough arguments to PHP binary
2020
Given a WP install
21+
And a file "mem.php" with:
22+
"""
23+
<?php echo ini_get('memory_limit'); ?>
24+
"""
2125
And I launch in the background `wp server --host=localhost --port=8182 -- -dmemory_limit=256M`
2226

23-
When I run `curl -sS localhost:8182/wp-admin/install.php`
24-
Then the return code should be 0
27+
When I run `curl -sS localhost:8182/mem.php`
28+
Then STDOUT should be:
29+
"""
30+
256M
31+
"""

‎src/Server_Command.php‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class Server_Command extends WP_CLI_Command {
6969
* Press Ctrl-C to quit.
7070
*
7171
* @when before_wp_load
72+
*
73+
* @param array $args Positional arguments passed through to the PHP binary.
74+
* @param array $assoc_args Associative arguments passed to the command.
7275
*/
7376
public function __invoke( $args, $assoc_args ) {
7477
$defaults = array(
@@ -104,13 +107,8 @@ public function __invoke( $args, $assoc_args ) {
104107

105108
// Add passthrough arguments before the -S flag
106109
if ( ! empty( $args ) ) {
107-
foreach ( $args as $arg ) {
108-
if ( '--' === $arg ) {
109-
continue;
110-
}
111-
$cmd_format .= ' %s';
112-
$cmd_args[] = $arg;
113-
}
110+
$cmd_format .= str_repeat( ' %s', count( $args ) );
111+
$cmd_args = array_merge( $cmd_args, $args );
114112
}
115113

116114
// Add the server flags

0 commit comments

Comments
 (0)