Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126008 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 4690E1A00BD for ; Wed, 20 Nov 2024 19:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732129868; bh=St/05SA3nyZdze+ZeT676+QGq9J8L2A0eldxu+qYR+0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Xmj/n0IvWy+2Eg5aml20C1mEWhOm8Dpf7r97Tu72l4IJ1VH2EiP+5fbYleN+JXW9e +vy5Hm2/s/+8wtKMvF/uc7URZkbBFUulL1qwBpuMzzc2uprz2T1IeN9MAwgY0DCsob pxBhcoCFhKeMerkHsKECQrSkZ/qrljRI5hSV+ykaQzARGlOj65+v5y7G6km7JYVfCa d6hYdI8JdXTe1u74vfTGd5oHTX2YnHKQsKmSXZtlxOFJLXmUAvhBPJAlwDZ7uTSR07 +JPX+6gh0mHgiQPLZIto/YtjFeldKobxgczeIKZeNOD/xBvjZH/KEce3gur+khST61 jL/JakDKZ++SQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6D56B18069B for ; Wed, 20 Nov 2024 19:11:07 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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, 20 Nov 2024 19:11:06 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-382423e1f7aso16197f8f.2 for ; Wed, 20 Nov 2024 11:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732129706; x=1732734506; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=Rp0xwhLQxtfR8CA2JZjt2LtLq0vIToY/epDtPQlFUI4=; b=KzCwnUk6ZaZqiGskNvnp1rCTsuFOwyrhpHsxdWLHw4W5QM4KYHYq759TG6ibrbEluB XHRIZvVRhnXZF2eVYu808WmksmT52J3Pl7HrsGYHUvm/v5e90eKk5D6RRPvhCKEepb2z mi5yM05rWSukcjr1Icq4VWU7pjnU7/YdiIuZ8tSzXiIzTV7AiGnJgXJIPjoOBSdkgK5M xdr8n5Xz8wblkeZvO///hZr2H4o8E9bV/+0m2Sheevy7YsOmYBnaV+YHrbd2JBmSnYel azs3SNxegFbPY9NGIMOlFS6cfnDaeF5M6EaGCeWHJZWyk3OtTSa14Fq8MS3rB4lfYjYw B2MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732129706; x=1732734506; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Rp0xwhLQxtfR8CA2JZjt2LtLq0vIToY/epDtPQlFUI4=; b=EPEf4LwtBfKWRaIIc3cxDSDqS31h8MTDKCC1BdmPLL8Cp9UxdsBt1oEDOdSipmUR8A RkJIgeGOQRy51GyWCt2ZJ2uwZkQwiovwnZkTrZSG8/7aFiim9vgfAldz75g6HJsplrei 71Kx1lFkWFiarHpgLloXGS98Vq/KJpI9rcCd+dTRDaUpv0vWejqC797PhzXE7sThxsWx h6a3G+ebt0UPSaXCp8nDIwerLfQXYelT/j5m5rczZF/M5lpyKUXNFNKI9QPanhczsU/t aJgTWw6c+m8Dnr2Cm7yM9yRAxptE/tmb6zgMt3u1LX4I9j52IE8aPp50DJV+wTXwCYk9 YKwA== X-Gm-Message-State: AOJu0Yx6wEe6tb7F9WIxLX8Dc1OeSP57w8rGVRrnuue8hagJHvAxuCYk qFq1AveREsD7JMvfZo0hQLuTkuGsIXqHO5LKCWaKf19bO0I1+wFv8YJhyA== X-Google-Smtp-Source: AGHT+IFHD86Vt66Vn7zEk7iw67Gs5Uw9MRQi9n1yW4VTFkqS6GtaTj/T0/bDw5knZT53rso2DrgR0Q== X-Received: by 2002:a5d:5f52:0:b0:382:47d0:64be with SMTP id ffacd0b85a97d-38254afc606mr2831589f8f.29.1732129705769; Wed, 20 Nov 2024 11:08:25 -0800 (PST) Received: from ?IPV6:2a02:1811:cd2f:3500:e093:fcad:4f6:e542? (ptr-du5vm7f5ekzptmf0fgi.18120a2.ip6.access.telenet.be. [2a02:1811:cd2f:3500:e093:fcad:4f6:e542]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382549052c0sm2906320f8f.7.2024.11.20.11.08.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Nov 2024 11:08:25 -0800 (PST) Message-ID: <8a3d0eeb-3e07-4181-9452-4a0550ecd375@gmail.com> Date: Wed, 20 Nov 2024 20:09:14 +0100 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] Deprecate alternate switch case syntax? To: internals@lists.php.net References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit From: dossche.niels@gmail.com (Niels Dossche) On 20/11/2024 15:45, Theodore Brown wrote: > Hello Internals, > > I recently found out (after 15 years of being a PHP developer) that PHP allows using a semicolon rather than a colon after case statements. [1] I.e.: > > switch ($value) { > case 'foo'; > case 'bar': > case 'baz'; > echo 'foo, bar, or baz'; > break; > default; > echo 'Other'; > } > > Apparently this syntax has been allowed since at least the PHP 4 days, but very few developers know about it. > > I ran a script on the top 1000 Composer packages to gauge usage, and out of 35,777 total case statements, only 15 in two packages used the alternate syntax. All were accidental typos (randomly mixed in with statements using the normal syntax), and I opened pull requests to fix both (the first has already been merged): > > - https://github.com/reactphp/promise/pull/264 > - https://www.drupal.org/project/drupal/issues/3486526 > > Would it be worthwhile for me to write an RFC to propose deprecating the alternate switch case syntax in PHP 8.5? > > The main reason for deprecation/removal it is that it causes confusion. A developer may think the alternate syntax behaves differently in some way from a regular case statement (e.g. preventing fallthrough or something), when it actually does not. > > Best regards, > Theodore > > Note: The normal case syntax has been part of the PSR-2 coding style since 2012, and PHP-CS-Fixer automatically fixes usages of the non-standard syntax when using the @PSR2 or newer @PER-CS rulesets. > > [1]: https://github.com/php/php-src/issues/15258 Hi I'm not convinced that getting rid of this is a good idea. It doesn't seem to cause real harm and as Kamil/cmb pointed out there was a legit reason to have this. So I'm not in favor of deprecating this. Kind regards Niels