Skip to content

Commit

Permalink
Merge pull request #198 from wp-cli/fix/undefined-index-for-db-socket
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera authored Dec 21, 2023
2 parents c921f04 + c28bf48 commit efbbcc4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,17 @@ function ( $matches ) use ( $phar_path, $shell_path ) {
* Replace variables callback.
*/
private function replace_var( $matches ) {
$cmd = $matches[0];
$str = $matches[0];

foreach ( array_slice( $matches, 1 ) as $key ) {
$cmd = str_replace( '{' . $key . '}', $this->variables[ $key ], $cmd );
$str = str_replace(
'{' . $key . '}',
array_key_exists( $key, $this->variables ) ? $this->variables[ $key ] : '',
$str
);
}

return $cmd;
return $str;
}

/**
Expand Down

0 comments on commit efbbcc4

Please sign in to comment.