Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113046 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52185 invoked from network); 2 Feb 2021 02:52:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Feb 2021 02:52:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 632E91804D0 for ; Mon, 1 Feb 2021 18:35:34 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2098.outbound.protection.outlook.com [40.92.22.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 1 Feb 2021 18:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3ZlDoi5n/Ye0yuiewq/1UU5PQ1SXT/pD72/dmD7/AI4fcz0xDeJMfoNXwH1Y4w2GIRDmRBmNYU8uXveEBz9H3dXswlSMkjVq8Fq8d89b1dlxTlmOSSedle3QDc+1Nh4ZpPNdNHv21/LfOn/R7IF/qRgLZjCHDv/PyOnXqDCBQsa+yaYBSsgq4p6XBgwuYa9Hvx9YGIVmQZVWS6rvxKht2oJzksoazvwYHoKyFzw55juf1KzybwZUWXcaS/RCQ09Jf5mR0pto7rnr6+RNYL1aOYFstvzsWE5TZyXAaVM+GomvrPFZhb+mArzQFYuOv1Mg9+fjFGjtkXKDBgvfrK1CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHloybVibu1u0opiMt5No4yaD2HbpbmgU8sXnN/DnLs=; b=M/3+69O+6onHibmQN80FE1nlX4H8NSlTJR0Z6xuYGdtLwfSyBevxlzGxd19W/ZBGXbw3303vt9lto2d9AsJ4z3wEFb/vwx8XFYuPbdOsuzP9b6jtcri01tYR2vLxug9HTzHE9mwy3S3sKJc6ujx2nrcj919OMDZQUy45roSIlykUen37DWi8ScazL+EyhJVMl696teY9Rup8Rc7hdczxDYdKJqZBkkP1RLGxNg/NilvofujD2Q/J//YN1Uc0HXtNVZaGjoz+YBp5da767Hg5dGV3LmpjIMcMD6MlxzxCnHE8rf6wtFxGutxdp/BvbVopry6S1WcKZAr6q/lGUWoCXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHloybVibu1u0opiMt5No4yaD2HbpbmgU8sXnN/DnLs=; b=Yf3wimoZlm6n1MtSVvSTcnRkWad723Q8QOTxJ9ir6EdXIQacddaWF2JewT5adPZjhBVVDFSokPjeIhWHSc7vjiauFDJqnEqWlPRvs3LbI/Ba2PhuK1/PV0HQMqBUhvHaH3HDCy19kBaJATP21dmW/7D1FqbuMtCJ48G/dyEmxwh8VjImFjuQNT14pKxDFXuBIAwqgBcSQrrNqWqSFgW/Y01KxrQx8R6URVumOjvYCtXElt41+ie6Sdn0H0Y+g9BlFSCIvXKHeKeJPy+TNj4SAT9LwXdEruTGOvB1bqDv/lsW4ohHHMu1EMDTR6lmvNISyasMzgBB6SAxDMXtscoZwA== Received: from DM6NAM12FT035.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::53) by DM6NAM12HT155.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.11; Tue, 2 Feb 2021 02:35:32 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:fc64::47) by DM6NAM12FT035.mail.protection.outlook.com (2a01:111:e400:fc64::285) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.6 via Frontend Transport; Tue, 2 Feb 2021 02:35:32 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d%4]) with mapi id 15.20.3805.028; Tue, 2 Feb 2021 02:35:32 +0000 To: Bob Weinand CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [VOTE] Dump results of expressions in `php -a` Thread-Index: AQHW7sXh/djsjqFFPU2LB2XOuWtB1qpDg3qAgAC0oVE= Date: Tue, 2 Feb 2021 02:35:32 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:997A949D4775B1A75D8F65A412F935844F9E8E7DB18C8709EEB4147F58FCEC30;UpperCasedChecksum:29B59A038CA9A3CA86A0D005ADB259EACFE580B31EC27631002891615F47FE3B;SizeAsReceived:7201;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [QEamfXhUohvZRBvfR6dmG4Ge/l2t6gKX7L9GxF+OGq4wy///mmfVDnU55LXpifng] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: c6498385-64e1-4cea-6108-08d8c723367a x-ms-exchange-slblob-mailprops: K3wx5smWY1PwvgS5FL6c7aYCSdIhAjJct2sLBhNu7llA4HGDdLzc5XTi1gI0bHCtxeo7zRUQIGlWz9TzQq/8meeD+l4r82vwiJkaNNRvRIM4VEVOL9TFg+1StLZc4k/bjZTn9Dp6Rmz92xIXwfJ7MHOWk7MKzuve/ADFoaUXDeUdWUiHNphPLH0fSlxhapHu76/GEBWiNXgiyvZ3bK9vkbFuQyWOx7gSOUJgdeXC6dJI73H/LVEaXAip1WoHh6byPAGVETiaQ04+3BXgzkyoh4JqlMO+yLJoqJKWEpId4NoIRt4+xE50IOd+aqwGtjgISg0vFkVSL0UFQdiO59nIvM7JB0EzvH+c3JX6TFoNbnID7LaTSpfyit0o95CWXJ9sS/2Q1mHDWHgbL80krKttiinyrckeYpxswEqC8mS9jAZk9C5yLJ80UTGcoSfJFvvHeM0/eHSISmRizjyTd2g2ANr1TUEuqLLuk9ZW5JesTg1z0BCAGK9uof7IuVlo6ueMqVBD/BFBBre9ZD2beNBkSZRlU8IkDahAJl7/9eoEGEDShG+a36vIhlp1DtxwhIu0eu0ACEj6xvkG1rLM6R6vtR0Bcu61YIASsY+FES5z4f/BppaxBTZcMwdY9kqWGlkIerETsAJFIS6sixR3+v6L+4yornXX3T68G7sYB+jgl4VKZjVWXsLPxqFUczhKki3biAqnCWhBHT5qlCmVswXHo7xtYVPmTEnwuYuahmWTvgkL8vdiZRzMZRWEgRjim3A8tqAWoYUcYCGKQA1jGyRum5165tInyVZBywILRvc1YZRHCNZMf8rM+olyfDnEG1z1MI5TC08Zpk9RhMo/yp8+H+/tIjtos1wtVsC+1rkJMWZUOrXcXuEcwFvXtAVbznhuH+d3XEkHll6bULnJ1Z1PtTIyJQxCqyfp3vZtj3Bp8dA= x-ms-traffictypediagnostic: DM6NAM12HT155: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AdhQk5xKX6Tx4hGP2uJTRIfsr3qko6uLVxYsDlTEYEEGAzpJGANgforsFN6IofXBA9au0AqinQX/OQ9gIWuTp03Aqu1D0f+orWMpYT/D9/Ai7YL53pnoLHtixktsm4OfGhkJ7nEKemRT/2BLqG/JLTfgvtnHymvpxmomQwNx8doL5bQcYoq9I/IQoF5MpMF7jiptR4HGK36WqHzdn5dJSvFaL8JYdFhR1/PUMVqIZrf4eZmTrcILZY3XoMMJ19JBE4o39l2CHVtF2C3WZr64VHSrhfngs4HLREPdc7+RbX/qIFQGxTlui7bYsJcGG9hmfqQ2Muv9rl4C3Rth4MUu+tHqwX4EA4T03WtmYW/b8dMrqeeGbAtAPxvY0zxmC6YXmnhoFD1ERrujKPwY71phCZjBJvmm1HZiNFVTs4R3M3WpDCwXX9ieuFwSsRaSTQzz x-ms-exchange-antispam-messagedata: evpSs6yQUl0fs0KPYCCQOQNGxBw2jol/dF7CKbTvxEhbeQfrc7x71ueHPd5pTcAxnHStjYdPjkC3GcRKe8T71GCAhWYslIRl0yXn+FWgLMXQpkpaN3Gq3zeDJELtG68C3ZYG+LAmaN7eWrEspYur0ADhO9R65LXbRTycjB+biVdvaKivw7RWSV1/utU9iKoTOKX1OFQeDDNb3hVFtwuHYw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: DM6NAM12FT035.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: c6498385-64e1-4cea-6108-08d8c723367a X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2021 02:35:32.3928 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM12HT155 Subject: Re: [PHP-DEV] [VOTE] Dump results of expressions in `php -a` From: tysonandre775@hotmail.com (tyson andre) Hi Bob Weinand,=0A= =0A= > > Am 20.01.2021 um 01:55 schrieb tyson andre := =0A= > > =0A= > > Hi internals,=0A= > > =0A= > > Voting has started on https://wiki.php.net/rfc/readline_interactive_she= ll_result_function=0A= > > on 2021-01-19, and ends on 2021-02-02.=0A= > > =0A= > > This RFC proposes to dump the results of non-null expressions using var= _dump/var_export() by default in `php -a` (the interactive shell).=0A= > > Additionally, this adds a new function `readline_interactive_shell_resu= lt_function` to the readline PHP module.=0A= > > This function only affects interactive shells - it can optionally be us= ed to set or clear a closure when `extension_loaded('readline') =3D=3D=3D t= rue`,=0A= > > but that closure would only be called in interactive shells (i.e. php -= a).=0A= > > (That closure would be called instead of the native implementation with= the snippet of code that was evaluated and the expression's result,=0A= > > if a php statement contained a single expression such as `2+2;` or `$x = =3D [1,2];` (that could be used as the expression of a return statement)=0A= > > - Dumping of expression results can be disabled using an ini setting or= at runtime =0A= > > =0A= > > Thanks,=0A= > > - Tyson=0A= > =0A= > Hey Tyson,=0A= > =0A= > My main concern in this iteration of the RFC is: what happens with big/de= eply nested objects?=0A= > They tend to spew tons of lines if var_dump()'ed. Do we have reasonable d= epth/output limitations in default dumping mode?=0A= > =0A= > 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; ...).=0A= > =0A= > 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 c= onsole - it shows you a minimal preview of the object, and then you can exp= and with your mouse. Obviously with a pure cli application, this needs diff= erent - intuitive - navigation.)=0A= > =0A= > As it currently stands, this makes php -a unusable in any but the simples= t cases, without just disabling the whole feature.=0A= > =0A= > I like the whole feature, but the missing output limitation (I have yet e= nough nightmares from var_dump()'ing the wrong object filling my shell with= tons of irrelevant information=85 I don't need that potentially happening = on every single evaluated expression)=0A= > =0A= > Thus I'm voting no, for now.=0A= =0A= As-is, the entire object or string would be dumped with var_export/var_dump= to stdout.=0A= =0A= Thoughts on the adding following output truncation mechanism =0A= (for the default C result dumper implementation)=0A= before printing the results of the returned expression =0A= (the user output continues to be untruncated, and the existence of cli.page= r =0A= would not affect this mechanism in case the binary is not actually a pager)= ?=0A= For arrays/objects used with var_dump - the equivalent of =0A= `ob_start(); var_dump($result); $result =3D ob_get_clean();` =0A= would have to be used first from C since var_dump still writes to the outpu= t buffer (php_printf(), etc.)=0A= =0A= I'd omitted output truncation from the RFC because I wasn't sure how many p= eople =0A= would consider it excessive to include a limit on var_dump output, and ther= e was little feedback before the RFC vote started.=0A= The simplest implementation would be to truncate to a byte limit and append= `...` if truncated, =0A= but the main concern that's been brought up is the approximate number of li= nes.=0A= Obviously, there'd be a value in truncating the output if there were to be = megabytes of output,=0A= though exactly what settings make sense as a default would vary.=0A= =0A= C would not print anything (e.g. `=3D> `) or even call var_dump/var_export = if the limits were set to 0.=0A= =0A= ```=0A= =3D ASSUMED_BYTES_PER_LINE) {=0A= $total_lines++;=0A= $offset =3D ($offset - ASSUMED_BYTES_PER_LINE) % ASSUME= D_TAB_WIDTH;=0A= }=0A= break;=0A= default:=0A= $offset++;=0A= if ($offset >=3D ASSUMED_BYTES_PER_LINE) {=0A= $total_lines++;=0A= $offset =3D 0;=0A= }=0A= break;=0A= }=0A= }=0A= if ($i >=3D $strlen) {=0A= return $raw_output;=0A= }=0A= return substr($raw_output, 0, $i) . "..."; // C appends newlines alrea= dy if there was none=0A= }=0A= // unmodified=0A= var_dump(truncate_string("test short string"));=0A= // 5000 'A's followed by "...\n"=0A= var_dump(truncate_string(str_repeat('A', 10000)));=0A= // 100 lines containing "A" followed by "...\n"=0A= var_dump(truncate_string(str_repeat("A\n", 10000)));=0A= ```=0A= =0A= Thanks,=0A= - Tyson=0A=