Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126955 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 B86C21A00BC for ; Wed, 26 Mar 2025 04:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742964491; bh=6/cAV2L6KQAMwjoDE79XcxT68zX8WqWaZnRC/ug8iTw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=GV7IatsQV0S+VsVXkxn1dGzHgdrQl7xz5svrph1Nf1/OuEaHlXIY/P+7GxGi5+A7Z zw7kcTMERcqLxa6j9KHubW3OnEXxwPAugVXyt3ekBhhTrwJoreLMN7U/MkthwXD96d vPrvYw2mla9ZedgJ59vq/RQQdyJch4ax2aGn0o/79KpMfSK+1xFP5yDoOc9yuunubL OIlvWn0yyAg+QWn0QszjF2T9Qyn+sag/KcPDp1t9iSLaivdGrwK0Q9OhKoDkFqh7t8 UcHA7Be9iHq4lBeADXxWq63T0kdyxCn56QjTuyVTphTrsjJtGepzYMtEpzecyG6xX4 1GLEK1RXzfAUA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BD78B18007C for ; Wed, 26 Mar 2025 04:48:10 +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_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,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 fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 Mar 2025 04:48:09 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 30C9E25401CC for ; Wed, 26 Mar 2025 00:50:38 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-04.internal (MEProxy); Wed, 26 Mar 2025 00:50:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=1742964638; x=1743051038; bh=rjLqttwBbwQV4O9+MZEtr xXR4qaAWpOYHo5NPJGdrM8=; b=WOwbNtoK9bx3BsjjRb1wPg4LdCqZriGzjAUIA /5F2wQLVved7uUf+uiTOwyAGLzMEaOZshkDvSfneXMHKKIXmt8yh77LMafNVTPW0 4nBO/RxYSiNfj+4JWkQfvMfXhycxIQS87cPCRxLcK6N0AIGaR6vtx29bTkDgeoPe 6q/0W6rYDFCMwu8JULQOX1BtwPnrSgPJTUu8MdPbjvSNcDsYcDeza6jZBo4wCGI2 elVKqafYl2AZv8eUwx11gGLbDmrs/qr0V7IEV+/1zn2NoNinFwZMCV/eAoV9roHU rp2/pu1ywNYhGM30Iw15IKBpFxXMJriPJn+ZQoAAmtve7u0IQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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-sender :x-me-sender:x-sasl-enc; s=fm2; t=1742964638; x=1743051038; bh=r jLqttwBbwQV4O9+MZEtrxXR4qaAWpOYHo5NPJGdrM8=; b=bGMsyVsDJg1mkk8sa aZCXBdkCER0Rj/cZPJVxPcAonIUtps5BTeNtxXd+x9X0NfTd8O4iS6zKW8wi6g3W HHpkKrd5QPGQhPdZA0M4qfTRkFl1FGQsHYUcUhYy7pMWttbaEcmiKj6p/brGPJZH hxnKcUF/yya8Zy47utuS+mJ9h9Ackhzh3dZQ3HDVa7vfwWrjvUQeJF5px34+bE6+ G7IgGi0crNsM9HkWqvFr4cqhiVmuIRMIeHXoNBBJiHmUGf2lXHXzl7Yqfj5bR8em yRIEeeBVE/+bqaBoqzAdoYwbzuCXRQC3xGKtqj7I+2GrDVAlb7iYHMf/nbMfWeAl HRe9w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieegieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthejredtredt tdenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpedugedvlefgueegheef jeetffduveeltefhfeegjeffffelgedttdevkeegkedugfenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id ABF1D29C0075; Wed, 26 Mar 2025 00:50:37 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Td94a63d0143dd548 Date: Tue, 25 Mar 2025 23:50:17 -0500 To: "php internals" Message-ID: <95d8b8ff-f3af-4e5f-a368-e89dd73be368@app.fastmail.com> In-Reply-To: References: <3e4ba7ea-a154-452d-abfc-05ef1322fade@app.fastmail.com> <782d76d9-711a-4cee-ae0e-fe0d69973f53@app.fastmail.com> <48dce917-d147-456b-9f03-c7e23411adff@app.fastmail.com> <8a16b81c-7dab-4523-a352-76ba0cb4e771@app.fastmail.com> <9c4ac301-dfb2-49da-90e5-37a2824fc4e3@app.fastmail.com> <5b1e6d70-a1c9-455c-93d3-6b22cf1fef11@app.fastmail.com> <52d84a5b-09d3-4e42-9620-a62fb239c21e@app.fastmail.com> <09a82882-f1ee-4bdb-8a27-e46144a711f1@app.fastmail.com> Subject: Re: [PHP-DEV] RFC: short and inner classes Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, Mar 25, 2025, at 3:29 PM, Rob Landers wrote: > File-private, in my mind, is different; such as when the classes are > distinctly unrelated with respect to each other, but nobody else should > be able to instantiate or use the private class. It is like it doesn't > exist outside that file. For example, something like a log formatter or > a default strategy implementation. Personally, I'd feel that > file-private should be kept as simple as possible and limit it to > "top-level" things, but that doesn't necessarily have to be the case. > If we did allow it on methods/properties, when mixing it with regular > visibility, what happens? `fileprivate public private(set)` ... means > what exactly? I assume we probably wouldn't allow that particular > scenario, and maybe `fileprivate` on a property means `public` in the > file, but `private` outside the file. But then how would that intersect > with inheritance? My point is that I don't think there is an intuitive > answer to these behaviors, but at least nested/inner classes, while not > 100% intuitive either, at least are available in other languages, so > its behavior will be familiar. The aviz RFC was designed explicitly to support this sort of case. :-) (Module or file visibility.) The syntax was borrowed from Swift, which has 5 levels: public, package, internal (within the same module, which is apparently not the same as a package), file-private, and private. The syntax for a visibility modifier is $accessLevel($operation) If the $operation is omitted, it means "any operation not otherwise specified." Right now the only explicit operation is `set`, though there's no reason `get` couldn't be made available on its own, too. We didn't, because right now there's no reason *to* do it, either. :-) But the logical structure is there. If we add more access levels, we just have more options for that part of the modifier. If we add more operations, we just have more options for that modifier. So if, hypothetically, we added a `module` visibility between public and protected, and added support for controlling the ability to unset() a property separately from setting it (for whatever reason, bear with me), the syntax extends to that quite naturally: public fileprivate(set) private(unset) string $foo; (With the standalone `public` still being optional.) Methods only have one action, call, so there's no aviz to consider. Just `fileprivate function foo(int $a) { ... }`. There may be other edge cases and gotchas to consider (eg, traits, as you note), but the syntax to use is already defined. --Larry Garfield