Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129156 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 lists.php.net (Postfix) with ESMTPS id 1442B1A00BC for ; Sat, 8 Nov 2025 21:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762636822; bh=Y0/87AMxbxIYDmYlVhZzSpjz1zgY9+St7BzVDoCHGGc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=frPSeJrAv2Lg1qjM+e12fW6m/ROAaXgFORLk5dbnsJW13nuVTogqQNIM9a6btxKGI jwOUCvr/fJgw51ueR8dJbIBuSODLs8XlHIXBdxF62/p7Dspn/wQq++psSxiIcMfeIR hMI9UaHPSzh2lMKdM5A9gfrDtOa2pqjmHa2OW1CzX+ruI+MyHYoCnHvWUvFrjBNU8S ubAuptMCTS0FptXAfCc/1jwQALjWic8JGzmlLeVFaKuTkjkkHl1mYVdKi9lz0hCJJg bJbWyC6bNOeZu0FJFhR5OyWZvKskTfhoh0nI/ckbGOR0nt4Nz/lAaLrimzEKSDaLWm JFBYt7T1YD2sw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 30F0718006E for ; Sat, 8 Nov 2025 21:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) (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, 8 Nov 2025 21:20:10 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 73D561D00133 for ; Sat, 8 Nov 2025 16:20:05 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Sat, 08 Nov 2025 16:20:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=fm3; t=1762636805; x=1762723205; bh=JrUlBko0jBrl3FIatpF+tRgzpxvs/0cE+6H3FKXJUec=; b= PDcM72v+OFmn2f3DO5qDD3dwVly4G6yJyDG8/hEGpT8Q29MWHLRFNLt5tLPvDr9n N+g7WFPwdXScS5qE7iBSX1vnzaLCiZzbPw3l6SormzpnEnbJp3fTS2+SY2Yd8lKh owKWkNMpic+dUhamHm6WVbUOdXgq8xcQjztLfJmTqtcSvz7azVcipthrMMuZKK5A rCxaLc1U6s4r5gfKG3tHUrIlJRZOO7GQhKKvPnh/lOqbURA55dvd04G8mbzO/n0f Pae+RHPdgNNpbQ2Iy1iRi+kb7EOtqAGWf4Xj+qWr0pFpm8tFs/4opHEHRwOX98T0 ta+6bWe6D+S2r2Fas3Gm4w== 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=fm3; t=1762636805; x=1762723205; bh=J rUlBko0jBrl3FIatpF+tRgzpxvs/0cE+6H3FKXJUec=; b=jIgIE+nbzuVCjhm9s ICDapU1fjpZo3KYOARjhXuDbOSyxswshErx2rHBYMqhgtPYx/oxN8xEwHFhVhWQI /UCryojiQjSH+0pKom9L35CzNVBqW21ur8GWkMWeHv0HegZrAQPhlHBxb/8Hmtuu 2cCpwymn7G72kAUWerCiN+5A3zPPwRVs/l3VWkSiAs/YXOxsiDgumUjnoSIQgk9W 7Yb585T//fqKWJODsGuXDMC9vZvtJu/oMi2G5UlhjkrsgEpVXUS99SNg+GwryUwv 3ypGdKS3lBp4+rlWfBmLJ5hNZ9n3oYP1gaLd90oaqy4tedA+tvzJwc5/DVS1m99w too1A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduleefieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertd dtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceo ihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeffke evudffuddvheejvdefkeelfedtudegfeehjeduheegieduffeggeegveefheenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhphh hpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 8 Nov 2025 16:20:04 -0500 (EST) Message-ID: <72f90052-fa19-415c-9f5a-ae75275fd030@rwec.co.uk> Date: Sat, 8 Nov 2025 21:20:03 +0000 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] RFC: Namespace-Scoped Visibility for Methods and Properties Content-Language: en-GB To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 08/11/2025 20:08, Rob Landers wrote: > The moment we allow "namespace prefixes", we introduce questions that > need to be fleshed out separately and with care. Do we treat > "Acme\AuthLib\Session" and "Acme\AuthLib\Services" as related? Even if > they come from different vendors and are unrelated in any way? Are > namespaces hierarchical or just flat strings that happen to contain > separators? While I appreciate the desire to keep things simple, I don't think we can avoid asking those questions, we can only propose answers. In your current RFC, the answers are: - No two namespaces are related, even if their names imply a hierarchy. - Two "internal" classes in the same namespace can see each other even if they are written by different vendors. > Today namespaces are a name resolution mechanism, not a semantic > hierarchy. Matching by prefix would start treating them as a package > system, and I explicitly am trying to avoid that in this RFC. I don't think that's true. The language already recognises the namespace separator, and that if you are in namespace "Acme\AuthLib", an unqualified reference to "Services\SessionManager" refers to "Acme\AuthLib\Services\SessionManager". That doesn't require any concept of "package", but it is clearly based on the conception of namespaces as a hierarchy. > By restricting the rule to exact namespace equality, the feature is > straightforward to explain and to understand. It also prevents > "accidental" access because two unrelated namespaces happen to share a > prefix. My concern is that by restricting it so much, we would prevent most of the real-world use cases for it, since the reality is that people use much more complex namespace hierarchies. > If you have a concrete, unambiguous rule for prefix-based access that > wouldn’t cause surprises or make assumptions about how people organise > their codebases, I’d be happy to discuss it. Right now, every version > I’ve explored would reopen the "module"/"package" debate from this summer. I mentioned, briefly, two possibilities: > I think we need a keyword or attribute which takes as a parameter > either the namespace prefix, or the number of levels to match To spell those out, the prefix version could look like this: namespace Acme\AuthLib\Somewhere\Deep\In\Package; // ... #[NamespacePrivate('Acme\AuthLib', includeChildren: true)] A number of levels version could look like this: namespace Acme\AuthLib\Somewhere\Deep\In\Package; // ... #[NamespacePrivate(minLevels: 2, maxLevels: null)] There's all sorts of variations on how those arguments could be presented, keywords vs attributes, etc; but the key point is the language is not defining where the boundary is, it is requiring the user to do so. The prefix-based approach could be expanded into an allow-list that didn't require any relationship to the current namespace at all:  namespace Acme\AuthLib\Somewhere\Deep\In\Package; // ... #[AllowNamespace('Acme\AuthLib\*')] #[AllowNamespace('Zeppo\FrameworkCore\*')] Or even an allow-deny rule system: #[AllowNamespace('Acme\AuthLib\*')] #[DenyNamespace('Acme\AuthLib\Plugins\*')] At that point, it's admittedly rather complex, but it makes *even fewer* assumptions about what constitutes a "package". -- Rowan Tommins [IMSoP]