Re: [VOTE] Dump results of expressions in `php -a`
| From: | Bob Weinand | Date: | Mon, 01 Feb 2021 15:40:05 +0000 |
| Subject: | Re: [VOTE] Dump results of expressions in `php -a` | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-113039@lists.php.net to get a copy of this message | ||
> Am 20.01.2021 um 01:55 schrieb tyson andre <tysonandre775@hotmail.com>:
>
> Hi internals,
>
> Voting has started on åÙ�Ò›„~í�
> N
@https://wiki.php.net/rfc/readline_interactive_shell_result_function
> on 2021-01-19, and ends on 2021-02-02.
>
> This RFC proposes to dump the results of non-null expressions using var_dump/var_export() by
> default in
php -a (the interactive shell).
> Additionally, this adds a new function
> readline_interactive_shell_result_function to the readline PHP
> module.
> This function only affects interactive shells - it can optionally be used to set or clear a
> closure when extension_loaded('readline') === true,
> but that closure would only be called in interactive shells (i.e. php -a)..
> (That closure would be called instead of the native implementation with the snippet of code
> that was evaluated and the expression's result,
> if a php statement contained a single expression such as 2+2;
> or $x = [1,2]; (that could be used as the expression of a return
> statement)
> - Dumping of expression results can be disabled using an ini setting or at runtime
>
> Thanks,
> - Tyson
Hey Tyson,
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()'ed. Do we have reasonable depth/output
limitations in default dumping mode?
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, this
needs different - intuitive - navigation.)
As it currently stands, this makes php -a unusable in any but the simplest cases, without just
disabling the whole feature.
I like the whole feature, but the missing output limitation (I have yet enough nightmares from
var_dump()'ing the wrong object filling my shell with tons of irrelevant information… I
don't need that potentially happening on every single evaluated expression)
Thus I'm voting no, for now.
Bob