Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115893 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35245 invoked from network); 29 Aug 2021 02:37:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Aug 2021 02:37:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A0BDC1804BD for ; Sat, 28 Aug 2021 20:12:29 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 28 Aug 2021 20:12:28 -0700 (PDT) Received: by mail-qt1-f174.google.com with SMTP id e3so8779473qth.9 for ; Sat, 28 Aug 2021 20:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=K/+JSPMKPJoYFLs3id+7Dytbbz86j7rrFN5H9hlQ9bA=; b=didgBDw1ZsZnuPLc5T4GLs4M0aH/nccFosYCmN9K16gSiTNzbY9JlFWz/W7bhrxFkG FCT96mDyDZzWb4B0/zP4ARSsjr+ip665hHHoLvrsE72d0lF9sBArwtmo709wI5IrHQZe ugXrV6BGqbC+iC2HrUboUE4miRd2qguorRLFTNfaFeblTCI8A6igDCAfNGnqwl4qpHgG SlNlkiUbJfPRQ5s4yTaxfBFKe9NbHeeJhERxCKq7IwQrLhCwNIJZzpkzZmxYHAU/I4dB Noufvo9fJbp2hv/c7QDHIC6Es8aT4WTj+jxvP8vTSW/LbAhZsl/3CAeZLfrlteTZ0Ldj F08A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=K/+JSPMKPJoYFLs3id+7Dytbbz86j7rrFN5H9hlQ9bA=; b=UHPZfIE75pOuzMq7ZPLJELjKKRNjM+iXXB/y/aqkHtEmODkfCRi8WElBomCAyEq0uJ ZwITntC71+mPtDl2GRXtWnxLpmAu1bl5xWhq5HCp83AfzEPxCOuexoA5lTGX14zMeYO0 ymSkIVOU0exr5nNMZ+DYun6DUZNGmmDPw6bsvlDTLDyqMmoIB70ybCUw6fpTb9tcueKZ Xb8CaTX0V2fMWntxC/7NfOw8k/zUpo2JKIep1rxddv7NICV42arKNlQw2C8x+w5KoYdL XDSBfZKCZ5eMGStZsBrBq1pRehIxHLBJiLOsGReiGzXK0BLZg05hFDzGgLw8u+SJ35HK bfVQ== X-Gm-Message-State: AOAM53380b47DFO/fb2xYtkFcL1JNCuHWl8zuSL5VriiqKNsV5eVC4kc o4yNEC7iOob9QIGbTrcsdAGJQQ== X-Google-Smtp-Source: ABdhPJy+72bd7zqk6pvDvNcmahEyZhRBXQAHaez4rmvrJsQELkQYBBLNdZ7NgF7da04YseXPdSnGPg== X-Received: by 2002:ac8:5a02:: with SMTP id n2mr15166159qta.359.1630206746089; Sat, 28 Aug 2021 20:12:26 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id x3sm7952426qkx.62.2021.08.28.20.12.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Aug 2021 20:12:25 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_64A0E357-592F-466D-A0B7-82876876AD2B" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Sat, 28 Aug 2021 23:12:24 -0400 In-Reply-To: Cc: Rowan Tommins , internals@lists.php.net To: =?utf-8?Q?Olle_H=C3=A4rstedt?= References: <6074db02-5540-1831-e77d-0ed8f882a63e@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] Make namespace part of runtime From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_64A0E357-592F-466D-A0B7-82876876AD2B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 28, 2021, at 5:12 PM, Olle H=C3=A4rstedt = wrote: >=20 > 2021-08-27 23:07 GMT+02:00, Rowan Tommins >: >> On 27/08/2021 20:47, Olle H=C3=A4rstedt wrote: >>> As a followup for my previous post, I think this could be a good = place >>> to start to enable attribute writers to create encapsulation = mechanics >>> for composition, like namespace visibility, "internal" access or >>> friend classes. >>=20 >>=20 >> In my experience PHP projects tend to use namespace hierarchies which >> are deep rather than broad, and I'm not sure how easily those >> hierarchies could be re-purposed as scopes. >>=20 >> Clicking through the Symfony source at random for an example, I found >> "namespace >> Symfony\Component\Messenger\Transport\Serialization\Normalizer", = which >> contains only one class. >>=20 >> A trivial implementation of namespace visibility which just matched = the >> exact namespace string would be completely useless for that class (it >> would be the same as "private"). A slightly less trivial >> implementationmight allow access from "child namespaces", but that >> wouldn't help in this case. >>=20 >> However, it might be really useful to restrict usage of that class, = or >> some of its members, to classes in the "Symfony\Component\Messenger" >> namespace; or maybe to those in the >> "Symfony\Component\Messenger\Transport\Serialization" namespace. >>=20 >> I can see two ways of enabling that: >>=20 >> - Allowing visibility modifiers to specify exactly what level of = prefix >> they refer to. This is apparently how Scala approaches things, = allowing >> you to write the equivalent of "private[Symfony\Component\Messenger] >> $foo; protected[Symfony\Component\Messenger\Transport\Serialization] = $bar;" >=20 > Yes, I assume this is why Psalm introduced a new annotation > @psalm-internal , which does take such a parameter. A PHP > attribute can do this, _if_ it has access to runtime namespace. >=20 >> - Introducing a separate concept of "package", either orthogonal to >> namespaces or overlapping with them, e.g. "package >> Symfony\Component\Messenger; namespace >> Transport\Serialization\Normalizer;" would still give a class name >> beginning >> "Symfony\Component\Messenger\Transport\Serialization\Normalizer", but >> would define "internal" to mean accessible within the >> "Symfony\Component\Messenger" package. >=20 > What's the estimated effort for adding package support to PHP? Did > anyone outline a possible implementation? In case you have not seen these, which discuss possibilities but at a = higher level than actually how to implement: = https://github.com/nikic/php-rfcs/blob/language-evolution/rfcs/0000-langua= ge-evolution.md = https://phpinternals.news/45 =20 -Mike= --Apple-Mail=_64A0E357-592F-466D-A0B7-82876876AD2B--