Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115887 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49800 invoked from network); 27 Aug 2021 20:32:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Aug 2021 20:32:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 66DA41804BD for ; Fri, 27 Aug 2021 14:07:25 -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=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 ; Fri, 27 Aug 2021 14:07:25 -0700 (PDT) Received: by mail-wm1-f49.google.com with SMTP id m25-20020a7bcb99000000b002e751bcb5dbso5169615wmi.5 for ; Fri, 27 Aug 2021 14:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=jTfGtLVD9SVWU3z0Md7ZqHbC4iZ/HRGjKDcwj28Yy68=; b=AS+elsspU07DTgE23xIJbH5vjkCeNwjX1F7JRKICdu6QGx56u2c7a57RRrISt+qwz7 pj6E1drNRIFH0Tn6YtRgbURZJp1TB5oWAoQhMczituBpICT5tyf8iSOjrTevChpLzXsR LoeU1E0vGLQx8vc3UUK2gOxpN6OWVh2vUnDJuslsLr8gYc1zeOSyBfHwoWar/IoQZ47n hFeJhFJ7QSmEIMFdBQIsh/AaXe1lbwsYj6ZRU8MWUUbBlb79C74EBM3nfWAAOSbx4byA Xvw9CatsbOo0lKtLnS9EpOqweFMbV87JMBp9FTwNZSXH0UAkLmc3gnJORPQtIiKZ06di 2GLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=jTfGtLVD9SVWU3z0Md7ZqHbC4iZ/HRGjKDcwj28Yy68=; b=ZQAjb3VLQQQgKPy0MmiQ3jxjvXxZTwpMZyq5jjn98GeJXIE/z7HMfe1GnoCLuumN3O cfK6IzFlXrHKETgPTkzttJZTK2ojKqd5SGL/shpF54SO6EeTnu2CTcbxU0cM/py1GNIR XzmNos2QHC2/KKY1VOmyfChvX0LiHw7vkoqN4BbvoqayuA1JSjA90FmeNTZhVRN9FD78 ZgwdILpj1QHoGVO0Wdi41mqyKBcaidEF9mj2rHEtguncyx1KO8Jc51H5IqYXDItlI+i0 nyzzW7U8G4DbglZumQgJ2vGNELvvAaRHKeNwOEuVdU9pJOQ8wLLpaudO29hWpJJe3eXS peAg== X-Gm-Message-State: AOAM530pLsQrO+IW4Xk67/Cq7nxiwIjiNTTUK+7F3py/PvN7ZmozXpt6 lZEtfMPrbNiRklW8D5x9UKZpWadj6nI= X-Google-Smtp-Source: ABdhPJyI1tvj2y7Wo/9q5Z8BLq0qnPV9iAAsFqj0ei7l+mlfFZqgNf9BkxZ8zQDVO4c8JszT2mf7/A== X-Received: by 2002:a1c:980d:: with SMTP id a13mr21647642wme.68.1630098443033; Fri, 27 Aug 2021 14:07:23 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id d7sm7634197wrs.39.2021.08.27.14.07.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Aug 2021 14:07:22 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <6074db02-5540-1831-e77d-0ed8f882a63e@gmail.com> Date: Fri, 27 Aug 2021 22:07:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Make namespace part of runtime From: rowan.collins@gmail.com (Rowan Tommins) On 27/08/2021 20:47, Olle Härstedt 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. 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. Clicking through the Symfony source at random for an example, I found "namespace Symfony\Component\Messenger\Transport\Serialization\Normalizer", which contains only one class. 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. 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. I can see two ways of enabling that: - 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;" - 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. I'm personally quite keen on the idea of packages, because they're how a lot of PHP code is developed in practice - as modular libraries linked by Composer - and I think we could optimise the language for that use (e.g. applying more cross-file optimisations within a fully preloaded package). Regards, -- Rowan Tommins [IMSoP]