Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:121796
Return-Path: <php-lists@koalephant.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 37858 invoked from network); 24 Nov 2023 06:30:12 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 24 Nov 2023 06:30:12 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 3C3E918003E
	for <internals@lists.php.net>; Thu, 23 Nov 2023 22:30:16 -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.9 required=5.0 tests=BAYES_00,DMARC_MISSING,
	SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <php-lists@koalephant.com>
Received: from mail1.25mail.st (mail1.25mail.st [206.123.115.54])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by php-smtp4.php.net (Postfix) with ESMTPS
	for <internals@lists.php.net>; Thu, 23 Nov 2023 22:30:15 -0800 (PST)
Received: from smtpclient.apple (unknown [49.48.245.183])
	by mail1.25mail.st (Postfix) with ESMTPSA id 692C9605D7;
	Fri, 24 Nov 2023 06:30:04 +0000 (UTC)
Content-Type: text/plain;
	charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\))
In-Reply-To: <CALKiJKrCwTk540i1tzvB3iC=o69DYNf20ZaJ9whyMf96LJd=TQ@mail.gmail.com>
Date: Fri, 24 Nov 2023 13:29:50 +0700
Cc: PHP internals <internals@lists.php.net>
Content-Transfer-Encoding: quoted-printable
Message-ID: <51993D16-4C3B-4147-91AE-8F3961760832@koalephant.com>
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>
 <CALKiJKpKk0vPhE6Q6H=BK4sy5SLsCBG0aET8X5ZiFo_=v+bLyw@mail.gmail.com>
 <C6AEED2E-197A-4C55-8139-1EB1AB374146@koalephant.com>
 <CALKiJKrJRWyEFkk1-A-4XOS2OJ6rzsj6D55LMcPrOFFSbRidLw@mail.gmail.com>
 <BEBA905E-CF22-4F1E-8CAD-E51B7D480BE0@koalephant.com>
 <CALKiJKrCwTk540i1tzvB3iC=o69DYNf20ZaJ9whyMf96LJd=TQ@mail.gmail.com>
To: Rowan Tommins <rowan.collins@gmail.com>
X-Mailer: Apple Mail (2.3774.200.91.1.1)
Subject: Re: [PHP-DEV] RFC Proposal - static modifier for classes
From: php-lists@koalephant.com (Stephen Reay)



> On 24 Nov 2023, at 01:09, Rowan Tommins <rowan.collins@gmail.com> =
wrote:
>=20
> On Thu, 23 Nov 2023 at 14:20, Stephen Reay <php-lists@koalephant.com> =
wrote:
>=20
>>=20
>> Out of the box, with no package manager or module loader or anything, =
you
>> can do as little as call `spl_autoload_register` with no arguments, =
and
>> have working class autoloading.
>>=20
>=20
>=20
> Sure, it's just about possible that you could paste that one line into =
each
> of your PHP files, and they'd all pick up the right classes. But it's =
more
> likely that you have some shared include called "startup.php",
> "boostrap.php", "header.php", etc, which has that line plus a bunch of
> other setup. So, the argument goes that adding a line "require
> 'namespace_foo_functions.php';" to that shared include isn't that big =
a
> problem.
>=20
> (If it happens you are using Composer, the files and config are listed =
in a
> JSON file rather than a PHP one, and Composer generates the shared =
include,
> but the logic's basically the same.)
>=20
> The strongest counter-argument, I think, is that it *scales* badly: =
once
> you have more than a handful of such include files, an autoloader =
solution
> becomes more attractive than listing all the files.
>=20

I think attractive is the wrong word here, but yes in general the issue =
is that it becomes a developer overhead as the number and location of =
files increases, particularly if you want to keep the files organised in =
the filesystem in a similar fashion to classes (i.e. namespaces mapping =
to directory names).

> However, in itself that's not an argument for static classes; it's an
> argument for function autoloading; the argument for static classes =
needs to
> be either:
>=20
> - "admit it, we're never going to get function autoloading";
> - or "I'd want this even if we had function autoloading" (in which =
case the
> discussion of require vs autoloading becomes irrelevant).
>=20

I couldn't agree more - like I said at the start: I have no dog in this =
particular race about static classes, my only concern is the continued =
use of Composer as a flimsy argument about why features aren't required.



Cheers

Stephen=20


> Regards,
> --=20
> Rowan Tommins
> [IMSoP]