Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125152 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 A34521A00BD for ; Fri, 23 Aug 2024 17:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724433163; bh=rhcNPeVRLJZ/T6uGZSb+i/ZM+DkoT2INPz1BF9w78eE=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=DSgPk1OBF78pC07DiH12pAMtvaeAJQxDwOiftBViJopz+oIN0A+g5gbvQI2/RvAJs LAetV1hN4CDISzq7UxkEp9pbfApi4ML+s8JeIbQhk6kUftknfvef1UyLZBvHSle9pO HQ9vYJ7HrdODjhtfz1zT4QYTZ4K8B/b3gF5auFP9VqE47dOHP9h7fDCU0Zf3pCLmAg 4d/V52Clz3If67eF0i4HP3MV0u1kHk3kNrnr00EoemCj0HbVAmHXqVPzTQdCH+fq+F 8ETXMibQ42TbFdIlwslBkXE0HTPknDVsD5hEAUKwd+QQKHI7nqhmV8YhCxGfA//X4f uWPl6fl8HluCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E1257180052 for ; Fri, 23 Aug 2024 17:12:42 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,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=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 ; Fri, 23 Aug 2024 17:12:42 +0000 (UTC) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-70df2bd6421so1277322a34.2 for ; Fri, 23 Aug 2024 10:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coggenterprises-com.20230601.gappssmtp.com; s=20230601; t=1724433051; x=1725037851; darn=lists.php.net; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=rhcNPeVRLJZ/T6uGZSb+i/ZM+DkoT2INPz1BF9w78eE=; b=VAt8mZ+7FuSj4AfOIS/6/VkeP9K1qLsfrbxguSjNFMzegfvLWf6foTz3Yoam7ltA7t fhD4FhPAi6SANnyPdNySV3lXoajK4Z50NuLOdkIzttcNTCgEALC2C2zN7xKuZ/N2WvBT kgfquG8EwJK+1t2ud/eiTLNFiU0yCk3OsGtcoLOjs0X6a1hTuGtB/JvVakBjptuH2isZ d6k6OawAqrpLeJnjGfmOmDNRMgCm+c2CjLfFml5uBvB2RI9n7DBZeBVObx3/5xY5Q69U rvpliWVL/4/6YTinBtdafsymqI5dWG4XLkg2hZj/nXFTvE6rWK9DGl6aH2kSfeoc1KLI vuwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724433051; x=1725037851; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rhcNPeVRLJZ/T6uGZSb+i/ZM+DkoT2INPz1BF9w78eE=; b=i2S7f3UqwepmpFlK/uO7/nDJv7rNo0nKQkHhms5fTEGypOJHaFFyPzwf/QsAFr1SXZ Ko5nTd9PzeHFZ9UhgR8uHT/na+UcdkWIipOuMmDffAt2/Ei0CIk4vS5yZcLsQq5RC5l9 c1gStv1hwoc8U2z9lrUiVFCTqF5s3WQmVLi0rkQhhR4QCWaenMQMDxPhDGZjStVm4yWB QX+GjHj2CmgrmKi03z6U7FTm+YBCDb6314Pt4nuwC055GctbfME3StsgzVrxKi/gtR1l GY/70Pg4ruCHk935qIrieJ/+gCsIsLEO6ht75pXudZR6hUSHd6H10FRvaZPd93N7FzAj JcCw== X-Forwarded-Encrypted: i=1; AJvYcCVnVTSqZsOY9gyQw378HjEb+hjFhKkDFXAAwTIJ2/B0m5ag/Eq6vhFaaH6gwWuV/0iQUFpgZ7ISb+Y=@lists.php.net X-Gm-Message-State: AOJu0Yy2si7IqWkAQjP0utJ4zaGqKdac9U0l0CAti6tcyUFIV6+PRq8i SjZoCLOHzpxZQCUOk9cCWr8OQuTJ90FPbcaqTRfEaqazN66YkrP/9iu++S2e8EVG8qcsXZd3nKg m X-Google-Smtp-Source: AGHT+IH7ROtDs+Nn8boBUFQpA4rtMPj2Lxy6aolW/aLwMhKh5R0HDVuqGcj3JZ48uUb+jBPTcW/+6w== X-Received: by 2002:a05:6808:178e:b0:3db:3102:adc6 with SMTP id 5614622812f47-3de2a909bb1mr3154499b6e.41.1724433050533; Fri, 23 Aug 2024 10:10:50 -0700 (PDT) Received: from Johns-MacBook-Pro-2.local ([207.213.210.67]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3de225d6ddesm771627b6e.49.2024.08.23.10.10.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 10:10:50 -0700 (PDT) Date: Fri, 23 Aug 2024 13:10:48 -0400 To: Stephen Reay Cc: =?utf-8?Q?Rowan_Tommins_=5BIMSoP=5D?= , "=?utf-8?Q?internals=40lists.php.net?=" Message-ID: <131FC621-823F-4E17-83DB-D8B83F535A2E@getmailspring.com> In-Reply-To: <828A2555-E7CC-4DD8-AE1B-8D50EB7EDC6F@koalephant.com> References: <828A2555-E7CC-4DD8-AE1B-8D50EB7EDC6F@koalephant.com> Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) X-Mailer: Mailspring Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="66c8c298_643c9869_15341" From: john@coggeshall.org (John Coggeshall) --66c8c298_643c9869_15341 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Aug 23 2024, at 12:35 pm, Stephen Reay wrote: > > > would find it non-sensical that you must add a backslash for the engine to do the "right thing" (in this case, optimize their code with a security benefit), vs just doing the right thing by default. > > What do you mean by this? What is "the right thing"? I mean this: I'm not saying that isn't necessarily how people think, I have literally zero data about this besides my own thoughts, but it seems like a bizarre idea that people would *expect* function name resolution to work completely opposite to how class/class-like name resolution works. > At it's core a vast majority of the functionality of the PHP language exists within internally-implemented functions, not classes. So yes, I think it's entirely reasonable that people would expect that internal functions resolve at a higher priority than user-defined functions with the same name, and that if you'd like to reuse a global namespaced function in your local namespace you need to be explicit about that -- not the other way around. --66c8c298_643c9869_15341 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On Aug 23 2024, at= 12:35 pm, Stephen Reay <php-lists=40koalephant.com> wrote:

