Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:123440 php.internals:123441 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: by qa.php.net (Postfix, from userid 65534) id 651601A009D; Tue, 28 May 2024 07:02:22 +0000 (UTC) To: internals@lists.php.net,"Gina P. Banyard" , Message-ID: Date: Tue, 28 May 2024 10:02:22 +0300 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PHP-DEV] [RFC] Transform exit() from a language construct into a standard function PHP internals References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 90.135.122.248 From: webmaster@daikaras.lt (Daikaras) On 2024.05.08 16:40, Gina P. Banyard wrote: > Hello Internals, > > 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. > > Let me know what you think. > > Best regards, > > Gina P. Banyard > > [1] https://externals.io/message/122483 I don't quite get the reasoning behind this change. `exit` behavior is not consistent with functions because it is not a function. But it is consistent with other constructs like `echo`. Or am I wrong? I'm all for stricter typing but not at a cost of reliability. `exit` IMO should always terminate script, no exceptions (no pun intended :)). Otherwise, it may have security implications in some codebases, as Saki pointed out. So I'd rather go the other way and have it error fatally like for example `break` does when passed non-integers. And on the same note maybe syntax could be improved to *not* require parentheses when passing the code (so `exit 0;` would be valid code) since this seems to be the cause of the confusion. Just my 2c. p.s. In B/C table you should mention that passing Stringable objects will throw TypeError when `strict_types` is enabled.