Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124579 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 545F11A00B7 for ; Wed, 24 Jul 2024 19:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721850338; bh=T6shtC3SrpEYF99KBXDbaBFLyELkBOQJB3utM7YXgvw=; h=Subject:From:To:Date:In-Reply-To:References:From; b=mHAZmLm0BPWZUDh4UvnJF264Fo6ymzemIO6qeNhzpSBDIce+uTjl8wSqmfQffHR1d V1Trwy7yxtKrUrmhReCLQ3RnzuIcHPr68EsTIqf8/acXUO5idtpnWMSUz5zB2DYhw0 glokEZgiTZTN5Kmbn6ZMiAyE5pZXFfrD/e1G3xF1CInU37DV+1pqKf3/gH1tcbaVrF pQlmNCSdYCVIqWb90LvU1huoLf9eisPGVRETzLKlIbl2F3N7NiuIrv74hdpY3uzjLZ GODIaNrbej1KeOLvHb4xfI55BKOHTmsgdwX87mMBnT7MyXdBofB94WK0NEVBYF705Q BmBtmpvJqHMDw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D636E180057 for ; Wed, 24 Jul 2024 19:45:37 +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=0.6 required=5.0 tests=BAYES_50,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 ageofdream.com (ageofdream.com [45.33.21.21]) (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, 24 Jul 2024 19:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ageofdream.com; s=ageofdream; t=1721850242; bh=T6shtC3SrpEYF99KBXDbaBFLyELkBOQJB3utM7YXgvw=; h=Subject:From:To:Date:In-Reply-To:References:From; b=VgPR2cRwOwb9kr61jFZTBTBVY7dAfZy7m9egQL8+KfTx7YCpMzDNvMVGgzeP58nQD b4YtClTLiQkXbDAeUom11VEuryYvd/UQ/z6xmwo9OEWcBBXS/vleIV7EQtcVUAAdRe mzjkIhBFf9UH6A279z6wLAj9EPUOIbcjV826RFEN52LPvo0sMXwd61dLVIXhVCoTQM T5CdmVlLQsAdLNBn6Ir5BEsc6oX7R2+lCTNGgpq3cEoVfT/MaiYgrXwTlbQ8fOv6qj 6EkTvn4qYabk/5V/QDI2ngqOIhO3IWNYZCnxZaNnkJ1rDxlfPk960+LXwPQlWCaY+W hefrRxGzIlz5w== Received: from [192.168.1.7] (231.subnet-69-85-112.ellijay.com [69.85.112.231]) by ageofdream.com (Postfix) with ESMTPSA id 0BEF52508F; Wed, 24 Jul 2024 15:44:02 -0400 (EDT) Message-ID: <927705b0404e70b0f0ade4a3354b2598d7c112f9.camel@ageofdream.com> Subject: Re: [PHP-DEV] Should PHP reserve a namespace for built-in classes? To: Tim =?ISO-8859-1?Q?D=FCsterhus?= , internals@lists.php.net Date: Wed, 24 Jul 2024 15:44:01 -0400 In-Reply-To: <95f6046a-4acf-4f8a-a850-a23650c0c6b3@bastelstu.be> References: <76559a9cd5eca4bc6799ed9612ce15c28cd7cb0a.camel@ageofdream.com> <95f6046a-4acf-4f8a-a850-a23650c0c6b3@bastelstu.be> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 From: lists@ageofdream.com (Nick Lockheart) On Wed, 2024-07-24 at 19:51 +0200, Tim D=C3=BCsterhus wrote: > Hi >=20 > On 7/24/24 19:43, Nick Lockheart wrote: > > What is the general feeling about reserving a namespace for PHP's > > built > > in classes? >=20 > see https://wiki.php.net/rfc/namespaces_in_bundled_extensions >=20 > Best regards > Tim D=C3=BCsterhus Thank you. I've read through the RFC and see it was approved. Is it too late to comment on this? My concern is that placing things into new and arbitrary namespaces as per the RFC is just a different variation on the global name problem. The problem, as I see it, is that new names that come bundled with PHP can be arbitrary. If new bundled classes can have arbitrary dictionary words as the namespace, then we may actually have a bigger problem as no name space is safe from future collisions. The biggest problem with built-ins is that you can't unregister them. I think a better solution would be to have one namespace for all bundled classes, so that a specific namespace is reserved in advance. From the RFC: > 3rd-party extensions clearly cannot start out under a PHP namespace, > as they have no direct relation to, endorsement by, or oversight of > the PHP project. If all symbols in bundled extensions are to be > prefixed by PHP, this would require a rename of all symbols when an > extension moves from 3rd-party to bundled. I think this is the real issue: How could we use a small number of reserved namespaces for built-ins, but deal with permanence of those names as things move around? What if we had a grandfather policy? Once a third party is accepted into core, it gets a core namespace. If it is later removed from core, it gets grandfathered into being allowed to use the core namespace, even if it is once again third party. The RFC did mention that once something moves to core, it seldom moves back out, if ever.=20 There was a vote on something similar four years ago, 13(no)/17(yes), declined. It was four votes shy of passing: https://wiki.php.net/rfc/php_namespace_policy There was more in that proposal though: the use of component namespaces in addition to just `\php`. Could this issue possibly be revisited and voted on with a more narrow scope? I think if we reserved `\php` and `\ext`, then there would be no need to have multi-level namespaces, like the prior RFC proposed. I think every standard class could just be `\spl\classname` without any naming conflicts between core classes. And that would also avoid future namespace collisions.