Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124818 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id CB61A1A00B7 for ; Wed, 7 Aug 2024 00:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722989062; bh=HRY5k+OLbiRBhUdc0ru8nUBOGJQRhUMmUy/vV+v0rtQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bMBr8btkHCJwif5a9L61ofbJXe68NKyn0jTfchmbr2j09tG9Ux549mh/BG10df4Bd fyBVgUR94TFILZxjLcAH3zi8fTPWkozD9x6jqPO2J92HE40WNhY2jcFmv9zzyDSDvp hs02rZtdJeXThKAwNimR/WGL0D0gFOIBqoNPxJJS/b/mTiuFy4KjsbZ39a3YDZePya JahjDP+gzgMBGnP0sxMewhElF6HvVMxuVdmkkoXB3mjXbZZ4g7EFOCkRXfBRzR42nS alp3oZz7XzjVVOJ+S1QXutZ8E6akPzu53xtXrzjDbpbMd4bOLrpsYJKmxd3PABacnh nPDR8Z0IK8jKA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 96480180055; Wed, 7 Aug 2024 00:04:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS; Wed, 7 Aug 2024 00:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1722988954; x=1723593754; i=cmbecker69@gmx.de; bh=jfLAc6W/mx/i2BsoSjWRl+t/9H3P7q/QqsiM1xkLUVo=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=gB916yZAgtBtcKLVEkWIbSSJHYHm8mztx+tl3wm3yATYYCQUfo03HDeo1qPBdybw 2vHAqMpWEYBKzZQccselFjvmJIQyMVcEVEmwBTXLKiph/mIc6sqiqKkFCUHMpxpFm +0//Kt12m5GQMedpjQ61LxAwl6RMXSJJVxhn+sTnOEc9GneVlZ+gMsQLKzWlO1mY7 6NEeGajzA3UmeSQXkQzawhXIeMUnp0A78KAiNSjdaocLlHXPqw7yEkzheDn5VX7Fp ISOWemx0nusMLznOh18Ez7OIjcqN4e/OrUDDQJKHxhDgon7oB5TUYCHtfU88I8YR2 9PcOuJHUoKAvhIaz2w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.2.130] ([79.251.205.37]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWics-1si5rO0tJ2-00O5yX; Wed, 07 Aug 2024 02:02:34 +0200 Message-ID: Date: Wed, 7 Aug 2024 02:02:34 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] [VOTE] Transform exit() from a languageconstructinto a standard function Content-Language: de-DE To: "Gina P. Banyard" Cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , Derick Rethans , PHP internals References: <15bb76a0-cbd7-4145-b429-76d424755106@gmx.de> <1a8650d2-7eb5-d645-8132-e5522ad24637@php.net> <06ba1d82-6387-46ac-8be3-1d3472993e1a@gmx.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:W7ivNQxnU97mdb0vIK7ecY5R1123U34wOoxr2vMb1zB7mBt0wrB NMW9cyR+dbxYrHXs7y8/RL6Dxf0eqffVAh/3wufrpMK4jpOQ1WYMhRpdB+gcbrM+CvqV3vT d5CYHW2Uz4vVthJVzjRffS+kpKjRxnhAg5bG1RqFPBj9fbMZRZV74jVLzgAbejcXo8nugvp 33tJfHDRU53M/G0X01F/Q== UI-OutboundReport: notjunk:1;M01:P0:5RrIMyu4YHE=;uobzyvXIGM0F/20Ro2tfaFPRb/w V3lA5OJfqh9TJfdTJ3ASYMOGUpO5VDdPm2xX0G82RNT/1CxgR2PBNaZwl/JHxTYLg2G4SH58J a9UqCsNl1CuUcqZpXwFwS2F5WJC6ARzllZ+uQ76D/EQ2p3LnvloqSNKbYsOxB4UKhpjRacIqI 8p4BnRhQVhtjhrtZrqXNR2o7dVjXFrFi639cqTtJ3LWyiq4uHWTDnIVJWKqmz1FMyalTka15i 2jHi/abAq3QprXez5m3BptfSW3mUh1qZRv/2W9thmkTyzKhbhviC1p4srrivNRq15Ph89SWeu hw9GdjRotGnJ07c3sXfKd0GdIfXxtCJmh8UlyK0T2C5iAEBssxr5Fy35axzixndx6fRUUdZXX F0VJUiGpduM8aYzsRUYAy2L9wxLrW98QtZAM8qJqIYwXiJaQ7Kk2sLMhYMgFdcJo2csbGiHuh z8ifLuoK4u0MkxDpepXfODm/gEzMd4OFAV79oPNga8lwYA8J33nVKLMZc+B+J9T5vhzMSMgAf RXkTMGrrPU+vF1XlZAAl/QYiAh9QE58yRW+yHsry4uqWRLt0G7g/na5i/UHlMvJZVrejxwkIR rjKgMaxrH0XOlQa9cKxQO11p5l4oSrhq6exycd/JHQQj5pSNw5xNT1HoJGfCW0rJM7HXhgMq9 Zvz+5rR8T5lXa7D2oDEPJz73bXgMF3aWSg04InuScV25fbO71lY1vLAytQ9guxRPyenKIUvNb xyT2TVsLipS39ggNqfuXW9YIlHDR+ZZOfxnsgDW6EOA8qdrzU223vxf7Dje6a1UKuFLexvIBJ a87s/n13iMDiVzOljdzhvykQ== From: cmbecker69@gmx.de ("Christoph M. Becker") On 06.08.2024 at 21:07, Gina P. Banyard wrote: > On Monday, 5 August 2024 at 23:55, Christoph M. Becker wrote: > >> Most likely, yes, although still somebody has to provide a fix, and >> someone has to do a new release. > > Why should I investigate time to fix extensions when this RFC might not = even land in the first place? I do not expect anybody who makes approved changes to the APIs to provide fixes for any of the affected external extensions. It's great if they help when asked, and it's okay if they don't. I merely noted that someone has to make these changes to keep these extensions up-to-date for new PHP releases. And sometimes real life interferes for the maintainers, so they don't have time (due to other interests, health issues, a new job, family, etc.) And even if others would like to help out, sometimes they can't[1]. > We do countless engine breaking changes without RFCs and without notices= to extension maintainers other than UPGRADING.INTERNALS. That is exactly my point: we should weight the pros and cons of any API change carefully. How many extensions may be affected, how hard would it be to update these extensions, how ugly would the resulting code be due to PHP_VERSION_ID checks, etc. And on the other hand, what would be the benefits for the whole ecosystem (php-src, extensions, userland developers). > Could we maybe start respecting the intelligence of extension developers= ? > And if not, can we stop pretending that we care about them when we, as a= project, clearly don't seem to care in our actual action? We should not fall into the trap of thinking: we did more seriously breaking changes in the past, so we don't need to care anymore. After all, we cannot change what had happened, but we may be able to improve. >> So we can now write `exit(status =3D 1)` or `exit(status =3D "some erro= r message`). I don't see any improvement using named arguments for a >> single argument function (maybe unless it is a boolean argument). And >> for a string argument, I don't think that `status` is a sensible >> parameter name here. > > Please propose a better name then. That's the crux with some of the union types for legacy functions: there are no suitable names. setcookie() has an $expires_or_options parameter, so we might choose $status_or_message here, and although that seems to be more correct, it would be ridiculous to use this as named argument. (For the record: I've got the syntax wrong, because I don't use named arguments, since these are fixing the symptoms, not the desease, which is a bad API.) >> That might be a nice feature, but at least I have never seen the need t= o >> pass `exit` as callable. And it wouldn't be hard to define a wrapper >> function (e.g. `my_exit()`) if someone really needs to pass it as a >> callable. > > The fact that one might need to do this workaround is bad already, and n= ot a justification against this RFC. The fact that one might need to pass `exit` implies that they are using some test helper extension (e.g. uopz) to stub/mock it, or that they should consider to consult a therapist. ;) >> That might be an issue (although I've never stumbled upon that), but >> it seems to me that this could even be handled in the ZEND_EXIT handler= . > > Now see this is strange to me, as I clearly remember hitting this issue = while working on a QA scrip for the PHP documentation, > was not understanding why CI was failing with no output, > until you realised that the issue was me passing a boolean to exit() tha= t was being cast to a string and not the expected integer. I have completely forgotten about this, and cannot really remember even no= w. > So I would argue you have stumbled upon this. I stand corrected. However, that doesn't invalidate my argument that at least some sanity could be introduced in the ZEND_EXIT handler instead of pursuing the RFC at hand. >> It still can be called without parentheses, so I don't regard it as a >> proper function. It might even be confusing to readers ("oh, now I >> can call a function without arguments by omitting the parentheses =E2= =80=93 but >> why doesn't it work for other functions?"). And the PHP manual even >> states (emphasis mine): >> >> | exit is a language construct and it can be called without >> | parentheses if no status is passed. > > Since when has the documentation been the normative aspect of PHP? > We routinely fix the documentation to explain the Zend engine's true beh= aviour, even if it doesn't make any sense. > > This sentence is true as of now, and may be changed if this RFC passes. > Using current wording on the documentation is.... a strange argument to = me. Fair enough. So just ignore that last part, but what about: It still can be called without parentheses, so I don't regard it as a proper function. It might even be confusing to readers ("oh, now I can call a function without arguments by omitting the parentheses =E2=80= =93 but why doesn't it work for other functions?"). Anyhow, perhaps an alternative to the proposal at hand would be to implement the following proper function in the core: function quit(int $status =3D 0) { exit($status); } Users who wish to have something like die("message"), could use it, or echo "message"; quit() Or perhaps that could be a set of quit functions; the main point is not to *change* anything in the core (for now), but still allowing users to *opt into* some cleaner functionality. [1] Cheers, Christoph