Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121783 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79825 invoked from network); 23 Nov 2023 17:55:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Nov 2023 17:55:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DA2D1180031 for ; Thu, 23 Nov 2023 09:55:31 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (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 ; Thu, 23 Nov 2023 09:55:31 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 89CFB3200A90 for ; Thu, 23 Nov 2023 12:55:25 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Thu, 23 Nov 2023 12:55:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1700762125; x= 1700848525; bh=gyJrGDIPyL+q6WT2BkkN1G2oKVgZBMPUspTFicNd0UM=; b=D 7BX+AgTBNgNaqPOcxJaBoUhuaWUcCp791pWP9DNXnYXQX8qvpW/7kUemWeL4ubyT EKY0bXpI+vKJtOl/f6aQ/i1IIqKnjJLa8zYcERSwdO5EOlrNefItnNBYtMQoG6qg TsodEThSgblkg7SsHC0TTLlAn1G81/ttkITvKm2ruAfpo1YMGBhEsL4FqDtJz+fp LZSd4TJ5VTG6RLU0G7f4uPky+kUi3Hi8fM93mcLOGk7rXijkJ/INrnYwK+RcnK6M HZEMHOWZgK+w5KQyrVko6w5qSdYo07FuWd5Ro3bMYMFIThTbZy6f7KioNrpqar3Q a/n4/zM4qbIrJyEuqIk7g== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1700762125; x=1700848525; bh=gyJrGDIPyL+q6 WT2BkkN1G2oKVgZBMPUspTFicNd0UM=; b=stIOYMI+JkUJw5OIah4p28l2PlPIN KzzeHeIArFCgD0y2BKaH0CCtHCHLRLC9aA2XllTAO8dyGjk6zFHkgKivNstCPhMj /2s5DaSBAZ1J8GH849VkQ08tNDOY2YeQB7+F8lGywOAhhfCLRG3OTxdQ3czzUGs8 bhZ6sC3FcU4DSw1VN+gYg1uKXpMbeHlXErwWKUc8suH6Rhk/BA/0QWOaaPYBjHpr KOpI7FE+6ZUZrcnJte0Zjf9nGe0WqdG6aYWKOBPaIoyZKU+3jgjwlQ0cyw0ZGeNQ CK8amMzyp9s1V+mJ83gEfveH3VgxKnQxRCW/GLFGHsaH9MjbWz5/IINTQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehfedguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9345C1700089; Thu, 23 Nov 2023 12:55:24 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1234-gac66594aae-fm-20231122.001-gac66594a MIME-Version: 1.0 Message-ID: <44083842-40a7-43a0-b85b-b021356e7f70@app.fastmail.com> In-Reply-To: References: <79d675e3-95b4-40bb-baf4-3e1c998f5390@online-presence.ca> <34979AED-893F-45DD-B641-A9F4F39B2928@newclarity.net> <2D505086-6AD9-4596-A515-85B50F5D12C5@koalephant.com> Date: Thu, 23 Nov 2023 11:55:04 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] RFC Proposal - static modifier for classes From: larry@garfieldtech.com ("Larry Garfield") On Thu, Nov 23, 2023, at 1:43 AM, Robert Landers wrote: > 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). It's close enough to the same thing that it has the same problems. As far as I am aware, a static variable in a function is stored in global memory as a singleton. It's logically the same as a global variable, but with access restricted to one function. A static property of a class is also stored in global memory. It's logically the same as a global variable, but with a funny name that has colons in it. It may be access restricted depending on the code. (Engine experts, if I am subtly wrong there please do correct me.) So static variables and static properties are both simply "globals with funny extras." And global-maintained state is well known and understood as a bad idea that hinders testing, refactoring, tractability, maintenance, and everything else developers care about. Using global state, with or without funny syntax around it, is the anti-pattern we should not be encouraging. Generally speaking, even my prototypes eschew globals and statics in 95% of cases. --Larry Garfield