Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128843 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 lists.php.net (Postfix) with ESMTPS id BB5BD1A00BC for ; Wed, 15 Oct 2025 13:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1760533867; bh=msmREIkp54TJDpOiBG+hVoXYdtLfQvo8axmOXapTycI=; h=Subject:To:References:From:Date:In-Reply-To:From; b=RuBBhosvRlDHtI80Kv12vV6shy49+7nYaMXPLmn6FOD3NI8o1mO4cjtyfpm5/btrW YDHXuEDgoVFaASWw9jU00Jdanuy3GEwJJXSKgVgRX2C+wxnlwTEKO4zGtiOX7P1k5a 1flixHduBPp/Ynu9HnNJLNAWxW7QLPL2Xaa+ndEinyy8g4yoMFK/3Csrwvc+rC4Awg ZnuI45x3SG/om8XklmC1yoWShwQD3EQCR8eNAnYGUb1wzgQHZrZ292VyBGDBgLQdW/ u9mWEpe/Cxbrrns76P5BN96unf9yYdps5vYD2vLD15TgSkHShKaGpiOg0o2iwQH/I2 agxI0XCWQ00Cg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3A502180062 for ; Wed, 15 Oct 2025 13:11:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_05, 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 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from gecko.ash.relay.mailchannels.net (gecko.ash.relay.mailchannels.net [23.83.222.66]) (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 ; Wed, 15 Oct 2025 13:11:05 +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 EA955100FC3 for ; Wed, 15 Oct 2025 13:10:58 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (trex-green-1.trex.outbound.svc.cluster.local [100.117.100.119]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 38834100E3F for ; Wed, 15 Oct 2025 13:10:58 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1760533858; a=rsa-sha256; cv=none; b=maT+fHTQSJOYVxBMidou0A73tWkZp1u/A4tbl6x+qwjf9jACDtjw9TIPx+xtHQdeAQBr8j qDtgALObFTQ2Zpf/DtNSmlEn6uIB7CHlHEXcqecbBxl8JR65lsitT2qM+KN7hVpLrv6npu LOLYCIhy6aVmpALDEA+KJgmQHanlrbQoloeCSdsJ7gjg5+KhnW954YXyk1uTJXwSTPusG7 7NjeUXXaeDRzdudtqEt6XntYl9pGwpkCryFyl10qyTJNzvwtEP9L3H91uNV58oQ6o6F+N6 +mcJVahRjSPsZVpGPv/qZpZnWUqHrXVUKILYY83ZquLrOQ9xmgd8Jw1tb4K7zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1760533858; 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=zqDDnmYgJnMzemTR2zo/6tbzONVumDFhsNHrtxpbrFU=; b=bupT4ohlQq2CFgGen0PlS6ybEzGzlvNlENdrRUIgxVMvBkzV4LMBHR8o0Pjme8g5tOjLQl BRvHIfXiV3NwbN+K+OmcU2n+xefLmm4NUI++HYIGroYhz6D0QvMJyJcbFuZNMJgLC/mpUh Rg3eqPqKDPVPCqjZAWdAqSx1xakQcO5a96ZxIJWki3JWimVom+YoKc4nlQy4Hu5qB7R2fV Aw+mKDf1xWdMfiMsYNrbon6jJWtcc0qzLTiBk1lJIgUnD9jrwLj+WBbea3RPU4fYOEhOhF fGkH0J05b1xyJO5gfxzZnRLr8CQHKA1Jf0un1hqu085uhLG3sE5fh2qUQ7L0iw== ARC-Authentication-Results: i=1; rspamd-668c7f7ff9-9lrs9; 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-Duck-White: 5d0ae3154a25d971_1760533858580_2670491460 X-MC-Loop-Signature: 1760533858580:1745892298 X-MC-Ingress-Time: 1760533858580 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.117.100.119 (trex/7.1.3); Wed, 15 Oct 2025 13:10:58 +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=zqDDnmYgJnMzemTR2zo/6tbzONVumDFhsNHrtxpbrFU=; b=ffMM8WH3e1jk5i/AH2fQcW4JTl WT+ePOzrd9DgB9KTvLYfsdkrRJ1xrsb1kC5ZKYQWAcyXKgIywQc8++//dDy0QPse1eOu0VCukaNXS 4FqP251efAiqLbwjsHjG5AULcQCu11XIMrWPGwl6uBNQhy6yp9nyA+FvQOioi0eGsYVM=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.98.2) (envelope-from ) id 1v91HM-00000000IMj-1VIR for internals@lists.php.net; Wed, 15 Oct 2025 15:10:56 +0200 X-ImunifyEmail-Filter-Info: SUVfVkxfU1BCTF9BQ0NPVU5UXzk1IElFX1ZMX1BCTF9FTUFJ TF8wMSB BUkNfTkEgSUVfVkxfU1BCTF9BQ0NPVU5UXzIwIEFTTiBNSU1FX1RSQU NFIFJDUFRfQ09VTlRfVFdPIElFX1ZMX1NQQkxfQUNDT1VOVF8wNSBCQ VlFU19IQU0gUkNWRF9DT1VOVF9PTkUgRlJPTV9IQVNfRE4gSUVfVkxf U1BCTF9BQ0NPVU5UXzUwIE1JTUVfVU5LTk9XTiBUT19ETl9BTEwgSUV fVkxfUEJMX0FDQ09VTlRfMjAgSUVfVkxfU1BCTF9BQ0NPVU5UXzAxIE ZST01fRVFfRU5WRlJPTSBUT19NQVRDSF9FTlZSQ1BUX1NPTUUgSUVfV kxfUEJMX0VNQUlMXzA1IFZFUklMT0NLX0NCIElFX1ZMX1BCTF9BQ0NP VU5UXzA1IFJDVkRfVExTX0FMTCBJRV9WTF9QQkxfRE9NQUlOXzA1IEl FX1ZMX1NQQkxfQUNDT1VOVF84MCBSQ1ZEX1ZJQV9TTVRQX0FVVEggSU VfVkxfUEJMX0FDQ09VTlRfMDEgSUVfVkxfUEJMX0RPTUFJTl8wMSBJR V9WTF9TUEJMX0FDQ09VTlRfOTkgTUlEX1JIU19NQVRDSF9GUk9N X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Version: 3.8.18/202510080919 X-ImunifyEmail-Filter-Score: 0.42 Received: from [31.201.40.213] (port=59308 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.98.2) (envelope-from ) id 1v91HM-00000000I9T-3ri6; Wed, 15 Oct 2025 15:10:56 +0200 Subject: Re: [PHP-DEV] Re: Inconsistency in PHP 8.5 deprecation of terminating case with semicolon To: Theodore Brown , PHP internals References: <68EEE5F4.5070105@adviesenzo.nl> Message-ID: <68EF9D5D.2030806@adviesenzo.nl> Date: Wed, 15 Oct 2025 15:10:53 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------090809080707020009070507" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------090809080707020009070507 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 15-10-2025 6:21, Theodore Brown wrote: > On Tue, October 14 2025 at 18:08 Juliette Reinders Folmer wrote: > >> Dear Theodore and list, >> >> I've been looking into the "Deprecate semicolon after case in switch statement" PHP 8.5 deprecation [1] >> with the aim of adding a sniff for this to the PHPCompatibility standard and I'm noticing an oddity for >> which I would like to clarify whether this is intentional or an oversight. >> >> As demonstrated in the example code provided in the deprecation RFC, both switch `case` condition >> statements, as well as `default` statements, can be ended with a semicolon. >> >> So when I first read the RFC, I interpreted the proposal to include both `case` as well as `default`, >> as, in my mind, `default` is just a special `case` in a switch. >> >> However, the RFC explicitly only talked about deprecating the use of a semicolon after a >> `case` statement and the implementation has followed this to the letter. [2] >> >> The net result of this, is that you can now have a `switch` statement with semicolons >> terminating `case` statements and `default` statements, where the former (`case`) will >> result in a deprecation notice, while the latter (`default`) will not. For an example, see [3] >> >> This feels inconsistent to me and counter to the intention of the RFC, which is stated to be: >> >>> Case statements followed by a semicolon can cause confusion, as a developer may think they >>> behave differently in some way from regular case statements (e.g. preventing fallthrough), >>> when they do not. >> Which leaves me wondering what the reason was not to _also_ deprecate the use of a semicolon >> to terminate a `default` statement in a switch ? I can't find any discussion about this in the >> original mailing list thread [4]. >> >> Anyone would care to clarify ? > Hi Juliette, > > Thank you for pointing out the discrepancy. You are correct that `default` is just a special > case statement, and the intention in the RFC was to output the deprecation message for default cases > as well (the example in the RFC included a default case followed by a semicolon to highlight this). > > The fact that a deprecation message isn't shown for default cases is an oversight on my part > when I implemented the RFC. The merged implementation correctly updated the AST for default > case statements followed by a semicolon to support the deprecation message, but I failed to > notice that when the compiler code loops over switch cases, there is a `continue` statement > when handling the default case which prevents reaching the code for the deprecation. > > I opened a follow-up pull request to fix this, which can hopefully be merged before > PHP 8.5 is released: https://github.com/php/php-src/pull/20172 Hi Theodore, Ah! That explains it. Bugs happen to the best of us. Glad to hear I didn't misunderstand the intention of the RFC. Thanks for clarifying and for the new PR to update the deprecation implementation. Here's me hoping it will be merged soon. Smile, Juliette --------------090809080707020009070507 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On 15-10-2025 6:21, Theodore Brown wrote:
On Tue, October 14 2025 at 18:08 Juliette Reinders Folmer wrote:

Dear Theodore and list,

I've been looking into the "Deprecate semicolon after case in switch statement" PHP 8.5 deprecation [1]
with the aim of adding a sniff for this to the PHPCompatibility standard and I'm noticing an oddity for
which I would like to clarify whether this is intentional or an oversight.

As demonstrated in the example code provided in the deprecation RFC, both switch `case` condition
statements, as well as `default` statements, can be ended with a semicolon.

So when I first read the RFC, I interpreted the proposal to include both `case` as well as `default`,
as, in my mind, `default` is just a special `case` in a switch.

However, the RFC explicitly only talked about deprecating the use of a semicolon after a
`case` statement and the implementation has followed this to the letter. [2]

The net result of this, is that you can now have a `switch` statement with semicolons
terminating `case` statements and `default` statements, where the former (`case`) will
result in a deprecation notice, while the latter (`default`) will not. For an example, see [3]

This feels inconsistent to me and counter to the intention of the RFC, which is stated to be:

Case statements followed by a semicolon can cause confusion, as a developer may think they
behave differently in some way from regular case statements (e.g. preventing fallthrough),
when they do not.
Which leaves me wondering what the reason was not to _also_ deprecate the use of a semicolon
to terminate a `default` statement in a switch ? I can't find any discussion about this in the
original mailing list thread [4].

Anyone would care to clarify ?
Hi Juliette,

Thank you for pointing out the discrepancy. You are correct that `default` is just a special
case statement, and the intention in the RFC was to output the deprecation message for default cases
as well (the example in the RFC included a default case followed by a semicolon to highlight this).

The fact that a deprecation message isn't shown for default cases is an oversight on my part
when I implemented the RFC. The merged implementation correctly updated the AST for default
case statements followed by a semicolon to support the deprecation message, but I failed to
notice that when the compiler code loops over switch cases, there is a `continue` statement
when handling the default case which prevents reaching the code for the deprecation.

I opened a follow-up pull request to fix this, which can hopefully be merged before
PHP 8.5 is released: https://github.com/php/php-src/pull/20172

Hi Theodore,

Ah! That explains it. Bugs happen to the best of us. Glad to hear I didn't misunderstand the intention of the RFC.

Thanks for clarifying and for the new PR to update the deprecation implementation. Here's me hoping it will be merged soon.

Smile,
Juliette




--------------090809080707020009070507--