Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123633 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 02A4C1A009C for ; Sun, 16 Jun 2024 12:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718540993; bh=d2Uk9Q5ZQNtX1YH5rXSaOTUDUZ+VbP4X9SlHNCn3mIo=; h=In-Reply-To:References:Date:From:To:Subject:From; b=QeDei18UUGaSErDI7lG8US5qLslj0GA1FZckVa/rgZZSWdSv9vo2SRPa/KfwIGL5B Xy+Y0uKbG9wOL/Jog+al2j6ZHCyYwtR0ngs4Rb8lnds0I5YGHfmHCDdIkODzyVvrKI mkaC+1kalut8tlN9yfV2R9QTe1hp3PpHq76S+CEE4Aqj/6GnPtTq5WNLUjx//uuCxs dFAH/v4RhEYskb62pR8FK0fH59lR1/ERY3NqIc0SdMEoAe4mLk5ZGC3bNM4vDSYQyf CJICUhGHijUW7pv/ArMQYDHZ4hmBW6lwIaShGu/f8Y/mmTQOoKgG7OBz8W4BE+53UP Mu2oxeTHIvtmw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 893E818005A for ; Sun, 16 Jun 2024 12:29:52 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,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 fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (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 ; Sun, 16 Jun 2024 12:29:52 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 71D7011400E0 for ; Sun, 16 Jun 2024 08:28:40 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Sun, 16 Jun 2024 08:28:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1718540920; x=1718627320; bh=d2Uk9Q5ZQN tX1YH5rXSaOTUDUZ+VbP4X9SlHNCn3mIo=; b=zUrdltCP0URwemD2nVCZL1Sffs Twfms4oXYxyKvUn8wm5LUnlFK1+/1194dDkEvTaeltvaVdNz1tM+/6AtNUJr4wc/ +ZB8gV3x/WGN4Q2bZt/TQlohr1ZWLKi8J/R0tpdj82XQukchZdx9DpnEHiBYl9AO hHb6YpUQGJxkSb6yXSFKgmcJqCfgAfkNpZlKNpCKpKLCh1ILbd3Kq4ej445pJZNd zQt6qhlLckmEqc5ENCcqqDWaGizpvAMj3cOb6Lmp1Kvm20uqq6Nw3rYZ8IqymFYg zB+WHIRP/z132iLvkbvBbid2enj7RWl44LWYXGZNf/OzVJ+J3hHQLXwWdZbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1718540920; x=1718627320; bh=d2Uk9Q5ZQNtX1YH5rXSaOTUDUZ+V bP4X9SlHNCn3mIo=; b=ewq1dITPwrVhV6m98I3x5rGueqd5TKMsK9hdTTQUZSB0 6NmGlcJhivdEAbysx/snNxGF9BtRyMV0aOyC+I33BFSX31SDXiWkh7QFsPFQXDoM b55aM73K8UCB3Jnw1mlhh+XAngYT/F5+BEyzfXd84+HSLw6K0cUaVpJMVr4a2DW6 6IbwKWKogZl5JlPvjMpfi8ZOz9Mw7fcKxDMOl0Mn5VHGpU8319je0isZKV9IbeMh guj+tU6Mrg5jXN6bv6wd6QrkNmQbhxPj/kflTKifvXX3Xw5if0JbSOyzzQV7s765 iN4pRX6E6wmFaQe+R6rynqiXA+QXSZzdT7NsZG4O0w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvfedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsegrtd erreerreejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothht lhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhepfeefudfhudduieekkedugffhud fgleejgfekgefhvdeikeelvddvjeehteegteegnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvsh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id F2C4515A0092; Sun, 16 Jun 2024 08:28:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-515-g87b2bad5a-fm-20240604.001-g87b2bad5 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: <0cf69a14-f1b5-4077-9d91-d7b579485eec@scriptfusion.com> <936e1aa3-48cc-4552-9f68-676ebcdeb596@rwec.co.uk> <1fc2f2d0-718f-45ec-8968-b66a1bde686e@scriptfusion.com> Date: Sun, 16 Jun 2024 14:28:19 +0200 To: internals@lists.php.net Subject: Re: [PHP-DEV] Static class Content-Type: multipart/alternative; boundary=368238be1c72421cb62feecdc094fb35 From: rob@bottled.codes ("Rob Landers") --368238be1c72421cb62feecdc094fb35 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, Jun 16, 2024, at 14:13, Rowan Tommins [IMSoP] wrote: >=20 >=20 > On 15 June 2024 18:39:20 BST, Valentin Udaltsov wrote: >=20 > >PHP does not have internal/private functions. > >Very often I use functions for really simple things like `array_flatt= en` > >(and register them via composer.json.autoload.files). But when the fu= nction > >requires decomposition to smaller ones, I switch to a static class wi= th one > >public and some private static methods. >=20 > Namespace visibility or a native "internal" attribute is something tha= t would be really useful, I think, because it would be able to apply to = whole classes as well as functions and constants. It would also allow yo= u to make the refactoring you mention without having to switch all calls= from Foo\bar() to Foo::bar() >=20 > In general, I think PHP should embrace the concept of "packages" much = more - for larger apps, there's a much greater scope for performance if = OpCache could analyse multiple files at once, and make assumptions about= them. (A consideration which didn't apply when autoloading was first in= troduced.) >=20 > With that in mind, instead of function autoloading, maybe we should th= ink about an "include_all" function, which accepted a wildcard/glob patt= ern. That would make it much easier to use preloading, and move away fro= m the "one class per file" layout, without blessing an official tool lik= e Composer, or a particular file layout. >=20 > Put together, those features would provide a powerful alternative to a= lot of static classes - i.e. those where no state or inheritance is req= uired, just a grouping of code. >=20 > Regards, > Rowan Tommins > [IMSoP] >=20 Considering that I brought up an internal attribute not too long ago and= it seems like =E2=80=9Cpackaging=E2=80=9D is a giant can of worms, I=E2= =80=99d like to suggest we don=E2=80=99t even approach the topic. People= on this list have very specific ideas of what that means and unless som= eone is going to finally try championing an rfc after 30 years, it shoul= dn=E2=80=99t even be a factor.=20 =E2=80=94 Rob --368238be1c72421cb62feecdc094fb35 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=

