Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119311 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59883 invoked from network); 18 Jan 2023 15:20:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2023 15:20:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7E03618054D for ; Wed, 18 Jan 2023 07:20:19 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS30827 82.113.144.0/20 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) by php-smtp4.php.net (Postfix) with ESMTP for ; Wed, 18 Jan 2023 07:20:19 -0800 (PST) Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 9AF4610C3A9; Wed, 18 Jan 2023 15:20:18 +0000 (GMT) Date: Wed, 18 Jan 2023 15:20:18 +0000 (GMT) X-X-Sender: derick@singlemalt.home.derickrethans.nl To: Christian Schneider cc: PHP internals In-Reply-To: <138CAD88-013E-40C7-8F0F-2034A7B0980B@cschneid.com> Message-ID: References: <22D992B7-62B3-4A4F-934F-17D53058FD35@cschneid.com> <138CAD88-013E-40C7-8F0F-2034A7B0980B@cschneid.com> User-Agent: Alpine 2.23 (DEB 453 2020-06-18) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV] [RFC] Add SameSite cookie attribute parameter From: derick@php.net (Derick Rethans) On Tue, 17 Jan 2023, Christian Schneider wrote: > Am 17.01.2023 um 15:59 schrieb G. P. B. : > > > > I might be again misunderstanding, but one cannot extend an enum as > > they are final classes under the hood. Currently, the only other > > native enum is the one that was added with the Randomizer Additions > > RFC [1] so this topic hasn't come up yet as the enum for ext-random > > is definetely complete. > > I'm talking about adding new values in later PHP versions, let's for > example assume they would add a SameSite mode "Stricter" and PHP wants > to support that. How would one write code to use "Stricter" in code > meant to work for both old and new PHP versions? if (version_compare(phpversion(), "8.4.0", ">")) { setcookie("test", "value", samesite: SameSite::Stricter); } else { setcookie("test", "value", samesite: SameSite::Strict); } These are run time checks, not compile time: 8 > JMPZ $1, ->18 ... 13 FETCH_CLASS_CONSTANT ~2 'SameSite', 'Stricter' ... 17 > JMP ->26 18 > EXT_STMT ... 22 FETCH_CLASS_CONSTANT ~4 'SameSite', 'Strict' cheers, Derick