diff --git a/features/eval.feature b/features/eval.feature index ba4f2f29..d2fae1e0 100644 --- a/features/eval.feature +++ b/features/eval.feature @@ -38,6 +38,22 @@ Feature: Evaluating PHP code and files. #! """ + Scenario: Has access to associative args + Given a WP installation + And a wp-cli.yml file: + """ + eval: + foo: bar + post list: + format: count + """ + + When I run `wp eval 'echo json_encode( $assoc_args );'` + Then STDOUT should be JSON containing: + """ + {"foo": "bar"} + """ + Scenario: Eval without WordPress install Given an empty directory diff --git a/src/Eval_Command.php b/src/Eval_Command.php index 1c94a853..9f09371a 100644 --- a/src/Eval_Command.php +++ b/src/Eval_Command.php @@ -39,7 +39,8 @@ class Eval_Command extends WP_CLI_Command { */ public function __invoke( $args, $assoc_args ) { - $execute_closure = function () use ( $args ) { + // @phpstan-ignore closure.unusedUse + $execute_closure = function () use ( $args, $assoc_args ) { eval( $args[0] ); };