Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124658 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 C848A1A00B7 for ; Sat, 27 Jul 2024 22:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722120645; bh=CiGlGIZsLmisPN38UgEVyw0qqOiQJzaXsWE6p7idCys=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=KlYjCHQN6hIIGiQWjtjlhJ7UKPp1ONnf8oUYA2iNBZqjHd+hh2uicDVCP/dGgHZ0r fesaP048VyNcVNNq9fe//eigaoOEHR+FKu3mXvSlWoI7IKuDcT2RGsTF3Ld0urV5T7 lhHaQa7eIodoTvENH9f4Oof6Sp2MCdcLQmzV0HLJD05vW+ManWt4zsMgB7OHwTpAoT J1OKvOfD4cckHdl0wa3Mj3TrNVVZ549WZDF2yFl5/hofVf9sl6ee2beQmOzaEk6IMN ghKUZ4UQJw8NINZZ9gzhKfn57muZr4TfrvyNM4rAj2sv1epeoBi0c6hGrbXbqJyrE9 lKXBU8SxB+WKA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BFC31180039 for ; Sat, 27 Jul 2024 22:50:44 +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,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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, 27 Jul 2024 22:50:44 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52f024f468bso3436112e87.1 for ; Sat, 27 Jul 2024 15:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722120546; x=1722725346; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=fX1seqbm5VF6EJTqvQRMZcgcksPjprCzAS3lDWousc4=; b=UzRlCeml6XFaT8JNq2vZ1JfSVWcyyRk/lkWnQTImPmVsPUCJcActdlJvaaLN6Dv2fm 1z5T9pYlMt2CSrXVGOREvi/pVm86o35SP1xxQCtjIeYFMUrxmxPd/Eft6vgVQTfA0Zvd e/1TKqAR8jnB0h0vHyNQDmBYSBk2mnoEJW6XLDXKJtyZ/XjCXFtBmVbWgbMLO1QvfjNB dViB74K8arQwFQPov9Fosns9rLQ/qZBYKQLwIFUVghCQwpT9TtkExPteKMaNFPzlg909 jWbPJUb0EfU+/1i/npZDC8a+MDvA3i5DQ2MPJGinAIVWB7EvbhV/TjyaGHltk9YRLLCg P9eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722120546; x=1722725346; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fX1seqbm5VF6EJTqvQRMZcgcksPjprCzAS3lDWousc4=; b=TQF3I9h+QmVdcManPNC3dBGSPyJZAJBJUJaMWruEM8S2YgcbQuWeJwqRNt0Y13nL7C DrrLYoRtG1gq1eff0fgrgtbfy/r3MHPNNO3rWGboEH585D9DFu3OM3tQPyEyIFcGsQPD Mt6UKUyQP45fMwEC8Iyx45IfsczHWox30E4gr2gKRmF16E+enga9UIyAwnvHZDluNrP9 wyr9QxastBuN4sotUw+pNe4ZF7TwxTZ9ChIWpSH9CVH4MwMD1MG2reo//T0O7DnE0P/p depS/4yDp6dGF955CbmGmpi/cIiefQP5xHMqBxk0tGwiTiUS96x1W7msIhSGJyrU9/9a sdbQ== X-Gm-Message-State: AOJu0YzgyvwHU/WSvJSHKKyXvw1TGdrW+FiwOKw0yTs1UIEv44w7+n/w iEg56H91TI0aMhGSrY38i7jVf5AgiwyjSoxoEvnYAuU69Olb9DDDlqkdbA== X-Google-Smtp-Source: AGHT+IGpCMAa/UfiIMX4ELxEXhgIG3V2WVe8iMvnKXUaO3F/NoWsdjCiVIz6PY4FKsaf+L67SeaKbA== X-Received: by 2002:a05:6512:e94:b0:52e:9c0a:3514 with SMTP id 2adb3069b0e04-5309b2c3627mr2938317e87.44.1722120545845; Sat, 27 Jul 2024 15:49:05 -0700 (PDT) Received: from smtpclient.apple ([178.197.198.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab52d51sm322344166b.79.2024.07.27.15.49.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2024 15:49:05 -0700 (PDT) Message-ID: <098864EF-9D75-417A-82DC-105082DA3A23@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_D540C6BC-C5A7-4EBE-B35E-85502AE5AF4A" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] Should PHP reserve a namespace for built-in classes? Date: Sun, 28 Jul 2024 00:48:53 +0200 In-Reply-To: Cc: internals@lists.php.net To: Nick Lockheart References: <76559a9cd5eca4bc6799ed9612ce15c28cd7cb0a.camel@ageofdream.com> <95f6046a-4acf-4f8a-a850-a23650c0c6b3@bastelstu.be> <927705b0404e70b0f0ade4a3354b2598d7c112f9.camel@ageofdream.com> <86b7e340-6ca9-4b3c-af0a-a5c2d1ee68c3@bastelstu.be> X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_D540C6BC-C5A7-4EBE-B35E-85502AE5AF4A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 25 juil. 2024 =C3=A0 05:22, Nick Lockheart a = =C3=A9crit : >=20 > 1. Could we have a global setting (maybe php.ini) that makes all = built- > in functions (not built in classes) directly accessible in any > namespace? That is: >=20 > // php.ini > AlwaysUseGlobalFunctions =3D yes >=20 > Then: > // myclass.php > namespace foo; > class Bar{ >=20 > function MyMethod($a,$b){ > if(array_key_exists($a,$b)){ // no \ before array_key_exists > // do something > } > } > } >=20 > And with that option set, PHP will know that array_key_exists *is* > \array_key_exists, even without the slash, and without checking the = foo > namespace for an array_key_exists function first? >=20 > My understanding is that some built-in functions have their own = opcode, > that doesn't get triggered when those built-in functions are called in > a namespace, unless the built-in is called with a `\`. >=20 > Having all *functions* default to global would make namespaces a lot > more user friendly to work with, since we wouldn't have to put > backslashes in front of everything. >=20 >=20 Hi, For the case of functions (and constants) in the global namespace, there = was an RFC on the subject about 4 years ago, which has been declined; = see: https://wiki.php.net/rfc/use_global_elements and the discussion = threads referenced at the bottom of that page. =E2=80=94Claude --Apple-Mail=_D540C6BC-C5A7-4EBE-B35E-85502AE5AF4A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 25 juil. 2024 =C3=A0 05:22, Nick Lockheart = <lists@ageofdream.com> a =C3=A9crit :

1. Could we have a global setting (maybe = php.ini) that makes all built-
in = functions (not built in classes) directly accessible in any
namespace? That is:

// php.ini
AlwaysUseGlobalFunctions =3D yes

Then:
// = myclass.php
namespace foo;
class Bar{

  function MyMethod($a,$b){
     if(array_key_exists($a,$b)){ = // no \ before array_key_exists
        // do = something
     }
  }
}

And = with that option set, PHP will know that array_key_exists *is*
\array_key_exists, even without the slash, = and without checking the foo
namespace for an array_key_exists function first?

My understanding is that some built-in = functions have their own opcode,
that = doesn't get triggered when those built-in functions are called = in
a namespace, unless the = built-in is called with a `\`.

Having = all *functions* default to global would make namespaces a lot
more user friendly to work with, since we = wouldn't have to put
backslashes in front of everything.



Hi,

For = the case of functions (and constants) in the global namespace, there was = an RFC on the subject about 4 years ago, which has been declined; = see: https://wiki.php.net= /rfc/use_global_elements and the discussion threads referenced = at the bottom of that = page.

=E2=80=94Claude


= --Apple-Mail=_D540C6BC-C5A7-4EBE-B35E-85502AE5AF4A--