From: scribu Date: Wed, 8 May 2013 12:10:12 +0000 (+0300) Subject: remove support for $_ special variable, since Boris doesn't support it. X-Git-Tag: v0.10.0~70^2~10 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1ead253ab0731414ac14dead11ee58d84eb33da3;p=wvm%2Fwvm.git remove support for $_ special variable, since Boris doesn't support it. --- diff --git a/features/shell.feature b/features/shell.feature index 2cc9c47f..a880b91a 100644 --- a/features/shell.feature +++ b/features/shell.feature @@ -10,26 +10,6 @@ Feature: WordPress REPL Type "exit" to close session. """ - Scenario: $_ special variable - Given a WP install - And a session file: - """ - WP_ADMIN - $_ - get_current_user_id() - $_ - """ - - When I run `wp shell --quiet < session` - Then it should run without errors - And STDOUT should be: - """ - true - true - 0 - 0 - """ - Scenario: Persistent environment Given a WP install And a session file: diff --git a/man-src/shell.txt b/man-src/shell.txt index da5393cf..02f84c97 100644 --- a/man-src/shell.txt +++ b/man-src/shell.txt @@ -2,8 +2,6 @@ `wp shell` allows you to evaluate PHP statements and expressions interactively, from within a WordPress environment. This means that you have access to all the functions, classes and globals that you would have access to from inside a WordPress plugin, for example. -`$_` is a special variable that contains the result from the last evaluated statement. - You can split a statement over multiple lines by adding a `\` (backslash) before hitting Return. If you type `history` and hit Return, WP-CLI will print the list of previously evaluated statements, which you can copy+paste into a PHP file. diff --git a/php/WP_CLI/REPL.php b/php/WP_CLI/REPL.php index 93e43774..830404d0 100644 --- a/php/WP_CLI/REPL.php +++ b/php/WP_CLI/REPL.php @@ -32,14 +32,10 @@ class REPL { if ( self::starts_with( self::non_expressions(), $line ) ) { eval( $line ); } else { - if ( self::starts_with( 'return', $line ) ) - $line = substr( $line, strlen( 'return' ) ); + if ( !self::starts_with( 'return', $line ) ) + $line = 'return ' . $line; - $line = '$_ = ' . $line; - - eval( $line ); - - \WP_CLI::print_value( var_export( $_, false ) ); + \WP_CLI::print_value( var_export( eval( $line ), false ) ); } } }