Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129410 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 154961A00BC for ; Sun, 23 Nov 2025 16:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763913623; bh=HOwfFU5kaIDvMazOI9b+HEWqut7fGwYfw/xA/C3lnTc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=eBBIWAMMp6lrXMY5GfCZWYV1/1QOLoRbT+xo9I+sT/TRgAEPZZnooyUVMCQsFZQeB Hm0kbIU+5YkgggelMn8CBDFKb+j847WNC07cCb0iuqutP6wuXZ4dwsoh4uR5whvF4S axmd82zqpPFwav2aQK3cUFtqMO2e/xWXfVZ23iq00/YKh2jCoECKdprfm652GuduZQ vfCFjSvCdNIQMJlCwC2lGGtH8iR9JvRZs33wmdEquL3/Fqv4KV1YvA/HsdrMmIwlnM ZiB1y53ISwfEqEBsKX8ZgzexG8mJfe0h4g0Mum1xljBlynsVHraJugyIT1lN4G6opO SFKAlaUg1pN/w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F232180072 for ; Sun, 23 Nov 2025 16:00:22 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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, 23 Nov 2025 16:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1763913615; bh=to9W+YYFb9VVh1SDyKgLfCmfCPbSQK8+cYDVxx22xK8=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=bEo3rbVRvezHagVdqETNjgRxp6mm0Tx5E8f14lumW71j8gExWlA9ZpDV90rm/DU8t /quhqJapOBbcoGo2i9rIX2geucnMDvyfPUlOr6pvOYRzWojxAA8d73v8+dZS37WjKf NeJVWfjDt5RvETUm1PefESFEjrkvtBzMUcFGQA8rQDU03d+78xw+stSuWYxtnmPWA5 NWq4hnWk34xCM7jdERmXgGSCK8+aw+1x1bZP1sTErk/kWwdVavg3qq6MBtN530BKz2 StBtl6muJluTGnT0JrDFZO8MUv2vp7mnpx+IDN1KQj9SiQEp6anAdZ1qI3tRfx76Lj SAOHfxx/lVhsQ== Message-ID: Date: Sun, 23 Nov 2025 17:00:15 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] RFC: Namespace-Scoped Visibility for Methods and Properties To: Rob Landers , internals@lists.php.net References: <72f90052-fa19-415c-9f5a-ae75275fd030@rwec.co.uk> <2d9f8f1d-e568-4bb5-b30c-0a9e54a8f5fe@rwec.co.uk> <8978174c-04fc-451a-8bf5-cb7c54346318@app.fastmail.com> <1606b9e5-62b8-446b-adac-519ac19d01c3@app.fastmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 11/10/25 20:19, Rob Landers wrote: > Updated RFC: > https://wiki.php.net/rfc/namespace_visibility From the RFC I'm seeing that it's legal to redefine methods in different namespaces? I've only figured that out with the last example in the “Preventing Visibility Reduction and Incompatible Redeclaration” section, it might have been hinted at with “However, visibility is enforced based on the namespace where they were declared, not on the inheritance hierarchy:” but if it did, I didn't understand it. I also don't believe it's useful to allow redefining namespace-scoped methods from a different namespace, since they would be *severely* restricted and also confusing. Consider: namespace Foo { class P { private(namespace) function x() { } } } namespace Bar { class C extends Foo\P { private(namespace) function x() { parent::x(); // illegal } } $c = new C(); $c->x(); // also illegal, despite C being in the current namespace, so everything should be accessible. } I stay with my previous note that cross-namespace inheritance becomes unsound (and confusing) once namespace-scoped symbols are involved. I feel that namespace-scoping needs to be restricted to top-level symbols to be easy to reason about. This also brings me to the next point: What about free-standing functions and constants? public/protected/private doesn't make sense for them, since they are not part of a inheritance hierarchy. But namespace-scope would be meaningful. All in all, I feel that file-private symbols would solve many of the same problems, but be much easier to reason about. The SessionManager from your example could just be file-private. Best regards Tim Düsterhus