Skip to content

Commit 63dbc3a

Browse files
committed
Ensure $assoc_args can be used in eval
1 parent cbe6916 commit 63dbc3a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

features/eval.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ Feature: Evaluating PHP code and files.
3838
#!
3939
"""
4040

41+
Scenario: Has access to associative args
42+
Given a WP installation
43+
And a wp-cli.yml file:
44+
"""
45+
eval:
46+
foo: bar
47+
post list:
48+
format: count
49+
"""
50+
51+
When I run `wp eval 'echo json_encode( $assoc_args );'`
52+
Then STDOUT should be JSON containing:
53+
"""
54+
{"foo": "bar"}
55+
"""
56+
4157
Scenario: Eval without WordPress install
4258
Given an empty directory
4359

src/Eval_Command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class Eval_Command extends WP_CLI_Command {
3939
*/
4040
public function __invoke( $args, $assoc_args ) {
4141

42-
$execute_closure = function () use ( $args ) {
42+
// @phpstan-ignore closure.unusedUse
43+
$execute_closure = function () use ( $args, $assoc_args ) {
4344
eval( $args[0] );
4445
};
4546

0 commit comments

Comments
 (0)