Re:PHP 8.4
by williamdclt on Thursday November 21, 2024 @12:13PM
(#42206389)
"if not defined" doesn't help, if your own `array_find` doesn't have the same signature and semantics than the new global then you're screwed. You'd want the opposite: overwrite it if it already exists in the global scope (dunno if that's easy / how that'd work in PHP)
You can't redefine functions in PHP.
Re:PHP 8.4
by mklepaczewski on Thursday November 21, 2024 @03:34PM
(#42208351)
There are extensions which allow you to redefine even constants.
the answer is using a namespace
Re:PHP 8.4
by someothherguyy on Thursday November 21, 2024 @02:10PM
(#42207560)
> `array_find` doesn't have the same signature and semantics than the new global then you're screwed
Screwed? Just rename or move the function to a namespace in an IDE and it will update all your references?
Also people should be coding defensively with things like “if not defined” when implementing their own global helper functions (or avoid doing that at all)