Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123307 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 0CA021A009C for ; Sat, 11 May 2024 08:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1715414820; bh=VPCQSSppMYQ6YwebyPQ49bBw/fvKVZ/MtVAnsnKfgsg=; h=Subject:To:References:From:Date:In-Reply-To:From; b=b5I1IKpuUa76Lmae0rIztm5aV1jTjeJ5LXp6B+z/EKfAhikqeeR5RcKC7u7fibPC2 Fg6i9+6jSoNEK3pR1a21OBJTC5OrbCDkCCXq9Gf+bJuKW8F4qsP3se6pSeN9L8O710 +ktBMYzbEcf5xqDKUeAD1qQPrbGNlit7YXXMg63J5UDmIWF9UK0BMk8dh0SpQaLfM0 Nu6bCQiSsC1yS41qP3qUQWt7xEFh4OE4WPG+yhI6+c4IK465D9IyLqrl25QhJNmmTV OB+QEsG9ZaGoIn+gbUBmsAr+L8QszPObCCM6FZMAy/CZUXsEmG13yM9R8rbQGOcsmI Td6eFh8VsmlTg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 25D7718005D for ; Sat, 11 May 2024 08:06:57 +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=1.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_20, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from slateblue.cherry.relay.mailchannels.net (slateblue.cherry.relay.mailchannels.net [23.83.223.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 11 May 2024 08:06:56 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 53E8E6C1CFC for ; Sat, 11 May 2024 08:06:05 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 456F16C1DED for ; Sat, 11 May 2024 08:06:04 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1715414764; a=rsa-sha256; cv=none; b=UalkQ07IfguzAcktNPRamxOcnWv9eHatfbqtEs6oHCGf5OFiUQGS6UajYq/ASfsDrhuKHN D6bhbv3DQOxb0dLlqejjA5mjEHNvCRhzioNOPgsSr8+ftltE7qRpmhS/zsAjYWMQ5jOgqW x6THMmZO8p9/smuD2TqpaLUbhMUi+IdF0g5kUhMEjrP+MlvpgCXIuYCeeZ6zI0pQ1KsaDK IwhrTPziIpiJOIbSvdgMmVmdra5zoUk3Wr/UsNZZgqLIJ5jVCJuI60RtIZJJ4p67ll0qFx 2NMamZhK454/Ym2FmSWOBvLtorKR4kAZsSG15ePBCNC6uiQhLiRlLJUxtFC5sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1715414764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1Z0vr+Q4NNbudiE1kNMSzXOFRiudTpt+3lBI4ZcZKys=; b=b4c03A5XBige+UgmUiH4i07RFEzHFlFerDZs+vWfMotZFPyjF6Sk1U/8/pXqEYsVZR9tNO cRgANzNNQAhgM6v91ZgJMdIqDR8AHb97XWGmZfWw0Vsj4vQ7nA8YFDwand1NJRmDI6uQxq VMvvQFsraB45+/6C3/NjJQ3zjMJY3zqz5bcm0CS5x2HUYrPrUqYNeS6E48SH/GtBEpIbdg suzAtCW70wK7x/tSIOk5kQS9BMuZ2+i3zERCOL2Sfmj+CSgEpGWCbYo+ecSgRXPZF6UPl4 w6E4+w2BX6uQRflWjc45pkhxi2hfuLhw5zEpbDdlfGDKobxpqXhLYvdaY1LM2w== ARC-Authentication-Results: i=1; rspamd-5d55749bb4-pwdvj; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Chief-Soft: 379280c27e72896c_1715414764832_503076721 X-MC-Loop-Signature: 1715414764832:1513352229 X-MC-Ingress-Time: 1715414764832 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.111.87.15 (trex/6.9.2); Sat, 11 May 2024 08:06:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1Z0vr+Q4NNbudiE1kNMSzXOFRiudTpt+3lBI4ZcZKys=; b=ewr8E04g3BfpLfViEjpiLuOe86 dWNojVdFNoGWrQim9HInlc4PstqghRqYHv3tmeULIcz8glAPT77rHl5rw3h3rLhEjS4Skr4ur3hTO XogdZih8a2gy8dAACOcpXnMwhH2hjwYC7wljM/fjVmkvlOgveyzwEiCfA6B3bWyUPHto=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.96.2) (envelope-from ) id 1s5hk2-00HDBH-1T for internals@lists.php.net; Sat, 11 May 2024 10:06:02 +0200 X-ImunifyEmail-Filter-Info: UkNWRF9WSUFfU01UUF9BVVRIIFJDVkRfVExTX0FMTCBWRVJJ TE9DS19 DQiBSQ1ZEX0NPVU5UX09ORSBCQVlFU19IQU0gTUlNRV9VTktOT1dOIE FSQ19OQSBNSURfUkhTX01BVENIX0ZST00gSUVfVkxfUEJMX0FDQ09VT lRfMDUgTUlNRV9UUkFDRSBGUk9NX0VRX0VOVkZST00gRlJPTV9IQVNf RE4gVE9fRE5fTk9ORSBSQ1BUX0NPVU5UX09ORSBJRV9WTF9QQkxfQUN DT1VOVF8wMSBUT19NQVRDSF9FTlZSQ1BUX0FMTCBfRFJVR1NfTU1fRE lTQ09VTlQgQVNO X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Score: 2.62 X-ImunifyEmail-Filter-Version: 3.5.13/202404301715 Received: from [143.178.147.245] (port=58647 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1s5hk5-00HD4c-0Q for internals@lists.php.net; Sat, 11 May 2024 10:06:02 +0200 Subject: Re: [PHP-DEV] [RFC] Transform exit() from a language construct into a standard function To: internals@lists.php.net References: Message-ID: <663F26E3.3070408@adviesenzo.nl> Date: Sat, 11 May 2024 10:05:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------020707080506090407020206" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------020707080506090407020206 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 8-5-2024 15:40, Gina P. Banyard wrote: > I would like to formally propose my idea for exit() as a function brought up to the list on 2024-02-24 [1] with the following RFC: > https://wiki.php.net/rfc/exit-as-function > > There have been some slight tweaks to the implementation, namely that the transformation from a "constant" to a function is done at compile time and we do not hook into the behaviour of constants any longer. No objections from my side, though, yes, PHPCS will need to be updated/adjusted to work around this, but that's no biggie. When reading the RFC, there are two things about which I still have questions. 1. As things are, `exit` and `die` cannot be used as a label for a goto statement. ```php goto exit; exit: echo 'exited'; ``` https://3v4l.org/fluuk and https://3v4l.org/cNMEW Will that change now `exit` would no longer be a reserved keyword ? 2. The RFC mentions the "old" semantics regarding type juggling for exit/die - always cast to string - and it mentions that passing resources or arrays in the new situation will become a TypeError, but that still leaves some room for interpretation for the other types, in particular the handling of booleans. How I read the RFC, the type juggling would change as follows (but I may well be wrong!): | Param passed | Old | New | Consequences | |-----------------------|---------|-----------|---------------------------------------------------------------------------------------------------------------| | integer | integer | integer | No change, interpreted as exit code | | string | string | string | No change, interpreted as status message | | bool | string | integer | Was status message, now exit code | | float | string | integer | Was status message, now exit code, "Implicit conversion from float to int loses precision" deprecation notice | | null | string | integer | Was status message, now exit code, "Passing null to parameter #1 ($status) of type string\|int is deprecated" | | stringable object | string | string | No change, interpreted as status message | | non-stringable object | string | TypeError | | | array | string | TypeError | | | resource | string | TypeError | | Might it be an idea to make all the type juggling changes explicit in the RFC ? (and correct whatever I interpreted incorrectly) Smile, Juliette --------------020707080506090407020206 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 8-5-2024 15:40, Gina P. Banyard wrote:
I would like to formally propose my idea for exit() as a function brought up to the list on 2024-02-24 [1] with the following RFC:
https://wiki.php.net/rfc/exit-as-function

There have been some slight tweaks to the implementation, namely that the transformation from a "constant" to a function is done at compile time and we do not hook into the behaviour of constants any longer.

No objections from my side, though, yes, PHPCS will need to be updated/adjusted to work around this, but that's no biggie.

When reading the RFC, there are two things about which I still have questions.

1. As things are, `exit` and `die` cannot be used as a label for a goto statement.

```php
goto exit;

exit:
  echo 'exited';
```
https://3v4l.org/fluuk and https://3v4l.org/cNMEW

Will that change now `exit` would no longer be a reserved keyword ?

2. The RFC mentions the "old" semantics regarding type juggling for exit/die - always cast to string - and it mentions that passing resources or arrays in the new situation will become a TypeError, but that still leaves some room for interpretation for the other types, in particular the handling of booleans.

How I read the RFC, the type juggling would change as follows (but I may well be wrong!):

| Param passed          | Old     | New       | Consequences                                                                                                  |

|-----------------------|---------|-----------|---------------------------------------------------------------------------------------------------------------|
| integer               | integer | integer   | No change, interpreted as exit code                                                                           |
| string                | string  | string    | No change, interpreted as status message                                                                      |
| bool                  | string  | integer   | Was status message, now exit code                                                                             |
| float                 | string  | integer   | Was status message, now exit code, "Implicit conversion from float to int loses precision" deprecation notice |
| null                  | string  | integer   | Was status message, now exit code, "Passing null to parameter #1 ($status) of type string\|int is deprecated" |
| stringable object     | string  | string    | No change, interpreted as status message                                                                      |
| non-stringable object | string  | TypeError |                                                                                                               |
| array                 | string  | TypeError |                                                                                                               |
| resource              | string  | TypeError |                                                                                                               |

Might it be an idea to make all the type juggling changes explicit in the RFC ? (and correct whatever I interpreted incorrectly)

Smile,
Juliette --------------020707080506090407020206--