Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121717 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55490 invoked from network); 19 Nov 2023 21:28:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Nov 2023 21:28:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C833218002B for ; Sun, 19 Nov 2023 13:28:13 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail.online-presence.ca (online-presence.ca [216.128.176.244]) (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, 19 Nov 2023 13:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=online-presence.ca; s=default; t=1700429290; bh=3wROCdWkBRo9LmA0goRy9Ydj5B+1KtftobIMgx+nvKw=; h=Date:To:From:Subject:From; b=NYW9MIVzlDSPbZPmq+XV92JZ9VcQOhxK4oC9zI5Z4xrbbd8pjSshyAnkyPmI0OhVF aS0ihfNTWs+gszv2EH1sYmOtPgl+9FWQs64aju2xvhheWVm96AyhmpVWYl/v9PKtDg bkvHH4LgT5pRLddWmtdyVH2DOkEhNZKr4X1E9Ip0BLzMCL8rgatDtQb1AUJsxOoHx1 2Toi1bXt9mffWbbpq79HEXEkd54hTgpQMl6vpB+5F66VzqjbhSSpnut9AlODgAc/y8 2lKA2SjNoVqFqXOfW26NnsKxEEiIq3i71Qam+kdjHmtHCqMlesWVi82LfHGjobIhDv xU3B/LVCMfCUg== Received: from [10.0.0.211] (S01064075c3d865eb.ed.shawcable.net [70.74.109.64]) (Authenticated sender: lanre@online-presence.ca) by mail.online-presence.ca (Postfix) with ESMTPSA id 208ED105BBF for ; Sun, 19 Nov 2023 21:28:10 +0000 (UTC) Message-ID: <79d675e3-95b4-40bb-baf4-3e1c998f5390@online-presence.ca> Date: Sun, 19 Nov 2023 14:28:08 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "internals@lists.php.net" Organization: Online Presence Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: [PHP-DEV] RFC Proposal - static modifier for classes From: lanre@online-presence.ca (Lanre Waju) Hi, similar to the abstract and readonly modifiers to classes (similar in syntax only), I propose a class level "static" modifier that ensures: 1. The class cannot be instantiated and will throw an exception if attempted. 2. All methods and variables in the class are implicitly static. 3. (optional based on community input) It should have the same effect on traits and interfaces For example: static class X {     const int k = 1;     private string $a     function foo():void{}     private function bar():void{} } would be equivalent to class X {     const int k = 1;     private static string $a     public static function foo():void{}     private static function bar():void{} } and so on. I will be implementing this myself it it gets approved. Cheers, Lanre