Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123775 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 995921A009C for ; Mon, 24 Jun 2024 06:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719212457; bh=qqgqREBVtNGjN/dBQxqzWTZQYzyhxnjjuu6cqIu8Tag=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mouYAv8lMXLhhCrELSXTSUQekXizB+q5qUfGBUPSF1rU4r7e6M8lSMIwSvxIzpK0x YnVaP7CVkGD6IYNdyTrg7z2Hdtf5qPOjuuCHjsgHkeqcVZ6bmoTjVgN4x0xZnZ/AxL pVgtb/hwv40mJSPj4OYtDPMKcFbBpn9SEnk2PSQnwu65jQAWgThIrDby4gv5XBCvUn AdKGvZm26+BAqErdLLw4VJf9z9wqBn54ntLzlAVaS4r15cLmbm4nmntW0ed00lmLJI iQHoQOCJiI7O+HZ8O+xAP8PZ0dLu+qmdVDgl/BGYOL0pWa6nbkbsdRNPdFEtkY1dbE eOBut9abc7Gzw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A8B618005F for ; Mon, 24 Jun 2024 07:00:56 +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, 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-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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 07:00:56 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e02bda4aba3so4023382276.3 for ; Sun, 23 Jun 2024 23:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719212379; x=1719817179; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qqgqREBVtNGjN/dBQxqzWTZQYzyhxnjjuu6cqIu8Tag=; b=MGi8dUbHtqCxGupT2dKGewnmuLbZVeAUCcvv39TWL+Aps/hYCcczeviyEvjGaJXbum kX8RuyE/bz2IHK1zv7R7XOmnbdRfVcMVErYCfq08CIrUUxK7KYLmHS6S2/zSCN1UZrHY MiJftgwe11t3U2fNUTwWGLiBWFxsSXSe8Z5caUvM9hmTBL3M+gzyUfhyUJwiXs91KmNA 8SvJ10DyN7PUSq/LfO85/IKWjY9nLJT+z4qQbhBIi1QYk9rA/GypKGoX+3rD20vZmuy4 1hJml3oE3e0N/OLSvsnG4Sh1MHWTChVgTcNdRKXpUtCkNTTpmNj6zOX6K5SBmzToxtYP bAGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719212379; x=1719817179; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qqgqREBVtNGjN/dBQxqzWTZQYzyhxnjjuu6cqIu8Tag=; b=a1inZxCmZ+I+giF16C7K4VUAQkhC7g1FrkXR0nt0x5la6w15n2UbONKdL41hUKVmgs VRcWioA4Tcdt/Cvmo8jnYTpI2DufhUyTJlTSHr5/lZ8SzMAzO50RO1FW0oipFJqLiwu7 bL9OOU0YkpV9mS93DXIy5a3WFlxyBfBlyoKP1Q2Mkvjq3367/WeZkaQf612/zy/D1igy VHB5cUjLBKz1xhaNHvSZVuK3ziuadcWLtigILNzXFOQNQbGXhF5Set2qbRgFjJhLeUVK mtQjgYhKljctP5sIliCUhjLD9EpUiMsrHO4SdG+lGG53RZSo1wkSMpsNTcGolsvQeWfq 82bg== X-Gm-Message-State: AOJu0YyI1t9pTzDpEqDuh7k+JpYexDa9b3b5gogYkAfxIXZSQ2ODBDGN wbxIU/u87PhX7yhMTUi5EcOKJFELlcqtOrYqM7dQIdPJJ8+/myxWHI/Jl2Xt/aQi25I4ksPXcMY nLTurRrEPuf8Cbg55vpev9TbavH4= X-Google-Smtp-Source: AGHT+IGedapciJ2Uvy2uJ4IisbQ5sYdMjKR7sNDBwf3szwN/6AxbvbcuI3jDYwjHQ0N7C1WUR+W3ooOZ0XMV4ypXCPE= X-Received: by 2002:a5b:852:0:b0:e02:b466:e59c with SMTP id 3f1490d57ef6-e0303d8fedamr3502781276.0.1719212379116; Sun, 23 Jun 2024 23:59:39 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 24 Jun 2024 09:59:27 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] Static class To: Bilge Cc: php internals Content-Type: multipart/alternative; boundary="000000000000269c96061b9d535a" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000269c96061b9d535a Content-Type: text/plain; charset="UTF-8" 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. While I don't use static classes, I can see how this can be used by others. I worked in big projects that used too many libraries, and when those libraries have functions.php file, they pile up and loading the composer autoloader can take a small dent on performance of each request. Having functions grouped by a class that can autoloader instead of a file is an advantage that should be spelled out as an use case. Feedback: 1. I agree that static classes may extend other non-static classes (that might have some static behavior). 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. 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. 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. Regards, Alex --000000000000269c96061b9d535a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Jun 24, 2024, 02:15 Bilge <bilge@script= fusion.com> wrote:
Hi Inter= nals!

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

<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
Hi! and good luck with the RFC.

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

I worked in big projects that used too many libraries, and w= hen those libraries have functions.php file, they pile up and loading the c= omposer autoloader can take a small dent on performance of each request.
Having functions grouped by a class that can autoloade= r instead of a file is an advantage that should be spelled out as an use ca= se.



Feedback:

=
1. I agree that static classes may extend other non= -static classes (that might have some static behavior).
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 end= s up being.
1.1 I think using a static class as a ty= pe 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 pe= r file loading separation.
=C2=A0

2. __set_state() is strongly linked to exp= orting a class instance as a valid php string, and is used to reconstruct t= he class instance upon execution.
Considering we for= bid instances, we should not support __set_state(). If you think otherwise,= please share an example how it can be used.

Regards,
Alex
--000000000000269c96061b9d535a--