Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124045 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 214F71ADADE for ; Sat, 29 Jun 2024 15:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719676657; bh=5EbTfFn702iGOkOt/xWI6NdS8CvXn6ZLMkPNN2xs5aQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Sg5q78LH8vMNEKDZS2XyIZ/IRPB5UGRtvwUblcTmWfxGYzgHm28DfXx2pnxOuvG+7 wtaxOzk+POuWoCMWBRu6H8FVmK4m0jiZO6SzjrObHZADtQ3FUXtZ0y1lzCCwJlf3Cm r1WPseqbGsOsplJuUej0nDiP9ri81hGe2x3ps3+9nR5W2K+YGcuD33GSuuGmklJw+D ZTGJJXmmmtcRKA/vyaSo3oy5CQyhsNFo/0mm/+XOIwXMehwXKGsNUegvOV0MvTCssr QhGGx2LstmrVwj6QZh5DNdSrMisV8pmTQpdLAcpTv/x9GEyOUqaVSxrpWcRYh98mWc nd4OH3m4xn3xw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 20A68180D1B for ; Sat, 29 Jun 2024 15:57:34 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 ; Sat, 29 Jun 2024 15:57:32 +0000 (UTC) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4256aee6e4dso12126975e9.1 for ; Sat, 29 Jun 2024 08:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1719676572; x=1720281372; darn=lists.php.net; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=+8sH63GwoTaXZQ5hXBzvb2v99TUjyE1Nzx5eb8lu6bc=; b=iIklmFDtsDcDSctr58EbagO8q6XBEy4Az5CsKd0ycqVpVniglwNKo03ih4ebLgcVW3 nX13++tGn6ouRUVDo2FVOicfmv3hv765hjqABwc+lEahqGnwC00M98yWkr8+C9WqY3DU vS+cAKOd++d2Q2iV6W6s8319I0VeB9TFln0ji7EVrH92iZryQCg820mH10Tlqa/4wUHT 3kDlT8F4ibCzymayJ+/gGQlSy9zGcy/FQ5ZEvF8cCXOZj8t9vsN8hv4VcGnsrVL1ZQ4c fNDYCbvVP9NZxqjkXr0uYIyvF3w7KQwmb3afE9caYCkz3mGivpU1WKEMTdUQ2SePELex S7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719676572; x=1720281372; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+8sH63GwoTaXZQ5hXBzvb2v99TUjyE1Nzx5eb8lu6bc=; b=qNuvt3EtQz174R5R0bWLjH1FzcQviNRcZ3NFrUQcESUuFW2JblTLdGa4bwh0f/dwIW /pFAu4hemDJDpgE2l1Io8Fn+jURQJt68l+u2Z9n/zPS9PrvW/1+jHGUUwLWhcEBxTpAp OcHelYJHecXFvPVRW5Zbb20pXRdt31JyegbT+/O6dwdTUOE3RH7Se0OITxFkylIXf62L 4tQ8p5T99CYZHJKxEJrShiBwUwU3UZJxw32jb/eoUAPgQ0bB7qR0zeR1d+RvhMM8mkfV uJUninQdjVw0Qx0Qxobxh4K0GQd/QWDavNNPScKuExhTI5crMlmmqmeSqdXylqweKSGf r+pA== X-Gm-Message-State: AOJu0Yw0XNMdiIyir2nuftJ8lePzsK8Q9aj72BY0O8x71fUYO7kAY3ID TNdqmABa3FlGnkGoc67rO/rUizv1VcTt+H+Umjt2whc3pqiIUf8ZTQTCNGrr0Rul4N8+SxEPLuc PoBSFVQ== X-Google-Smtp-Source: AGHT+IHIuzHbSWIyeBKRukZyydECNkUFv7dH5F6sZiQwFqTCkaMjPi01xZBrSTifae5OI3tuGoEIXA== X-Received: by 2002:a05:600c:4814:b0:424:9024:d468 with SMTP id 5b1f17b1804b1-4257a00c957mr9082885e9.17.1719676571764; Sat, 29 Jun 2024 08:56:11 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:6c21:b9fe:48f5:4a1b? ([2a01:4b00:bf09:5101:6c21:b9fe:48f5:4a1b]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4256b0c0f26sm80343825e9.39.2024.06.29.08.56.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 29 Jun 2024 08:56:11 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------xji9Pqjc56R5PDzn6ibd81tz" Message-ID: <834e3a0f-19c2-4665-bd8e-c05c61e48231@scriptfusion.com> Date: Sat, 29 Jun 2024 16:56:11 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Static class To: Ayesh Karunaratne Cc: php internals References: Content-Language: en-GB In-Reply-To: From: bilge@scriptfusion.com (Bilge) This is a multi-part message in MIME format. --------------xji9Pqjc56R5PDzn6ibd81tz Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ayesh, On 24/06/2024 08:53, Ayesh Karunaratne wrote: > - Why is it a class-level flag and not an attribute (similar to the `#[Override]` attribute in PHP 8.3) ? I believe Tim already answered this, and I understood his reasoning to be that keywords are used when they modify behaviour in a way that is meaningful for the consumer of that class. Or to put it another way, attributes are purely informational. For me personally, introducing an attribute never crossed my mind, and since we already have the keyword in the language performing a similar function in PHP, and other languages already, it seems nonsense to contemplate anything else. > - Can a subclass extend a static parent class without using the > `static` keyword in the subclass? This will avoid a lot of BC issues > if a library decides to declare classes as static. No, a static parent implies a static child, but implied or not, it must still be specified explicitly. I may need to clarify that in the RFC, so thanks for the question. > - Are there any opt-out mechanisms for subclasses? Not sure what you mean exactly, but if you mean, can a static subclass suddenly become non-static, the answer is no.Again thanks for the question, as this is also something I had no previously considered. > - Can you mark interfaces, abstract classes, and Enums as static? It seems others avoided addressing this question, and honestly I was not really sure where to go with this one. What would it mean for an enum to be static? I thought the whole point was we can type a group of values, but static classes have no meaning within the type system, so I cannot see the application. As for abstract classes, the current version of the RFC (1.2) now declares static mutually exclusive with abstract, so the answer there is also no. For interfaces, I haven't given this a great deal of thought. In principle I don't think a static interface is especially useful, but I could be wrong about this. Nevertheless, it is not something I intend for this RFC, since even just static classes already have their detractors, and expanding its scope any further is probably placing it further in danger of rejection. So for now, the answer is also no, but static interfaces seem like a reasonable extension to this work if there is interest in future. Cheers, Bilge --------------xji9Pqjc56R5PDzn6ibd81tz Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Hi Ayesh,

On 24/06/2024 08:53, Ayesh Karunaratne wrote:
 - Why is it a class-level flag and not an attribute (similar to the `#[Override]` attribute in PHP 8.3) ?
I believe Tim already answered this, and I understood his reasoning to be that keywords are used when they modify behaviour in a way that is meaningful for the consumer of that class. Or to put it another way, attributes are purely informational. For me personally, introducing an attribute never crossed my mind, and since we already have the keyword in the language performing a similar function in PHP, and other languages already, it seems nonsense to contemplate anything else.
 - Can a subclass extend a static parent class without using the
`static` keyword in the subclass? This will avoid a lot of BC issues
if a library decides to declare classes as static.
No, a static parent implies a static child, but implied or not, it must still be specified explicitly. I may need to clarify that in the RFC, so thanks for the question.
 - Are there any opt-out mechanisms for subclasses?
Not sure what you mean exactly, but if you mean, can a static subclass suddenly become non-static, the answer is no. Again thanks for the question, as this is also something I had no previously considered.
 - Can you mark interfaces, abstract classes, and Enums as static?

It seems others avoided addressing this question, and honestly I was not really sure where to go with this one. What would it mean for an enum to be static? I thought the whole point was we can type a group of values, but static classes have no meaning within the type system, so I cannot see the application.

As for abstract classes, the current version of the RFC (1.2) now declares static mutually exclusive with abstract, so the answer there is also no.

For interfaces, I haven't given this a great deal of thought. In principle I don't think a static interface is especially useful, but I could be wrong about this. Nevertheless, it is not something I intend for this RFC, since even just static classes already have their detractors, and expanding its scope any further is probably placing it further in danger of rejection. So for now, the answer is also no, but static interfaces seem like a reasonable extension to this work if there is interest in future.

Cheers,
Bilge

--------------xji9Pqjc56R5PDzn6ibd81tz--