Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:121769
Return-Path: <landers.robert@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 15812 invoked from network); 23 Nov 2023 07:43:34 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 23 Nov 2023 07:43:34 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 2275518003B
	for <internals@lists.php.net>; Wed, 22 Nov 2023 23:43:38 -0800 (PST)
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM,
	MISSING_HEADERS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
	SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <landers.robert@gmail.com>
Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43])
	(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 <internals@lists.php.net>; Wed, 22 Nov 2023 23:43:37 -0800 (PST)
Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-58a01a9fad0so293582eaf.1
        for <internals@lists.php.net>; Wed, 22 Nov 2023 23:43:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1700725412; x=1701330212; darn=lists.php.net;
        h=content-transfer-encoding:cc:subject:message-id:date:from
         :in-reply-to:references:mime-version:from:to:cc:subject:date
         :message-id:reply-to;
        bh=JlUTd1vjdLp28xsL9Hkg9WmQB4APf4l1nafvyLeyzLk=;
        b=lSM9db2NWToSRACqZ+Ud68MWXMOt+irwnJvrLgiD2SWX/x2S1pSOaXtJ0a46WfBSPD
         uQ2yEa4unDhzpjGDKgx1ng6f6YWTvIT3zDa6orQouebK/zzOFDmYKctW/4PZNnVk11zm
         Uj7RGMcBJAs7/uHJ5BPrJQtZk4viJwnYgAbF02tnhRikDr2wlzZ9F4xjY429+H0djkDv
         e1/WK0bTZWILciM8y87rx7w61OlnNY/q+WlJSzknsTwMPx8MrfJq382lNuXKO39qJuaG
         lzkPwmlE7GCxxcjA8lhLVamdF5R2vWsSrqhSOGqnOIxGZklBXwQrSwb3/RHpq9q59cOW
         AGCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1700725412; x=1701330212;
        h=content-transfer-encoding:cc: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=JlUTd1vjdLp28xsL9Hkg9WmQB4APf4l1nafvyLeyzLk=;
        b=AA8yNJkxo7YTHqjy6J9V8M8o7/NZ59pMGglDrMmuo1Nufm0mkh9J7w6usVc2O/Pfyk
         /HZrTyB4ahUXOpGbYSBTd7RcyQF3I+fZQGNa9WpocjT3XtRPXtmZxNSdtnI9wuKhj4YQ
         vMJKkv2D0r1uX6E1hR90JxdN8rkWM0Jo2XV6dZGwh9NO3w7nRlCeDIp3HeNd8xX3E37e
         yi1uSSdUWUARS3VBortjsfPXjD/njfp/i8/d1R5rnoKMFf33/REXsw40eeGOW7huiK3t
         vsDls0hKGZodaYfjypiFUJW9Y5IoC8DEyhQCMWmnxtCYs1M+DRrmOl+6+xfa0+zo49nJ
         0MOQ==
X-Gm-Message-State: AOJu0Yyikxl2UGsGszOZR3CbiDxxcxZp4Aqp41PNaBI0Z5hz7+SQfS6Y
	ylTF6OcW/A1wSZr9K1bE/9Fw8NVyV5rgvZr/bBSJ408SLUs=
X-Google-Smtp-Source: AGHT+IH9WF75HRld11R+CwT0KyXIhXUriRekYoD1JC/1cVPKh6SsMleZgsHzZGqL2PvddPenYlI/9kt7whumkjleBv0=
X-Received: by 2002:a4a:dc5a:0:b0:589:f3e3:326f with SMTP id
 q26-20020a4adc5a000000b00589f3e3326fmr1100377oov.0.1700725412243; Wed, 22 Nov
 2023 23:43:32 -0800 (PST)
MIME-Version: 1.0
References: <79d675e3-95b4-40bb-baf4-3e1c998f5390@online-presence.ca>
 <CAPTD5yH9Wk=ADvCRf4K3SVNm+hfyarHr8_4hQAMbt-zDH4zxkA@mail.gmail.com>
 <CAGBsUreqkyoohwL0B7o8WFQLLcekMryDmDRQ1ksoF2FZCt9WOA@mail.gmail.com>
 <34979AED-893F-45DD-B641-A9F4F39B2928@newclarity.net> <2D505086-6AD9-4596-A515-85B50F5D12C5@koalephant.com>
In-Reply-To: <2D505086-6AD9-4596-A515-85B50F5D12C5@koalephant.com>
Date: Thu, 23 Nov 2023 08:43:21 +0100
Message-ID: <CAPzBOBMPgSvnnsMZEELT7u+kma7OsK6rRvwddTzmM+PjC=5emg@mail.gmail.com>
Cc: PHP internals <internals@lists.php.net>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Subject: Re: [PHP-DEV] RFC Proposal - static modifier for classes
From: landers.robert@gmail.com (Robert Landers)

On Thu, Nov 23, 2023 at 7:00=E2=80=AFAM Stephen Reay <php-lists@koalephant.=
com> wrote:
>
>
>
> > On 21 Nov 2023, at 06:48, Mike Schinkel <mike@newclarity.net> wrote:
> >
> > Wow.
> >
>
> Hi,
>
> (This is not a direct reply to Mike, his just seems to be less shouty tha=
n other recent emails)
>
> I'm not *particularly* bothered by the results of this specific RFC eithe=
r way - a *similar enough* result is already possible by grouping static me=
thods in an abstract class, but I'm disappointed to see yet again that ther=
e's this implied notion that working with PHP in 2023 means "well surely yo=
u must be using composer", which leads to "but composer..."  somehow being =
an accepted argument when it comes to missing/incomplete builtin functional=
ity.
>
> Despite the way some treat it, this isn't the composer internals list, no=
r is composer a required or even bundled part of PHP.
>
>
> Does that mean you shouldn't use composer? No, if it works for your proje=
ct, that's great.
>
> Does that mean gaps in the php language/standard library should be automa=
tically ignored/glossed over because composer may provide a work-around? Al=
so, no.
>
>
> PHP has for a very long time stood out amongst other web-focused language=
s for having a very rich standard library out of the box ('batteries includ=
ed', I think the cool kids would say now).
>
> Let's please not take PHP in the direction of "modern JavaScript" where l=
anguage deficiencies mean that an entire alphabet of constantly changing th=
ird-party tooling is required to do anything but the simplest tasks.
>
>
> Cheers
>
>
> Stephen
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>

Hello,

I'd venture to say that static classes have some unique benefits over
plain functions. One, you can encapsulate state using private static
variables. That simply isn't possible with regular functions (unless
you use static variables in the functions themselves, which isn't
quite the same thing). Two, you still have inheritance that you can
use with static functions. You can't really have inheritance with
regular functions unless you are strictly passing around closures.
Third, static functions can also use traits (in theory) to allow for
code reuse. Fouthly, not everyone is writing s Symfony/Laravel
application that needs highly testable code and might just be throwing
a prototype together -- static classes could hold static configuration
for the app.

In something like C#, static classes are used as a way to extend parts
of the language.

One thing for Lanre: please do not remove the requirement to
explicitly mark a method as static with this. As someone who has read
very long readonly classes, when you make a change, you usually don't
find out it is readonly until you make that change. This is because
the "readonly" is at, and only at, the very top of the class. Now, if
you need to make the class non-readonly, but want to keep all the old
variables readonly, you have to make dozens of changes. Please, for
the life of sane refactoring, don't make "static class" a shortcut for
not being explicit, just make it so that things MUST be declared
static. Long classes are (unfortunately) a thing, and it makes
everything more obvious as to what is going on. Further, removing
static from the class, the class should still function, IMHO.

Robert Landers
Software Engineer
Utrecht NL