Re: [Concept] Flip relative function lookup order (global, then local)

From: Date: Fri, 02 Aug 2024 20:37:23 +0000
Subject: Re: [Concept] Flip relative function lookup order (global, then local)
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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

Thread (112 messages)

« previous php.internals (#124727) next »