would find it non-sensical that you must add a = backslash for the engine to do the =22right thing=22 (in this case, optim= ize their code with a security benefit), vs just doing the right thing by= default. 

What do you mean by this=3F= What is =22the right thing=22=3F

I mean this:=

<=3Fphp
// something.php
namespace = App=5CModels;

function password=5Fhash(string =24password, = string=7Cint=7Cnull =24algo, array =24options =3D =5B=5D): string
=7B
   print(=22Hello=22);
   = return =24password;
=7D

<=3Fphp
// m= y code
namespace App=5CModels;

include =22somethi= ng.php=22;

password=5Fhash('foobar', PASSWORD=5FDE=46AULT);=

This code IMO shouldn't print =22Hello=22, but it does. Th= e current behavior of looking up the local namespace first for functions,= instead of the global namespace first, IMO is the =22wrong thing=22 beca= use it expects developers to fully qualify internal function calls every = single time because, under very specific legitimate use cases that are pr= etty rare in the course of normal development, you actually might want to= do that.

I'm not saying that isn't necess= arily how people think, I have literally zero data about this besides my = own thoughts, but it seems like a bizarre idea that people would *expect*= function name resolution to work completely opposite to how class/class-= like name resolution works.


At it's core a vast majority of the functionality of the PHP language = exists within internally-implemented functions, not classes. So yes, I th= ink it's entirely reasonable that people would expect that internal funct= ions resolve at a higher priority than user-defined functions with the sa= me name, and that if you'd like to reuse a global namespaced function in = your local namespace you need to be explicit about that -- not the other = way around.
--66c8c298_643c9869_15341--