rfc:readline_interactive_shell_result_function
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:readline_interactive_shell_result_function [2021/01/16 20:50] – tandre | rfc:readline_interactive_shell_result_function [2021/02/03 00:39] (current) – tandre | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Configurable callback to dump results of expressions in `php -a` ====== | + | ====== PHP RFC: Dump results of expressions in `php -a` ====== |
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2020-12-19 | * Date: 2020-12-19 | ||
* Author: Tyson Andre, tandre@php.net | * Author: Tyson Andre, tandre@php.net | ||
- | * Status: | + | * Status: |
* Implementation: | * Implementation: | ||
* First Published at: https:// | * First Published at: https:// | ||
Line 14: | Line 14: | ||
(I've seen https:// | (I've seen https:// | ||
- | Because PHP's interactive shell is written in C, adding new features or bug fixes would require a lot of time getting familiar with | ||
- | C programming, | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 22: | Line 20: | ||
Additionally, | Additionally, | ||
- | This will dump the results of expressions every time a statement containing a single expression such as '' | + | This will dump the results of expressions every time a statement containing a single expression such as '' |
An example of the behavior of the default expression dumper is below: | An example of the behavior of the default expression dumper is below: | ||
Line 78: | Line 76: | ||
newline not automatically appended by shell | newline not automatically appended by shell | ||
=> 44 | => 44 | ||
- | php > { print(" | + | php > { print(" |
test | test | ||
php > | php > | ||
Line 86: | Line 84: | ||
<code php> | <code php> | ||
- | php -a | + | $ php -a |
Interactive shell | Interactive shell | ||
Line 120: | Line 118: | ||
*/ | */ | ||
function readline_interactive_shell_result_function(? | function readline_interactive_shell_result_function(? | ||
+ | </ | ||
+ | |||
+ | The default implementation added as part of this RFC is effectively identical to the below implementation, | ||
+ | |||
+ | <code php> | ||
+ | readline_interactive_shell_result_function( | ||
+ | function(string $code, $result) { | ||
+ | if (!isset($result)) { | ||
+ | return; | ||
+ | } | ||
+ | if (is_scalar($result)) { | ||
+ | echo "=> " . var_export($result, | ||
+ | } else { | ||
+ | echo "=> "; var_dump($result); | ||
+ | }}); | ||
</ | </ | ||
Line 125: | Line 138: | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | None, only interactive sessions are affected, | + | |
+ | Only interactive sessions | ||
+ | |||
+ | In interactive sessions, this will start calling [[https:// | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 162: | Line 179: | ||
* i.e. change '' | * i.e. change '' | ||
- | ===== Proposed Voting Choices ===== | + | ==== Rendering a result limit ==== |
- | Voting starts on 2021-01-03 and ends 2021-01-17. | + | https:// |
+ | The setting '' | ||
+ | |||
+ | < | ||
+ | My main concern in this iteration of the RFC is: what happens with big/deeply nested objects? | ||
+ | They tend to spew tons of lines if var_dump()' | ||
+ | |||
+ | I'm often enough using php -a to do some quick ad-hoc processing (example, read a big json file, and then access a value; instantiating a mediawiki bot framework and calling replace on it; ...). | ||
+ | |||
+ | It's really cool to have any interactive feedback at all, but please, at least by default, limit the output. (An example is the JS REPL in browser console - it shows you a minimal preview of the object, and then you can expand with your mouse. Obviously with a pure cli application, | ||
+ | |||
+ | As it currently stands, this makes '' | ||
+ | |||
+ | I like the whole feature, but the missing output limitation (I have yet enough nightmares from var_dump()' | ||
+ | |||
+ | Thus I'm voting no, for now. | ||
+ | </ | ||
+ | ===== Vote ===== | ||
+ | |||
+ | Voting starts on 2021-01-19 and ended 2021-02-02 | ||
Yes/No, requiring 2/3 majority | Yes/No, requiring 2/3 majority | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== References ===== | ===== References ===== | ||
+ | * https:// | ||
* https:// | * https:// | ||
- | * https:// | + | * https:// |
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | 0.2: Dump non-null expression results by default with var_dump()/ | ||
+ | 0.3: Document the default implementation used in the implementation |
rfc/readline_interactive_shell_result_function.1610830240.txt.gz · Last modified: 2021/01/16 20:50 by tandre