On 05.08.2024 at 21:37, Gina P. Banyard wrote:
> This sounds like a uopz extension issue that is easily fixed.
Most likely, yes, although still somebody has to provide a fix, and
someone has to do a new release.
> I am not sure why we should bend over backwards for extensions that allow to
> break usual userland semantics while preventing userland behaviour to be
> better.
We shouldn't do one or the other without having weighted the pros and
cons. So what are the pros regarding improved userland behavior:
* we can use named arguments
So we can now write `exit(status = 1)` or `exit(status = "some error
message`). I don't see any improvement using named arguments for a
single argument function (maybe unless it is a boolean argument). And
for a string argument, I don't think that `status` is a sensible
parameter name here.
* pass to functions as callable
That might be a nice feature, but at least I have never seen the need to
pass `exit` as callable. And it wouldn't be hard to define a wrapper
function (e.g. `my_exit()`) if someone really needs to pass it as a
callable.
* does not respect strict_types and does not follow usual type juggling
semantics
That *might* be an issue (although I've never stumbled upon that), but
it seems to me that this could even be handled in the ZEND_EXIT handler.
Perhaps I've missed some pros, but it seems these have been the ones the
RFC explicitly mentions.
So, what are the cons:
* removing the ZEND_EXIT opcode
That immediately breaks any extension using it. A quick Github search
lists 3.1 k occurrences[1].
* making exit a "proper" function
It still can be called without parentheses, so I don't regard it as a
proper function. It *might* even be confusing to readers ("oh, now I
can call a function without arguments by omitting the parentheses – but
why doesn't it work for other functions?"). And the PHP manual even
states (emphasis mine):
| exit is a *language* *construct* and it can be called without
| parentheses if no status is passed.
Weighting the pros and cons is left as an exercise to the reader.
[1] <https://github.com/search?q=ZEND_EXIT&type=code>
Thanks,
Christoph