Re: [VOTE] Dump results of expressions in `php -a`

From: Date: Wed, 20 Jan 2021 16:00:11 +0000
Subject: Re: [VOTE] Dump results of expressions in `php -a`
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-112938@lists.php.net to get a copy of this message
> On Jan 19, 2021, at 18:55, tyson andre <tysonandre775@hotmail.com> wrote: > > Hi internals, > > Voting has started on > 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 I voted “no” because I don’t think readline_interactive_shell_result_function() solves a problem in a way that is better than can be done in userland. It’s quite limited, requiring the readline extension, and anyone who wishes to build a more complex implementation will need to require users to add something to auto_prepend_file or manually load something after dropping into interactive mode. I had originally thought that userland implementations might be able to make use of this to piggyback off of php -a, but Justin Hileman (author of PsySH) thinks it’s not something that would be useful to userland REPLs [^1]. > There’s still no way to do 99% of what PsySH does without a userland REPL. This just makes > the output look similar. I do think there’s value in improving PHP’s built-in interactive mode with prettier dumping of expression results, but I think readline_interactive_shell_result_function() will not end up being used in practice. Cheers, Ben [^1]: https://twitter.com/ramsey/status/1347661890420428802

Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc
« previous php.internals (#112938) next »