On Sat, Apr 5, 2025, at 20:25, Bilge wrote: > On 05/04/2025 15:32, Kamil Tekiela wrote: > > > > While it has its uses empty() should be avoided whenever possible. > > > Agree. A better RFC would be to just deprecate `empty()`. > > Cheers, > Bilge >
empty() has very many uses. Once you understand what it is shorthand for, it makes a lot of sense to use it how it was meant to be used. For example: empty($var) ?: foo($var); which is just shorter than: if (isset($var) && $varl != false) { foo($bool); } Generally, you don't use empty() on strings though, just arrays, in my style guides anyway. For strings, you use `$string == ""` or to be more proper, maybe trim($value ?? '') == '' ... but these days, trim doesn't accept `null`, so that makes it a bit more wordy than it really should be. However, it is just a deprecation notice, so it is easy to ignore. For now. — Rob