Skip to content

Commit 0a858c8

Browse files
authored
Fix newly reported PHPStan errors (#104)
1 parent 38cf00f commit 0a858c8

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

‎features/server.feature‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ Feature: Serve WordPress locally
3232
256M
3333
"""
3434

35+
Scenario: Custom ini configuration
36+
Given a WP install
37+
And a mem.php file:
38+
"""
39+
<?php echo ini_get('memory_limit'); ?>
40+
"""
41+
And a custom.ini file:
42+
"""
43+
memory_limit = 512M
44+
"""
45+
And I launch in the background `wp server --host=localhost --port=8188 --config=custom.ini`
46+
47+
When I run `curl -sS localhost:8188/mem.php`
48+
Then STDOUT should be:
49+
"""
50+
512M
51+
"""
52+
3553
Scenario: Access wp-login.php
3654
Given a WP install
3755
And I launch in the background `wp server --host=localhost --port=8185`

‎src/Server_Command.php‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,23 @@ public function __invoke( $args, $assoc_args ) {
125125
}
126126

127127
// Add the server flags
128-
$cmd_format .= ' -S %s -t %s -c %s %s';
128+
$cmd_format .= ' -S %s -t %s';
129129
$cmd_args[] = $assoc_args['host'] . ':' . $assoc_args['port'];
130-
$cmd_args[] = $docroot;
131-
$cmd_args[] = $assoc_args['config'];
130+
$cmd_args[] = (string) $docroot;
131+
132+
if ( ! empty( $assoc_args['config'] ) && is_string( $assoc_args['config'] ) ) {
133+
$cmd_format .= ' -c %s';
134+
$cmd_args[] = $assoc_args['config'];
135+
}
136+
137+
$cmd_format .= ' %s';
132138
$cmd_args[] = Utils\extract_from_phar( $router_path );
133139

134140
$cmd = Utils\esc_cmd( $cmd_format, ...$cmd_args );
135141

136142
$descriptors = array( STDIN, STDOUT, STDERR );
137143

138-
if ( Utils\get_flag_value( $assoc_args, 'adapt-scheme', false ) ) { // @phpstan-ignore argument.type
144+
if ( Utils\get_flag_value( $assoc_args, 'adapt-scheme', false ) ) {
139145
putenv( 'WPCLI_SERVER_ADAPT_SCHEME=1' );
140146
}
141147

0 commit comments

Comments
 (0)