Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124727 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 353691A00B7 for ; Fri, 2 Aug 2024 20:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722631147; bh=1TblYLvW7OmmC0WMmVyuLT6R/NT7QViNO3ubFG2o9Ng=; h=Date:Subject:To:References:From:In-Reply-To:From; b=BqngOdjYQt6/zHXwQyxOzWnUMZycodoRLRIZ0By5wtN8Vv6XE9bhEYFovbpP7756B T5Fc3FgXTCblrjOVkbtpVGiKiqEwiYBd4nZCT4zmXYg+x7vsrNZii3j0CVUwwm/erH vek7SE3Ub6m/ArSaRzIldh1buT0NXJhSPcrnlXq9VS5TukThcGFKpRY5aVqo3k+hq2 n0rJEAQQ+KbJYSx6NlS8fFB2ywt9ZDo2twawfGU3+ozOhTL1mud+kx101BhWfi1NMW ZdOMicbsRAYzjyx0HrPjE/DZYysrefgFbZRNzz7MPTeA5fp0kc0OWJiNK6fq6RXPuo es1yHdUoiBn8g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 80F2D180069 for ; Fri, 2 Aug 2024 20:39:06 +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,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-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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, 2 Aug 2024 20:39:06 +0000 (UTC) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-367963ea053so5438670f8f.2 for ; Fri, 02 Aug 2024 13:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1722631045; x=1723235845; darn=lists.php.net; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=UPl19jXBYeG8uDIs2X4nsJ3WeqF17d64jG/H1roeEAg=; b=EwnKOpVAHlLnB8WLvOHHIlZSHxiw1PgCgi979rc9UjsRhC21atWvjw8nYQTs8QvMc0 9ePtsNUwf+LgdUHHdFJN3Hc3kGlTdgmUNoelxh+KYrkX25jrbZtjZvFyRU6h96xJu9Ug bzfZDbs6DvfLAn64eOyGgr7d8XXwy0RPrSH6vi8aK6HBkDeofW97WHs1gufdabeTkV0F myBRpmid6eZQo9uRP88T6PAdPPOY6B/LGbwSL3R7EzS3bfPYAfAMGWCv3kdFgLuRWc+P HsiBwIodTUA4U/MNESqatW2XyvtPpMSSPnP2bRJnDZLPLuWTMIqI09N7j6jNfX2HCNtx 3+gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722631045; x=1723235845; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=UPl19jXBYeG8uDIs2X4nsJ3WeqF17d64jG/H1roeEAg=; b=M/1OvmjbduWLa/PH3fjxnqFMGPxUnKAq2fZYSPWwmY8F2ynseHbNQ47b7S74sXWJxa JjPBaIwZLCAOGDQgzK7Z/CkId25bzCQzVJLdBD8LsAYheQ0XOJK9J5yUzVlo+kZEexmJ Dwwx6PJDLwLNf/0t7QLbq1VixkSECS3gEC38bkFul1KJwsepOhSVaZn8SrShZsnwGv7M 38m8yU5MIn+orxV+6W/xGW2Gd36OBpMu5BmF1ns1+aPMNJHUnGxV7MLUrDYoj387j3+f EOdSojnW7PTBdpSoaTxFCRWGGfJBqQZKNThIKrZdygRQ9kL/CnmjSrdu9VxkEeosgUA6 A18g== X-Gm-Message-State: AOJu0Yy1li95FbQmhhQOZN86gHuGsT/wDpjuatx8Zn6TnsJry1vgSTVH 6psFBGKntWui0psrkXgSiAD8tx6cwhruTYSkndCJ2Zq0lBwtjMqVusliPY1OCOTgSMYQ46ySC4G m X-Google-Smtp-Source: AGHT+IHM9TZe3DdjOTRy65RpQzUGa5GlhJqfg8iZRu/OZLN5yA8CLI3m1BZDGk8OYTQMPzwYssVVcw== X-Received: by 2002:a05:6000:1a8f:b0:368:3384:e9da with SMTP id ffacd0b85a97d-36bbc1ddfdfmr3478311f8f.62.1722631045113; Fri, 02 Aug 2024 13:37:25 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:a178:430d:68cc:c628? ([2a01:4b00:bf09:5101:a178:430d:68cc:c628]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd013fc1sm2715025f8f.38.2024.08.02.13.37.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Aug 2024 13:37:24 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------i8FtGSRQ2b0oWRH99jzCWUZA" Message-ID: <48c22449-6cdf-449f-917f-365506e3f2d0@scriptfusion.com> Date: Fri, 2 Aug 2024 21:37:23 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: From: bilge@scriptfusion.com (Bilge) This is a multi-part message in MIME format. --------------i8FtGSRQ2b0oWRH99jzCWUZA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ilija, I think this proposal has legs, and you are right to rekindle it, instead of letting it die quietly. On 02/08/2024 17:51, Ilija Tovilo wrote: > * Some mocking libraries (e.g. Symfony's ClockMock [5]) intentionally > declare functions called from some file in the files namespace to > intercept these calls. This use-case would break. That said, it is > somewhat of a fragile approach to begin with, given that it wouldn't > work for fully qualified calls, or unnamespaced code. > My only concern is there needs to be an alternative way to do this: intercepting internal calls. Sometimes, whether due to poor architecture or otherwise, we just need to be able to replace an internal function call. One example I can think of recently is where I had to replace `header()` with a void function in tests, just to stop some legacy code emitting headers before the main framework kicked in, then unable to emit its own response because HTTP headers had already been sent. In a perfect world it shouldn't be necessary, but sometimes it is, so I think for this proposal to be palpable there must still be a way to achieve this. Cheers, Bilge --------------i8FtGSRQ2b0oWRH99jzCWUZA Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi Ilija,

I think this proposal has legs, and you are right to rekindle it, instead of letting it die quietly.

On 02/08/2024 17:51, Ilija Tovilo wrote:
* Some mocking libraries (e.g. Symfony's ClockMock [5]) intentionally
declare functions called from some file in the files namespace to
intercept these calls. This use-case would break. That said, it is
somewhat of a fragile approach to begin with, given that it wouldn't
work for fully qualified calls, or unnamespaced code.

My only concern is there needs to be an alternative way to do this: intercepting internal calls. Sometimes, whether due to poor architecture or otherwise, we just need to be able to replace an internal function call. One example I can think of recently is where I had to replace `header()` with a void function in tests, just to stop some legacy code emitting headers before the main framework kicked in, then unable to emit its own response because HTTP headers had already been sent. In a perfect world it shouldn't be necessary, but sometimes it is, so I think for this proposal to be palpable there must still be a way to achieve this.

Cheers,
Bilge

--------------i8FtGSRQ2b0oWRH99jzCWUZA--