Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions features/eval.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/Eval_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
};

Expand Down
Loading