Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123676 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 C646C1A009C for ; Wed, 19 Jun 2024 13:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718802515; bh=hMiLhDHRbzepMAPAwVPHNgGQCIX6mc5ioZqRSd1TNOk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FVaemWcX7qDuYjW2qa3apx7HoRzBqSHyGH/uz8i6BaAMkhqR+VHkibzIKO7UJW/Nz FQzjaLGhqtkUamleXIhdtwYU0Dk+WqKJCp+1EqHsOIT39tzd6hwMaEOOZyXi2OK3z6 YLsye9AaqeB023YeSkCAqaxSbpaaEQQeYpz3tTpeWkSTtSvVqIWofji2y9DdUcAr9m mb8V662QnhEellyAdNUNOoSp501A7u4jGtiz3dX7i54/yq5FvwpyICtinyKQ0WRNAm 4CXHS3AmmA+yUYHCCGdI6DULjWRsBwV/ZlS0TXVYmwKpJ+l/nMg6gVEP/kb5jz4iYg PDVljzejb0v+g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C5457180877 for ; Wed, 19 Jun 2024 13:08: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.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_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-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 ; Wed, 19 Jun 2024 13:08:34 +0000 (UTC) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-632980b9c03so48952847b3.2 for ; Wed, 19 Jun 2024 06:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718802440; x=1719407240; 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=ir7KK1Sa3w2syC0gTUGylg9toKBRr4Kmc750M9Ujm4g=; b=MgkMUXs1Hs5C6m4+WTqJJjMsmWZha1xaOjPLta/YsbO/WOOObR3bmb/pn000elmH6G UldPEQvMEwDEHzVnNyW9gNT6ruE7+s0DkeQg0YXCb3O50OPwaSPkCZEKi6C1qwC1gGwf TgMCYeAPSB97WVRLJM6p7cnmUEofrJBoVkB8h1g64SNWYktTuX4fo88Zt6tg+YXaTbvI vHAAKlqCUUNtE1Ll2oNL1nWkdknRZd3435BpUXLA7VuYNsd9fOVH9OCXs98IDuf9JMwa nMjD45YyixdH5AnfRizSWFyxrivN4bq7rGvHX2oJjvL4F329q/5/mszYDBUNnISvpQev X11g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718802440; x=1719407240; 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=ir7KK1Sa3w2syC0gTUGylg9toKBRr4Kmc750M9Ujm4g=; b=ajXIG72IVt5yJyZtQnmmTxLYFZzo4kg+vJbUfHgHsNunat4tQl7cZiWJRiPn7NIpeF n5J21Wfg+BFi4GW+CBOY90LeVOOUixTOY3bEOpcfV6bbW8nmVazWw8IkE44P9HJLaIKu VhLo9YRoMj/XB9r2DGqx3WRpLYNMDyN9Box5O1Z9Pj3klcvpWk6ALe4sRtE2c0jx2Sbq 0HXZdElKS3iBWUZN7S3/boorbO9TgE8djVZ0erOnn4FsYaI+t0u0zt+ZcHbByAN0RxPE hbovpBq/h3dkb/Z4Epdgbw+chd7HRZE+Trs0YweXZabinjBHNpIKIpGs/MmQDVkHSO+E xiZA== X-Gm-Message-State: AOJu0YwtpiKFaslbD3rljhXIXfkVk/QR3qgvdXB3bb3B/X530C6ivjHa URFSqrjiM8UqVFHqMeRbZh8JVEMMNTSnF0sETKVCSHT8Z99a83h9MVbmt8PRXcdyLdCCCMfNW0e qR0uFoOPQvRc3UqT4bCq3IOl32FA= X-Google-Smtp-Source: AGHT+IENy2ljPO2ggPGBVzM7/3SCH1AEuMZyXKV7EkdduP0GC5lAN1wqWXx61IcwI4GuEDg3RUs8a/GpKtw1K1DehNY= X-Received: by 2002:a25:ad59:0:b0:e02:80d4:81ae with SMTP id 3f1490d57ef6-e02be10c316mr2825189276.3.1718802440264; Wed, 19 Jun 2024 06:07:20 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 19 Jun 2024 15:07:09 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Static Constructor To: Erick de Azevedo Lima Cc: php internals Content-Type: multipart/alternative; boundary="000000000000e42361061b3de007" From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --000000000000e42361061b3de007 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Erick, =C5=9Br., 19 cze 2024 o 14:35 Erick de Azevedo Lima napisa=C5=82(a): > Hello everybody. > > I found myself wanting this feature (that I first encountered when > programming in C#) for removing a workaround from a codebase I work from > time to time. > I searched internals and found a discussion from almost a decade ago. Tha= t > discussion did not end well, mostly because of insulting accusations. > I then decided to do some research on this subject and found out that it'= s > a pretty common feature in other OOP languages. > Also, as I started studying the php-src (and missed the days when I used > to program in C in my main job), I decided to do an implementation myself > even before presenting the RFC. > The implementation link can also be found at the RFC. > > You can read the RFC here: > https://wiki.php.net/rfc/static_constructor > > Regards, > > Erick > I like the idea of having a static initializer. I think we could propose a better naming, method name `function __staticConstructor` is a concatenation of the words static and constructor while constructor is used as an initializer when building constructing objects. Have you considered naming it for example shortly `function __static()` ? It is somehow similar to https://wiki.php.net/rfc/static_constructor#java in static-block. Cheers, Micha=C5=82 Marcin Brzuchalski --000000000000e42361061b3de007 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Erick,

=C5=9Br., 19 cze 2024 o 14:35=C2= =A0Erick de Azevedo Lima <er= icklima.comp@gmail.com> napisa=C5=82(a):
Hello everybody.

<= div>I found myself wanting this feature (that I first encountered when prog= ramming in C#) for removing a workaround from a codebase I work from time t= o time.
I searched internals and found a discussion from almo= st a decade ago. That discussion did not end well, mostly because of insult= ing accusations.
I then decided to do some research on this subje= ct and found out that it's a pretty common feature in other OOP languag= es.
Also, as I started studying the php-src=C2=A0=C2=A0(and misse= d the days when I used to program in C in my main job), I decided to do an = implementation myself even before presenting the RFC.
The impleme= ntation link can also be found at the RFC.

You can read the RF= C here:
https://wiki.php.net/rfc/static_constructor

Reg= ards,

Erick

I like the idea of having a static initializer.
I think we = could propose a better naming, method name `function __staticConstructor` i= s a concatenation of the words static and constructor while constructor is = used as an initializer when building constructing objects.
Have y= ou considered naming it for example shortly `function __static()` ?
It is somehow similar to=C2=A0https://wiki.php.net/rfc/static_constructor#java in = static-block.

Cheers,
Micha=C5=82 Marcin= Brzuchalski
--000000000000e42361061b3de007--