> On Dec 12, 2025, at 9:26 PM, Hans Henrik Bergan <[email protected]> wrote:
> 
> trivial to make in userland.

Sure, almost everything is trivial to make in userland and re-use as a function.

> how about making a composer coerce package first, 
> give it some time, check if it becomes popular,
>  and if it does catch on, reconsider adding it to core?

I don’t think so. There’s no node-js world with left-pad function. 
People prefer to write plain php instead of re-using external function that’s 
needed to be downloaded and correctly loaded with autoload. Too much effort to 
re-use.

Moreover, event if a function is quite popular, it doesn’t mean it should be 
bundled: `dd` / `dump` / `u` / any Laravel global functions that’s users think 
it’s bundled.

I think it’s better to grep the world with structural search and find some 
cases:

- condition($a) ? $a : expr()
- if (condition($a)) { $a = expr() }

With more or less popular use-cases:
- $a == ‘desc’ ? ‘desc’ : ‘asc’
- $a == ’true’ ? ’true' : ‘false’
- $a > 10 ? 10 : ($a < 0 ? 0 : $a)
- max(0, min($a, 10)
- in_array($key, $values) ? $key : $default
- array_key_exist($key, $values) ? $values[$key] : $default
- isset($values[$key]) ? $values[$key] : $default
- any similar

It could be done if I prepare RFC and it will be necessary. Firstly, I’d like 
to discuss the idea itself.

----------

Best regards,
Dmitrii Derepko.
@xepozz

Reply via email to