Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123777 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 E86971A009C for ; Mon, 24 Jun 2024 08:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719216745; bh=92fnGxmuvg8JEjQKWj4v5UtdTJfM5U7hd4vQwCRoVk0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gYXzZ39y1ON/1UFXCzePj4cwbAJlUmcG7PSgLe2+laS0/od202xUYOmd5BIxA4dDp 2jZzCcjJmuWNjf0l/WKk6u38jS7LG8hvyxJwJDYVPkru/aGMOZ9Pwq3RSoCtD3otwi w429rtWnYvysbFf+DbQtlgTekM0VQEDcL5lLoRM2zkz2atmZEgEeTVuXaAsmc95HyM BbN6/LMY2nSXzSG2ROn8LM3xBCjbC/RRfMIp4yDM2r9n0mahzbW5Vc5UxKPKWb5pnd Kwo9zKaHhNUJ8F4/aoujQ6h6wdyTnxgPlW30setw7MEVfwtqTtRuDDTbSioMmy5Y9L PSS3nFxw3kjiA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C7B8918089C for ; Mon, 24 Jun 2024 08:12:21 +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-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 ; Mon, 24 Jun 2024 08:12:21 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2ec002caf3eso58401931fa.1 for ; Mon, 24 Jun 2024 01:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1719216663; x=1719821463; 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=Uinuwh0Xd30Q4aWybToQ8FGOP+b1mSwivG3vuavhYFo=; b=0jIklBJ8Dc5xVdEbt3TYjKXz5WIp7G29FuHYlb/9ldWqaIJ2IDpkjvWDWyMrFkK6wh nLP6eLjCpy4A8yPIu+BIDWHOXAzZBju27Yw0RaWwjXLnNxcM/kYEG0TnRnGa2l1so4AP Ch/UB1LwGz1LJYJ1lemKlTLvWDI03dLKR5dK1r0RCuQ8daYJbBzcN/QRYYoFLAjUmJtp N3SuhXLZnL3YPtqCL7i+gwfONfOHiSXSXP6SYZA8nw1hr1ywkAVJnWAQKd6bOIEoxFia lVtkHI11rQap5cfBhQuZtMjqtT1xlmF0kky6f62akz7xSXYcc7SO71U5rp5RyIM3q0x6 nEMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719216663; x=1719821463; 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=Uinuwh0Xd30Q4aWybToQ8FGOP+b1mSwivG3vuavhYFo=; b=K6m+AuZzuvktYjBA2RY/f0S7UPNJQz2Rp1vAPNaRs+YpKaLx+1waNhJWEwee4yD3Lc Oxl9En9H5BG0vm6y/DB+RWOCoVajGN34/CYhEo0JATxlhTkEcYUJifDEmZkqwacC7DWC p0Zb1ctyqFZBGFkx7yZ1HDivkOI3nhPktHi1Xc4iJnjpBVwHhvk/nT4ciq96SkrtxBGi K38osnpa5QdOUKRLWugeyJXFj6U6bcbrwqq8Z5DQqzeBLhbsROifYMxoCuQfbBbo9xYV 0oj+zKBr0e0oLqevK284IpPR2TeeXR+5RscdoH5tzWlMEqR81pJ8HFyNng1S1VQjQYNQ lgog== X-Gm-Message-State: AOJu0YxPHiS8qz1dqR+poxzUnz1amwubvH0unyTI04MchhqnUh0KLPS/ EPRzKj9O4B6OrSvp3ih7I9t+KDiRbRKLhpjgOoFIjN+KFSCN1oG0r9Tgaf2vJuKQ+KUViBhg0aD dc+s= X-Google-Smtp-Source: AGHT+IGTwBHOKeEiaxA0U2yuEPjaEoO4/ej5OtaPvk1VGbfcG25CPA21dRJU/u342c9a5yyQJoWjTA== X-Received: by 2002:a19:5209:0:b0:52c:dfa0:10c9 with SMTP id 2adb3069b0e04-52ce1832ac8mr2774801e87.24.1719216663282; Mon, 24 Jun 2024 01:11:03 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:7cb7:f467:6260:9f23? ([2a01:4b00:bf09:5101:7cb7:f467:6260:9f23]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-a725459233csm86952466b.96.2024.06.24.01.11.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jun 2024 01:11:02 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------QUxpvBGR7z96VY96OlooyQ4j" Message-ID: <82e220e3-e3e6-42a5-9134-d773e0803715@scriptfusion.com> Date: Mon, 24 Jun 2024 09:11:01 +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: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= 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. --------------QUxpvBGR7z96VY96OlooyQ4j Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 24/06/2024 07:59, Alexandru Pătrănescu wrote: > On Mon, Jun 24, 2024, 02:15 Bilge wrote: > > Hi Internals! > > I am pleased to present my first RFC: Static class > . > > > Hi! and good luck with the RFC. Hi Alex, and thanks for your excellent feedback! > While I don't use static classes, I can see how this can be used by > others. It is my sincere hope that everyone will vote with similar empathy. > Feedback: > > 1. I agree that static classes may extend other non-static classes > (that might have some static behavior). To be clear, they must /exclusively/ have static members, not just /some/. > But I think that static classes should be extended only by other > static classes, or at least for the first iteration of these feature. > This should be documented more in the RFC, no matter how it ends up being. This is an interesting debate, and something we may end up doing. I am currently undecided if it would be better to enforce full static class hierarchy, but I could definitely be so convinced. > 1.1 I think using a static class as a type should be considered an > error, as there will never be instances of it if we consider all child > classes will also be static classes. > Of course, this cannot be an error on php side given the class per > file loading separation. This is a very interesting point that I had not considered. I agree, it should be correct to forbid type hinting static classes. However, if I understood you correctly, we cannot actually implement that? My knowledge of engine internals is too weak to know the correct answer here. If it is possible, I think we should do it. > 2. __set_state() is strongly linked to exporting a class instance as a > valid php string, and is used to reconstruct the class instance upon > execution. > Considering we forbid instances, we should not support __set_state(). > If you think otherwise, please share an example how it can be used. Thank you for catching this. This is strictly a mistake on my part. I have never used, or even heard of, __set_state() in my life. I was merely perusing the magic methods to make sure I caught them all and it seemed, at a glance, this might apply to static classes, but as you point out, if this indeed requires an instance then it does not apply. I will remove this from the next version of the RFC, which I shall publish imminently. Many thanks, Bilge --------------QUxpvBGR7z96VY96OlooyQ4j Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 24/06/2024 07:59, Alexandru Pătrănescu wrote:
On Mon, Jun 24, 2024, 02:15 Bilge <bilge@scriptfusion.com> wrote:
Hi Internals!

I am pleased to present my first RFC: Static class
<https://wiki.php.net/rfc/static_class>.


Hi! and good luck with the RFC.

Hi Alex, and thanks for your excellent feedback!

While I don't use static classes, I can see how this can be used by others.

It is my sincere hope that everyone will vote with similar empathy.

Feedback:

1. I agree that static classes may extend other non-static classes (that might have some static behavior).
To be clear, they must exclusively have static members, not just some.
But I think that static classes should be extended only by other static classes, or at least for the first iteration of these feature.
This should be documented more in the RFC, no matter how it ends up being.
This is an interesting debate, and something we may end up doing. I am currently undecided if it would be better to enforce full static class hierarchy, but I could definitely be so convinced.
1.1 I think using a static class as a type should be considered an error, as there will never be instances of it if we consider all child classes will also be static classes.
Of course, this cannot be an error on php side given the class per file loading separation.
This is a very interesting point that I had not considered. I agree, it should be correct to forbid type hinting static classes. However, if I understood you correctly, we cannot actually implement that? My knowledge of engine internals is too weak to know the correct answer here. If it is possible, I think we should do it.
2. __set_state() is strongly linked to exporting a class instance as a valid php string, and is used to reconstruct the class instance upon execution.
Considering we forbid instances, we should not support __set_state(). If you think otherwise, please share an example how it can be used.

Thank you for catching this. This is strictly a mistake on my part. I have never used, or even heard of, __set_state() in my life. I was merely perusing the magic methods to make sure I caught them all and it seemed, at a glance, this might apply to static classes, but as you point out, if this indeed requires an instance then it does not apply. I will remove this from the next version of the RFC, which I shall publish imminently.

Many thanks,
Bilge

--------------QUxpvBGR7z96VY96OlooyQ4j--