Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111400 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57625 invoked from network); 9 Aug 2020 19:47:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Aug 2020 19:47:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BBD2C1804D9 for ; Sun, 9 Aug 2020 11:46:22 -0700 (PDT) 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-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12olkn2023.outbound.protection.outlook.com [40.92.23.23]) (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 ; Sun, 9 Aug 2020 11:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NKJ7QwUGNpPWXV7gftLy6/s2R4WcZsM11qZMCVOs2lfSUkw+87K42Hlj627RY0rqGElN49FVxaGtKre1gezIrncos9q3LDo1w0a3gvfPWccL0RR2OZ1RMWEVgA0EtRX79W0eKm1spDb90+9Fa6KE+FaUnBVI2XqDuPvtZu+sYKRHFCk04c7Ri6G1L3p1wKJug18tyVG18EC3rmezt2Z48K/fY6IbBWA0RnR68Br7/9wjCNNOepLYK5K5G2q5WZcM0xZgNKECE/9EvcXUrLzPvLu/oIDgxaOjmRuYeWHquNKh1H44yoT3m5Mcr7P7vQtgmSNfwv+cJCm5ubExyOf//A== 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=TumNjNpuWqm21UxpLAAKbfz3bWq3j8fCqEr8r7Q3JK4=; b=cwD2RYyjDPD3pcprQjCGh8YdSjT0/pB+xGRm6x4uP+BvVBh6SwpI1Wzx+hcOd4FH7WsoxvYpx8CI2Der8gZSoypk2KZZeid0WlqQj+QJvSvhwJIsi055s9h1FJTMdk/MW30mRGuWzz1WoZMZ6cBtCSV5jQiXdHYGEv4eAfvo217J64FrKIvyNMLuRlnSOGjxtnpOb1tryUJ74zjkxyfn+IwstfOJGU2q13wA+gflIsExP18MhR20zh2cc3P1GGKvNZJx2b2/G44tazICvZZS+XrbWEMoN81NrBIcWMyY76GrO4eF1UmuLUHwlOWmWl8GlMAKnuWf1md1fNXVOGJ0Dg== 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=TumNjNpuWqm21UxpLAAKbfz3bWq3j8fCqEr8r7Q3JK4=; b=iSDlSL+s+jJdWoNXdv8EA8ZjvS9e9KURYItZnBVmsrmriwJZcCgH7s32c3h1No91oegoE/UO6k6LNqtQuhXuLkU741YOCwx8bJdVdRNhDW0MFDZTgMsdBI02Eo65gswYspJkB1SZDDg17lY/BpuMqs0FUY9igdlAupATd9nMXLV0llZ3D/t8IdUhL7IzrCIjm5wxXVYs09ZZUixoaPRR9kCZ/G3op+/kuXdRWfrS4pFcgYqB9ilH+FP9rRUW6k8yg3pw1zoxEuBw/J/GJXMqE5+FuBKh7vl3ndX1IVPbRqqTWv4/viWQYwewr62emfJGjbbaKt1xenaJs4viu4CH9w== Received: from DM6NAM12FT008.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::4e) by DM6NAM12HT117.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.10; Sun, 9 Aug 2020 18:46:20 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:fc64::51) by DM6NAM12FT008.mail.protection.outlook.com (2a01:111:e400:fc64::271) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.11 via Frontend Transport; Sun, 9 Aug 2020 18:46:20 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1%6]) with mapi id 15.20.3261.022; Sun, 9 Aug 2020 18:46:20 +0000 To: "internals@lists.php.net" Thread-Topic: Improving the usability of PHP's interactive shell? (completions, displaying expression results, custom syntax) Thread-Index: AQHWXVBlEJWFSBe2+kWGt77QcnGQFKkwIN6X Date: Sun, 9 Aug 2020 18:46:20 +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:3D572A780FEEC7D51C67C5F390B12A7AAC8E0108503091B878EFD0EBD6C9E653;UpperCasedChecksum:E684A88E50EE02F99AE2A2BC5101484C5300F31BC23B355FE9754E1C639BCBDA;SizeAsReceived:7202;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [v1mlErNnuGUpDMwmtoo5YmlqO1evjh448fc1N1oC8uO+zb6+fNez5Mn6QHhBzCRj] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 5390922e-c3b7-4aa6-bd5a-08d83c9481b5 x-ms-traffictypediagnostic: DM6NAM12HT117: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BoIV1cY3kM5Rhke2Q53Pkv0AVTlD0cghcaoUiGMlMc7fhzB5UCNDtYcnua8mB7gTKEeVRLoFdK/BeD86aLOfPpLcnP/kMBjKoLp6HBKcdmTne7qypG7ON6fi6etNfsGNQtsxDFEoeObeGfhgHnv7qpKBA+fzYTkeo3OLZSTrctw/2W+yWEwy08o5yck/87xFtGllKwrTg8ly9GAxQzdPSGUfucLqfp6YMZ4f2dteoxthztux/G0MPyxyz9Mrch4j x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: mW5LkkdYska5q2zyxLTZh2Vmg6CRCpD83XgL208JxNJUryIM9keowftdCnqUg8G63Xfguu7NJIuCvr7gTYwg6K2j22NovAKxCLIqP7KpZOG7ncj2UkuacsSZkL+IupvjQioX6KFTahxdp5gSDSsB61rsL7Cfr5aoq1EJm0hAU8dqw96N2hxtHr0xGiwQjFQi75tJ7Q/pEGxX9VxpOPYtww== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: DM6NAM12FT008.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 5390922e-c3b7-4aa6-bd5a-08d83c9481b5 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2020 18:46:20.1203 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM12HT117 Subject: Re: Improving the usability of PHP's interactive shell? (completions, displaying expression results, custom syntax) From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= > - Add a hook to `readline` such as `readline_set_php_result_handler_callb= ack(function(mixed $result, string $snippet){...})`=0A= > =A0 that can be used to create a user-defined function to print/process t= he result of expressions.=0A= >=A0 (Create a clone of `zend_eval_stringl` to support that)=0A= > (The result value would instead be freed after the callback was called)= =0A= >=0A= >=A0 Many other REPLs (Read-Eval-Print Loops) that I'm familiar with print = a representation of the result of expressions, but PHP doesn't.=0A= =0A= I've added this in https://github.com/php/php-src/pull/5962 .=0A= I plan to add a system ini setting that can be used to permanently disable = this silently (enabled by default in all environments/example configs)=0A= This will be callable if `readline` is installed, whether or not the shell = is interactive or the SAPI is CLI.=0A= - e.g. `cli.allow_interactive_shell_result_function=3D1` would be the defau= lt. Other existing settings were https://www.php.net/manual/en/readline.con= figuration.php=0A= - A buggy handler closure might interfere with people trying to debug issue= s,=0A= which is why the ini setting is proposed.=0A= =0A= ```=0A= readline_interactive_shell_result_function(=0A= function (string $code, $result) {=0A= // echo "Result of: " . trim($code) . "\n";=0A= echo json_encode($result) . "\n"; // or var_dump(), etc.=0A= });=0A= ```=0A= =0A= 1. Are there objections to adding this in 8.1 (after adding the described i= ni setting)?=0A= 2. Thoughts on the name? readline_interactive_shell_result_handler_function= probably makes more sense.=0A= https://www.php.net/manual/en/function.readline-completion-function.php= does something similar.=0A= =0A= The unit tests give an example of how this could be used.=0A= https://github.com/php/php-src/pull/5962/files#diff-153ee3f384d333904c50000= 33bee9803=0A= =0A= Thanks,=0A= - Tyson=