From 75469df7cfa2f5171bdef4570fe685ba791d98e2 Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Mon, 19 May 2025 13:05:44 +0200 Subject: [PATCH 1/2] Make $args available as global Fix: https://github.com/wp-cli/eval-command/issues/80 --- src/EvalFile_Command.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/EvalFile_Command.php b/src/EvalFile_Command.php index 5d2d4b2d..de73a955 100644 --- a/src/EvalFile_Command.php +++ b/src/EvalFile_Command.php @@ -63,10 +63,14 @@ public function __invoke( $args, $assoc_args ) { * Evaluate a provided file. * * @param string $file Filepath to execute, or - for STDIN. - * @param mixed $args Array of positional arguments to pass to the file. + * @param mixed $positional_args Array of positional arguments to pass to the file. * @param bool $use_include Process the provided file via include instead of evaluating its contents. */ - private static function execute_eval( $file, $args, $use_include ) { + private static function execute_eval( $file, $positional_args, $use_include ) { + global $args; + $args = $positional_args; + unset( $positional_args ); + if ( '-' === $file ) { eval( '?>' . file_get_contents( 'php://stdin' ) ); } elseif ( $use_include ) { From 25e9cc1cde54acbccd10fa0ea7014932a584b5c9 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 3 Nov 2025 22:03:59 +0100 Subject: [PATCH 2/2] Lint fix --- src/EvalFile_Command.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EvalFile_Command.php b/src/EvalFile_Command.php index de73a955..fc4efaf4 100644 --- a/src/EvalFile_Command.php +++ b/src/EvalFile_Command.php @@ -68,6 +68,7 @@ public function __invoke( $args, $assoc_args ) { */ private static function execute_eval( $file, $positional_args, $use_include ) { global $args; + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $args = $positional_args; unset( $positional_args );