Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123887 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 392F31A009C for ; Wed, 26 Jun 2024 20:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719433199; bh=+xXZ6xWj4rMCn+Ty9rm9D/COIJKpSxQOwuLb+tk4EVs=; h=Date:Subject:To:References:From:In-Reply-To:From; b=ZkH2KLcRA2IsphVQ88Yt3cp4I7Hh9WAUZHe19C6qNgpElW8Je6W75iQ8fIvHmQaaQ HEJdCk5UCha5kBbYTbTLwCNc4OGLDI3cUk6vOCooddgcndrRVLZeg4Ihd/1uSzb51d tx8jhqgc2cXOxhivIW3BYtWQB4oIGOdfMbJsugbxnEwtvywxdF1/d3ZLIuiahP0hup sVDLEZ8s9ke2w8sei0zuHWTn6jVHtKhNaDDnRo/Q8QDpEmyXpt66u0ZupxJg07OQ84 obWZPdTihXBOSE3fR6I6jtr9TUHhkUIhZ5hzsCFA/DZtomKv7lgPjQErhxPPhFJRvU UeUZ4WVsl3v9A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3914E1801EA for ; Wed, 26 Jun 2024 20:19:59 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, 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-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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, 26 Jun 2024 20:19:59 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-424f2b73629so11595025e9.2 for ; Wed, 26 Jun 2024 13:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1719433120; x=1720037920; darn=lists.php.net; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=JKMKHIH+fyCpCfRM3SgsEIAwqzXBH/Bk8XFaWbgdX/4=; b=KwSeWx9wVKuLn2XDK0z0mbmj8qnhbGxDxmn0RVqDiN/W5mge+QiXyytuoA/qa0H2qK cimNmnt72ckGefXVfvex7qA+4OVnkpb2AbalT0gooj/K0zGtuaZgu5XbTj0kGJc2uvOA evh9aJgU6JxcZkXVv+yxGutFAVDKKwYM4ridHBpt9MF67Lou2sj6eXCgyk98ChHF8yta qydihKbzTL3OZYWtgBbs0XX1jypekwY1H6faKDAtGm/43kIkhua+CW8TnFasIYHkDb9P M0kSGqzgib4FneiZ5pM6mkOyyITsbGbDIzhN0TBhhuthCBkElA1AWl2FrXLy4C7pXlWW ilTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719433120; x=1720037920; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=JKMKHIH+fyCpCfRM3SgsEIAwqzXBH/Bk8XFaWbgdX/4=; b=c+EsmD24gV9464OE/zsZZuEKKmDnHrne9lWGiHTj5Rs89kR8UQ1Yv/rgY/gGSQqe/M oEZ63YDd7gu/qAQQrY4XPKhucIqx3TxGKvatu/xLSH2Y/SR1seJ8lWXEkQrgP7ZUkLaO WJKmCTfsKc8ejpZTmYePDk0Sndria68XuMBZZTb6aP/XSTuyw8j+G+WxObqP0JMk/v7B pUNqCULGw4O+98BR6qdAh9ZL4vLLwerY2uOgUQR9nGIuk827nM6RVsSHMhUkGOoiSJIy DZcyh/7nlyw/Nrc0fa5T9E1WSqeP/WQi8BJfbxBjVVchkGqiL5lmCnpMUVQ3gTTpagee bqww== X-Gm-Message-State: AOJu0Yyx99Ve2YmZ8HiQ+hcMbsThrwH4spDaw5q38brcO3capegtoHxs Qz51xe6YOa2VnKh/tC5FkGOuRq7A09UooW2JsuQWcWexrYMY8JPX4mzVyUr27dlyXtDVPsiHaf8 cnnU= X-Google-Smtp-Source: AGHT+IHm1M97nLqu40KvKQVJhtyDnLlYC+xWTgcJR2sOG3zEwh38b07rjrbL26r5LBPb67KmcnFvbw== X-Received: by 2002:a05:600c:3b84:b0:425:5f90:ed4a with SMTP id 5b1f17b1804b1-4255f90ede3mr15736925e9.35.1719433120238; Wed, 26 Jun 2024 13:18:40 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:f56c:55b2:2cd4:224c? ([2a01:4b00:bf09:5101:f56c:55b2:2cd4:224c]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-424c8280a87sm37638455e9.24.2024.06.26.13.18.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jun 2024 13:18:39 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------6pDdC0v0FZtLlH1IP27MBC0s" Message-ID: Date: Wed, 26 Jun 2024 21:18:39 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Static class To: internals@lists.php.net References: <4596aa73-cfd4-2292-7191-2839a5bab695@php.net> Content-Language: en-GB In-Reply-To: <4596aa73-cfd4-2292-7191-2839a5bab695@php.net> From: bilge@scriptfusion.com (Bilge) This is a multi-part message in MIME format. --------------6pDdC0v0FZtLlH1IP27MBC0s Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 25/06/2024 16:17, Derick Rethans wrote: > we shouldn't be encouraging static classes as > a bag of static functions, that ought to be just namespaced functions. I understand this is the prevailing preference of a certain few, including (but not limited to) yourself and Larry. Nevertheless, classes as a bag of static functions is a phenomenon that exists and will continue to exist in PHP until such a time as `static` is completely removed from the language, so I don't really understand the avoidance of adding, in the interim, what seems like just a missing part of an existing feature. However, I still want to understand why a file of functions is strictly better than a class of functions. What are the benefits of a file over a class? For me, I dislike importing individual functions. It is often the case that, when such logic is so grouped in a static class, where we use one we may use several such functions. In such a case, we only need a single import statement instead of one for each function. This seems like a clear benefit. Even in the case that I only use one, I still prefer to import a class over a function, because it has better support in my editor and doesn't stick out like a sore thumb in the list of imports (why should it?). Cheers, Bilge --------------6pDdC0v0FZtLlH1IP27MBC0s Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 25/06/2024 16:17, Derick Rethans wrote:
we shouldn't be encouraging static classes as 
a bag of static functions, that ought to be just namespaced functions.

I understand this is the prevailing preference of a certain few, including (but not limited to) yourself and Larry. Nevertheless, classes as a bag of static functions is a phenomenon that exists and will continue to exist in PHP until such a time as `static` is completely removed from the language, so I don't really understand the avoidance of adding, in the interim, what seems like just a missing part of an existing feature.

However, I still want to understand why a file of functions is strictly better than a class of functions. What are the benefits of a file over a class?

For me, I dislike importing individual functions. It is often the case that, when such logic is so grouped in a static class, where we use one we may use several such functions. In such a case, we only need a single import statement instead of one for each function. This seems like a clear benefit. Even in the case that I only use one, I still prefer to import a class over a function, because it has better support in my editor and doesn't stick out like a sore thumb in the list of imports (why should it?).

Cheers, Bilge

--------------6pDdC0v0FZtLlH1IP27MBC0s--