Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123359 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 9A6721AD8F6 for ; Sat, 18 May 2024 19:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716059775; bh=FcaGq+2zBf7ASDMdh9YbQ27qhnWzqdATmhPGtAClcBg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=nfagN4zVIRHrOovrioUnWyuagBAgP3vX6z/0rlU9lQ0lwE0sS/PNE+WClzkZNg0I7 Lk9yJDNTxL/oE5SI7yW1xfAg+uVNX49+JthB3nurSVRB7h278y+4jI/xeu1tPTIFgP /q605qW4wuFeozzIzmshJXSw08+EE6DgpQXDQgwc2lm4T4c626wDz3AnxhEPo7YHyG HVOp/BmTbOInNAneathzT6+hR3Qdcon5u/zXpsJ669DUUy/Tb2rO1GZ26z3H0NBqMU 0P4Lfe5xXU4A1ZBnTAaAxk+Y3X90I0lMIFC5/JRytkOOPZ/8h3GJ/jTtEaHWj1SvvZ uoXIfmGAAaAsA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AB5EC180557 for ; Sat, 18 May 2024 19:16:12 +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.7 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_SBL_A autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from sender-op-o17.zoho.eu (sender-op-o17.zoho.eu [136.143.169.17]) (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, 18 May 2024 19:16:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1716059711; cv=none; d=zohomail.eu; s=zohoarc; b=gXPxs6q3oyYHJtQUEGJJKyJP48IMhrjbf3XyCRcPLbxEu8CWuXlyrWC6E0O0cy6UCxR2n0TFPrBxaGkzVvkvoIrLDhfPQlf+rMiau0c1Ma6EhRip7bKUoYeZdLky1y8GbmaJwril/84FcpJfCY6sG4kF0+LUO5WpElGAnGl2xcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1716059711; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=P+FSm0FUUJ19x1p8BwSPY2cF3WV7l41QSM7ArShb9uM=; b=ezEsO+YBxU17D2/hbN/Nr18jvOckkF8yL7NylDnd9fzO2sqIVT8t3IirQZ+9GE/3slyQkQtV40gucpENUMM1jhlzSIvJMs2uysOHGBSww+0ex1X9gxAsVLO01M3bjZnzB7XP6LFFMdshiir0c7F5WaTC6G09+owxVWLG3cU+Vg8= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=barneylaurance.uk; spf=pass smtp.mailfrom=barney@barneylaurance.uk; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1716059711; s=zmail; d=barneylaurance.uk; i=barney@barneylaurance.uk; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=P+FSm0FUUJ19x1p8BwSPY2cF3WV7l41QSM7ArShb9uM=; b=EIXzptco1LXAPgZh93R9WJTEbYd3e5bLVDjTr6UfjkRnpAHUL8Jiu/G4uMXdLD3o hZhAlFZntlXomKGWvhCT6tY7bHtLmbiIQag/thcKWW8e1HvLp3kUmq55WvF2CHAvQ4M ReMOCDfQ7RKQGi/UX2Dh43kl7RUgoGPbF5SJkNPc= Received: by mx.zoho.eu with SMTPS id 1716059708115791.1427786720283; Sat, 18 May 2024 21:15:08 +0200 (CEST) Message-ID: <35f6f3ce-fc7d-4911-8a1a-a06f8e17fe71@barneylaurance.uk> Date: Sat, 18 May 2024 20:15:06 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [Discussion] "Internal" attribute and warning To: internals@lists.php.net References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ZohoMailClient: External From: barney@barneylaurance.uk (Barney Laurance) On 18/05/2024 15:00, Robert Landers wrote: > Hello internals, > > I've been thinking about having an "internal" attribute that will emit > a warning if called from outside it's left-most namespace. Hello Robert, It's worth looking at the prior art on this - the @internal annotation from PHPDoc, and its implementation PSalm, PhpStorm, and also the @psalm-internal annotation, which I added to Psalm. @internal requires the leftmost namespace segment to match between declaration and reference, while @psalm-internal is used with a specification of the namespace to which the annotated element is internal, which may be a deeply nested namespace. I had the idea to create @psalm-internal originally because the Drupal project was recommending plugin and site developers create independent work within the Drupal namespace, while having certain elements documented as internal in the Drupal\Core namespace, with breaking changes in point releases. Another prominent left-most namespace with code developed by people who might like a tool to help them avoid depending on each other's internals is League, as in https://thephpleague.com/ I think if something like this is added to the language it would be a shame not to give it something like the flexibility of @psalm-internal, instead of only dealing with the left-most namespace part. See https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/internal.html https://psalm.dev/docs/annotating_code/supported_annotations/ I'm not currently a PHPStan user, but from what I read PHPStan doesn't have this feature but has started considering it: https://github.com/phpstan/phpstan/issues/1178