On Sun, Jun 16, 2024, at 14:13, Rowan Tommins [IMSoP= ] wrote:

On 15 June 2024 18:39:20 BST, Valentin Udalt= sov <udaltsov.valentin= @gmail.com> wrote:

>PHP does not = have internal/private functions.
>Very often I use func= tions for really simple things like `array_flatten`
>(a= nd register them via composer.json.autoload.files). But when the functio= n
>requires decomposition to smaller ones, I switch to = a static class with one
>public and some private static= methods.

Namespace visibility or a native = "internal" attribute is something that would be really useful, I think, = because it would be able to apply to whole classes as well as functions = and constants. It would also allow you to make the refactoring you menti= on without having to switch all calls from Foo\bar() to Foo::bar()

In general, I think PHP should embrace the conce= pt of "packages" much more - for larger apps, there's a much greater sco= pe for performance if OpCache could analyse multiple files at once, and = make assumptions about them. (A consideration which didn't apply when au= toloading was first introduced.)

With that = in mind, instead of function autoloading, maybe we should think about an= "include_all" function, which accepted a wildcard/glob pattern. That wo= uld make it much easier to use preloading, and move away from the "one c= lass per file" layout, without blessing an official tool like Composer, = or a particular file layout.

Put together, = those features would provide a powerful alternative to a lot of static c= lasses - i.e. those where no state or inheritance is required, just a gr= ouping of code.

Regards,
Rowa= n Tommins
[IMSoP]


Considering that I brought up an internal attribute not= too long ago and it seems like =E2=80=9Cpackaging=E2=80=9D is a giant c= an of worms, I=E2=80=99d like to suggest we don=E2=80=99t even approach = the topic. People on this list have very specific ideas of what that mea= ns and unless someone is going to finally try championing an rfc after 3= 0 years, it shouldn=E2=80=99t even be a factor. 

=
=E2=80=94 Rob
--368238be1c72421cb62feecdc094fb35--