Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112981 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27505 invoked from network); 25 Jan 2021 13:22:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jan 2021 13:22:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 28C111804A7 for ; Mon, 25 Jan 2021 05:03:48 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-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,HTML_MESSAGE,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from 02b.relay.hey.com (02b.relay.hey.com [204.62.114.229]) (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 ; Mon, 25 Jan 2021 05:03:47 -0800 (PST) Received: from hey.com (bigip-vip-new.rw-ash-int.37signals.com [10.20.0.24]) by 02.relay.hey.com (Postfix) with ESMTP id 68F781BF7CE for ; Mon, 25 Jan 2021 13:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hey.com; s=heymail; t=1611579827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1hqG+YUUwsR7ZJxJXKbbZ8c8tRSpjWqYe9egO/WL/TE=; b=oIAPJtAvoveadRmi3135rjvY5rrIsqEPNjz8ljtSGPl/K2hyzB/TTUYnaRLMDFJAI9A3IG /2LzkaD5Rna9277WI+ituCui2xpJN7UxB2h0xyW/bSX98Pz1j9QKCt/TA0jGY8f+rGn6/J 9Kb5c3URj46R65/d7uib9leHi2AtzrnMsuIDJ0JZzVhLKCp1BJSvaC55V/K5OkRI82yWSi J4WzA1NyzxrVOcX6uC6w6Q5Juo+tDlAs4+2lIzeXsxyrUjO0mbl9TPOcWCN2VyiOZGbaEP Mpt9fXV4LQfMQc7sjn8AfH2Mo546dnt6puKiyX6UZrWQBRgzHDd/qUWDKkYxbw== Date: Mon, 25 Jan 2021 14:03:47 +0100 To: "internals@lists.php.net" Message-ID: <08f91596a4219b8411dab06450b8bf51b4e84d16@hey.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_600ec1b341dbb_215e3020877c5"; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Proposal: Automatically inheriting functions from parent namespaces From: samuel.stancl@hey.com (=?UTF-8?B?U2FtdWVsIMWgdGFuY2w=?=) ----==_mimepart_600ec1b341dbb_215e3020877c5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think it would be useful if namespaced *functions* automatically=0D propagated to all child namespaces as well.=0D =0D An example use case of this would be packages having their own helpers=0D= like this:=0D =0D namespace MyPackage {=0D =C2=A0 =C2=A0 function foo() {}=0D =C2=A0 =C2=A0 function bar() {}=0D }=0D =0D And being able to use them in MyPackage\Commands, MyPackage\Fields, ...=0D= as if they were global functions.=0D =0D The benefit of this is that packages could safely add helpers functions=0D= without risking conflicts and having to do awkward function_exists()=0D checks (which can break things easily). And there would be no overhead=0D= of having to import functions, since that seems to be a pretty obsolete=0D= practice nowadays with only classes being imported in most major=0D projects.=0D =0D Which means that this could revive the practice of namespacing functions=0D= while solving the problem of conflicting global helpers from multiple=0D dependencies.=0D =0D And of course, this is a breaking change. Though I'm not sure how big of=0D= a problem upgrading would be, since having multiple functions with the=0D= same name, but in different namespaces, seems like a pretty rare thing.=0D= =0D Thanks,=0D Samuel=0D ----==_mimepart_600ec1b341dbb_215e3020877c5--