Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112729 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89331 invoked from network); 3 Jan 2021 16:35:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2021 16:35:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 61C901804C6 for ; Sun, 3 Jan 2021 08:11:38 -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=0.8 required=5.0 tests=BAYES_50,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 NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2028.outbound.protection.outlook.com [40.92.41.28]) (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, 3 Jan 2021 08:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ICiASNsmrSLiVSQPcfyntlQWHzyikZoUie2xR9UjMrQA9ljv+2PloYkVioOGbf5HC67cdSnOUjWRPkM1AFlk0PscsPFuQwxz1NaNnfXIioR19HzQXYmLFaRDFBrQst010RCSMHcX6ic8tXQkqJ3KhAtSTTvXzgxhg5VddPyc8jcduor2+956wZYRsq/MpFe6VqloLGmqtXzuNoVvQXqeBAlXU0GGmeaC5CvkFGQEpMgL22/+i3eoPJ1+jHkeoslxxy3nwh4X/R2CX1uZredvD6q0ukxAPEbHcpZCGoX/eVE4mj+10H+oF0N5K6y648wi9+k8BpeRJEds/XwStiP/eg== 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=xpXfEkazFHqZ7ViVPRnCZTtsA88hXBP7mEoNfYwx2lQ=; b=l/P+DAWXhSd+A5j11ReLAtgCrTUx5Vgt4suLUY8VlFw4YHuZKOwVXUCM+YguzC/4M3d77f6AhqPmXfJL8d/bAXHGhd2YplHRFBbiwT4g4eLQOI8fn29szH+Kn6ye+Yk523uQnzNqDYgDchlyEFtM8Wc3oOcHeaeaXywKZLtDb3QdDrFq+ViHmDtCNHVG8W8qbNzUASi/jO4t5dnPRTCtikFH3eGefUMl7TTFfRVHgh3mYb2y72VJKcBUFkvKK97QhwhgFsUWbfqFz0JsMIMXuC2BItrVwNfeMqRfmcEjUvzZKCdhWvlK2Vtz+/RjuSL/C9N6pgGwzIfhV19bt3eh0A== 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=xpXfEkazFHqZ7ViVPRnCZTtsA88hXBP7mEoNfYwx2lQ=; b=qEsm1KPzSJcINQH4QlHSH8iLd63poryC8WthX9H1opbknu5Sw/ZaHD5Lc+l4xGnSQmSq8Auk3brMjEUZEGa+vbDcMspfLy29pTpKStTpmZFAhe1mVj98d34/tRF1h28tr/kWNs4JROo/j9cibsCZ6WAazK+BIaWO/v+xJlv4TfzGkNzT2HGskkv2JHy9j2LsM+T1tWf7mz1JHaZaqLAqy+6XoAm9afrm18wEpfbSrallOzjlpaUBMfb8xl4gQKVv2kGADDDrjjy85pEI4UQvf1LKLN+j1qjNPudRIqfCZXhQwppHCNV4gCBR2naren+6nmLchb41mEc0K8kix+/Yhg== Received: from BN7NAM10FT050.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::41) by BN7NAM10HT183.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::465) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20; Sun, 3 Jan 2021 16:11:35 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e8f::53) by BN7NAM10FT050.mail.protection.outlook.com (2a01:111:e400:7e8f::284) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Sun, 3 Jan 2021 16:11:35 +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.3721.024; Sun, 3 Jan 2021 16:11:35 +0000 To: Nikita Popov CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a` Thread-Index: AQHW1x7Yg3FUP/hma0qSEEKC7GDKEqoVDKsAgAAh0os= Date: Sun, 3 Jan 2021 16:11:35 +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:5D9FD00C479C456774BA1AA76B947626ACDF7B970096DCAD768407BC67343036;UpperCasedChecksum:25C732BD5BEEE798A7BDB26B81730E93424CE9871D7B6EB54A2ECDED583A0B67;SizeAsReceived:7094;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [2iPf8w2odrRjpYLSsnpsY6ecoBi8ZaNjgzMgwdG6iWw=] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: fea25d54-69a7-4bb5-ea19-08d8b0023e70 x-ms-traffictypediagnostic: BN7NAM10HT183: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VsgyEAxDEnt8OniIso4spiGJxKW2tfi5wwz5qEriSAJVum6R389UjOGARvRi2ovYiERf9rw8ItYf95tt8LP700lh+lOe6hCcfuMEJaQV74vpQ9/UsYGYUMZIRubDcqJiZ9dWnAt57IId652ihyKsAhYQ9bD30f4RBEeYhDRbhWjDl8oxftuPGB0PoJRiamkDaSuG4bjtnh6yjC9ynEsgF52hmHrYTFzJBSzuEdCrJAomtgGyuhWQ8hANo27BBXFLlA3sBWrJ99q8oDARVqb389q2k/aifBKRZ4JQewISqPE= x-ms-exchange-antispam-messagedata: 3yUADXa1GxITmY7bdmXTOccVPCww74sepiNtkjljw2eLGouCm/6laAAZrcPSNJIyxvhLkpC8J2uwz9nEA1qqxBo53FaFRNkQhgC6EGnN3QXt4kJq4n5/ta/eqmF0pXeZK88fabNqKYm5PgIPhKV1Xw== 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: BN7NAM10FT050.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: fea25d54-69a7-4bb5-ea19-08d8b0023e70 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jan 2021 16:11:35.5756 (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: BN7NAM10HT183 Subject: Re: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a` From: tysonandre775@hotmail.com (tyson andre) > Reading through the linked earlier mail, you have quite a few additional = hooks in mind, which might need a significant amount of additional userland= code (such as a parser implementation) to usefully implement. At that poin= t I'm wondering what the benefit of this hybrid approach is, relatively to = a userland implementation like psysh.=0A= >=0A= > That is: =0A= > a) Assuming all the hooks have been implemented, what additional function= ality is the interactive shell implementation itself actually providing?=0A= > b) Is it possible to go the other way around, and expose that additional = functionality to userland instead? You do mention fatal error tolerance as = one distinguishing feature -- is there anything beyond that?=0A= =0A= For https://wiki.php.net/rfc/readline_interactive_shell_result_function in = particular,=0A= compared to `php -a` in php 8.0, a subsequent RFC would provide additional = functionality using these hooks: it would add default hooks to print a shor= t representation of results of expressions to the interactive shell impleme= ntation (that could be turned off or replaced to dump objects)=0A= =0A= - The benefit is that dumping the result of expressions improves the defaul= t experience.=0A= psysh wouldn't be installed by default when a new developer is learning p= hp through the php manual, or when sshed into a remote server.=0A= - The reason to allow hooking it is because some objects wouldn't have a us= er-friendly representation for var_dump/var_export (e.g. recursive data str= uctures)=0A= - Even if the code size is large, it may be doable by making the userland i= mplementation part of ext/phpi/ (--enable-phpi), which is disabled by defau= lt and can be installed in separate packages created by operating system pa= ckage maintainers (and shrunk by using minifiers)=0A= =0A= Compared to psysh, the main distinguishing feature is definitely the abilit= y to detect/tolerate fatal errors when compiling snippets or inheriting cla= sses, and fewer dependencies to include to integrate an interactive shell w= ith utilities for a project.=0A= I don't think it should be exposed to regular processes or web servers, tho= ugh, due to possible memory corruption or leaks after zend_error_noreturn (= e.g. class inheritance errors after autoloading), etc.).=0A= =0A= - It would possibly be an improvement to throw an error instead of causing = a fatal error for common mistakes in interactive shell sessions such as dup= licate functions/parameters but I'm not sure how likely that is, especially= since classes and functions currently get added as the file is being compi= led.=0A= =0A= Integrating userland shells like `psysh` deeply into `php -a` may wish to a= void readline entirely and call a callback instead of printing `php>` and d= irectly processing input like those projects already do.=0A= Two hooks may help with enabling that approach, which can be added in `auto= _prepend_file`=0A= =0A= 1. A hook to call a callback instead of printing "php >" and C readline rea= ding stdin.=0A= e.g. `readline_replace_interactive_shell_initializer(function () { ... = read and process stdin in a loop })`=0A= 2. Adding a hook to call a function every time an uncatchable fatal error w= as encountered, e.g. to resume the userland shell.=0A= e.g. `readline_replace_interactive_fatal_error_handler(function ($errco= de, $errmsg, $file, $line, $errcount): bool { /* process or exit */ })`=0A= =0A= Thanks,=0A= - Tyson=