Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123611 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 7393D1A009C for ; Sat, 15 Jun 2024 11:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718450257; bh=d8SZw/UdKB52JFeSrKoG3zXYq4h+7IDW9m56FUxUmSs=; h=Date:To:From:Subject:From; b=QOAmelfHh1jwdUnrDlOdH3ZlyIV3ScVxZH7cTmvElPJ0v6SEIHqCuxGZY3V0S+CZa FKk6EN179Iai2VqqVZu2lc1l8eWQMufYvnpZRfDhDiZWGZ64BgQrwupMcs0RjwupgP NpkHsFZAvTM1o4CtQ9vc6g+QW5LKSAvjHoA1GD3o6+Mv+qkSxSyRB3mgS9XDoz91wS w6MI6ohAiCe9jrovvF1rED0Tfh88w6A/RSzzognkjzUw+kia8JE/JnOtheq4fTIXCe tSpsdRbgxXdH6iC2o9Xdv5once2LK+f5b0yW8s15KMrTN0zqwOqAnxQ4C/gIntxqIS 5DC16Hfrbk5yw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 94482180003 for ; Sat, 15 Jun 2024 11:17:36 +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=2.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URI_TRY_3LD 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-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 ; Sat, 15 Jun 2024 11:17:36 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-35f22d3abf1so2712672f8f.1 for ; Sat, 15 Jun 2024 04:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1718450184; x=1719054984; darn=lists.php.net; h=content-transfer-encoding:subject:from:content-language:to :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FlCFDxxmkT/BtH8XKqa+HkJUdlvMH2UeDU7RCluMpZ4=; b=FnAtU1CUGGDv1VXfNYsU9JYjfgKvifIVCyBHfDoF7dQbbBNezznOMJ2SqqqDrNZRi/ n46Tyoq8xl2No9vlIItA/YCHs8YymzmeWvtnKrwMbePN2FJ3XhqFyIRy8RTacB2HyIsl 80H/SyOt6N9xnPUSV4d8kMlDgAuFWO1qYID16IDG4Laczhh0dj2eE9kK+uN/FyPNYgRZ 3Z9roS8ZvNP4dVjruojgh0EEHPI+aRp32AdL8+DxzgoZxzV54aWDrbyDfdiRSPGLNXfI HTevXoCnyAJhid2ZPyDTtJ07+99hXCaKDDSP/LU3TW2CkeDvJam4WF5tvE4fjVpC+2s7 iI6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718450184; x=1719054984; h=content-transfer-encoding:subject:from:content-language:to :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FlCFDxxmkT/BtH8XKqa+HkJUdlvMH2UeDU7RCluMpZ4=; b=U1t+OHiKn8yKjoiTitM2m1V2/u8nzgnJo/dhxBzIznQxYFKxsxX4vTKrY564UUpFHO 0EUd7Q2WFMDcQvElOZCEOb8yxDgt8YBU4dOMEzcKWQK/FaWVOKCXD741Lke4BE2v4Rd2 +dayU7//Ubg+RZJ+oUS83kHI8uCtCv95KnJ1x0vSZrKReGgKt4QYd3ydLBYna9Xofsba dDDArIo4IIij8ARdR66W7N7XP/ePzhEEVQMBs1RnGqOq/QCDiGE3ZjDXOzkWUAt2QaFe u/mqPB2ho1lplb61bl0I8LqQ+Wt+6hE5FQv5qw4cynUCT9fcd80gxI7CVBu4wjX2h4qc 6ZeQ== X-Gm-Message-State: AOJu0Yx8Usds5IKzfrJRkV8pHDjgmihTXl1ICSuhhnr01XrR3vwqd6gK b30uu9pObKOdcWZQzxKyRbDxKIkdjNKWLaYt1gN7D/5uVTupn9QCZ61K7nfr6PH8LDYMYq2weCQ 8fWk= X-Google-Smtp-Source: AGHT+IEUbiC/89EgN3ZUw9XOadIRfxAGSn6V50a1eMsAsrGNfaDN/SNHtQ2d6XrZrXQTKK+mTUCOvg== X-Received: by 2002:a5d:44ce:0:b0:360:8911:a7b2 with SMTP id ffacd0b85a97d-3608911a88amr1329932f8f.55.1718450183955; Sat, 15 Jun 2024 04:16:23 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:7030:8554:1648:c9b4? ([2a01:4b00:bf09:5101:7030:8554:1648:c9b4]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36075114dcfsm6792626f8f.114.2024.06.15.04.16.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 15 Jun 2024 04:16:23 -0700 (PDT) Message-ID: <0cf69a14-f1b5-4077-9d91-d7b579485eec@scriptfusion.com> Date: Sat, 15 Jun 2024 12:16:21 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: internals@lists.php.net Content-Language: en-GB Subject: [PHP-DEV] Static class Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit From: bilge@scriptfusion.com (Bilge) Hi Internals, I want to introduce the `static` keyword at the class declaration level. That is, the following would be valid: `static class Foo {}`. A "static class" is one that only permits static members (methods/properties) and could have similar semantics to a static class in C# . In particular: static classes are implied final and they cannot inherit from any other class. These specific semantics are negotiable, but in practice I've never seen the need to mix inheritance with pure static classes. A static class can be emulated somewhat with a trait in userland, and I have long used such a micro library for this purpose . This works by forcing the constructor to be private, thus preventing instantiation, but it cannot guarantee that the consumer does not create any instance methods anyway (just that such methods would be useless as they would be inaccessible). Ergo, it would be better to have this as a language feature so the compiler can provide the necessary guarantees and warnings against improper use. I am not too familiar with internals, but I figure I can probably muddle my way through an implementation by following the readonly PR , which I imagine has similar touch points. The main thing I'd like to ascertain at this stage is whether such a PR would have support? Kind regards, Bilge