Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117453 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49845 invoked from network); 30 Mar 2022 11:32:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Mar 2022 11:32:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 974751804F7 for ; Wed, 30 Mar 2022 06:01:01 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 30 Mar 2022 06:01:01 -0700 (PDT) Received: by mail-ej1-f51.google.com with SMTP id j15so41322824eje.9 for ; Wed, 30 Mar 2022 06:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vjibroGHucdIVVkzs5hVlEI/G5q/9/VrQjeuKrIlbTc=; b=Wz16HYYl+oF1uFjxS5HW4RJ98bMGBKoTYUIkF3d2uY5xTcESonrNWNWM70y+aiuHI3 PezdNVi0GCme2MXfT9+USbUBw+zw7XuwWTNQUzwBqUC1/Sp8Q884s+Wt+jjjUrkJBA2w iNL6zmHozL/zvy43Gx33X3ZDrhRFk1sg9ULSoVekylnFOZ61Z2pXhO8+17Otp1XenGTu 78wUFouae7BxRABTRieZeocki4Juu4ltLCazaibBPfcYKrQRebCrgxdK0FGI0wv8SBNC yU0rRiZhcVpV5uK9FzctppZf9K6emiIQPCrQwRT+AbA3W5aMrXcrtYJzV3rRmNTjBlv7 4FeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vjibroGHucdIVVkzs5hVlEI/G5q/9/VrQjeuKrIlbTc=; b=gE+k6OQu/BnzTYhImjYbpdPeqEUY/Q0Dzll96q00qt+CWCYM0endlyqlAxSkdyfAQk T/Bo1qFlIIDc5pdHym8uqH754jrWEX1TseAtbF71fGEQALgZ+aW3OYu40Pp2AHERHjNc XJzf84nPLrIpg9DBuD2/I7T4ZUqf14Wmb4aHcAJeIweuUODykhVmUXt1B1vRNwtaxsbx H27WC5LP+JU2010w8hIiX9CRLCu4utqOOXQoHHeSIkRdQlazQ0LyegJ0ruez1gzgvIJt mclKasOGwA8WtcTx31xse1JJW4PVmjFQ2S6jyRgy8+9iZysSIIVjbB9VCgvIR4+15cIA bJDQ== X-Gm-Message-State: AOAM533BPsG0kQaa6B5Y+IkPXtwZ/DKZ1pMIhhGq9GciG5nB/BqLj8Ur E2dsKnbo6jpEDT8MYBM5TF7wPgaUJ7gku01D3D83Vy+1 X-Google-Smtp-Source: ABdhPJz5eAqxUx7ShdIQC4D31zPynf2LylEiQ9qJGK7Sq2+8zKFbXzbltSv6ygVyPbv/Dr6tlzDg5tk+J9IsWrN3lAk= X-Received: by 2002:a17:907:2cc3:b0:6da:e6cb:2efa with SMTP id hg3-20020a1709072cc300b006dae6cb2efamr39374465ejc.169.1648645257364; Wed, 30 Mar 2022 06:00:57 -0700 (PDT) MIME-Version: 1.0 References: <76c399cb-fb29-4583-a212-8eb69740c96b@www.fastmail.com> In-Reply-To: Date: Wed, 30 Mar 2022 07:00:42 -0600 Message-ID: To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: Guilliam Xavier , php internals Content-Type: multipart/alternative; boundary="000000000000ed34bd05db6f2286" Subject: Re: [PHP-DEV] Typed constants revisited From: mbniebergall@gmail.com (Mark Niebergall) --000000000000ed34bd05db6f2286 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Alex, On Tue, Mar 29, 2022 at 10:35 PM Alexandru P=C4=83tr=C4=83nescu wrote: > Hey Mark, > > > On Wed, Mar 30, 2022 at 6:03 AM Mark Niebergall > wrote: > >> >> I have updated the RFC https://wiki.php.net/rfc/typed_class_constants >> with >> more details and examples from this thread, and updated the RFC status t= o >> Under Discussion. Hopefully the updated RFC helps answer questions and >> clarifies what the proposal includes. >> > > Thanks for the RFC and the drive here. > I personally see the benefit and I think it would be a nice addition. > > I think you should also update the "Supported types" section. > Starting with enums, constants can also be objects. Once a good technical > solution is found, any object would be supported probably > https://wiki.php.net/rfc/new_in_initializers#future_scope > I think that only void, never and callable types should not be supported, > just like on properties. > > I have updated the "Supported types" to list out all types that are supported and which types are not supported. Constants cannot be objects since objects are mutable, so typed constants will not be allowed to be an enum (which is technically an object). A typed constant _may_ be an enum value though, so the following example will be valid: ``` enum Fruit { case Apple; case Banana; } class Colors { protected const string RED =3D Fruit::Apple; protected const string YELLOW =3D Fruit::Banana; } ``` > >> Of note is the "Inheritance and variance" section, which details uses wi= th >> abstracts and interfaces, plus the "Constant values" section which >> includes >> details about errors. >> >> >> > >> > -- >> > Guilliam Xavier >> > >> > > Thanks, > Alex > --000000000000ed34bd05db6f2286--