Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-17 Thread Tim Düsterhus
Hi Am 2025-04-07 09:14, schrieb Rowan Tommins [IMSoP]: I think a function for "string is zero length or contains only whitespace" would potentially be useful And for that one it would need to be defined what whitespace is. Is it just the ASCII whitespace characters? Is it Unicode whitespace?

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-07 Thread Hans Henrik Bergan
>If this can still be implemented in userland you don't need logic integrated >at low level Afaik it cannot be implemented in userland today. The closest you can get today is to use reference hacks, which introduce side-effects, like if you do function blank(&$value){...} blank($_POST['foo']) an

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-07 Thread Rowan Tommins [IMSoP]
On 5 April 2025 21:00:15 BST, Rob Landers wrote: >I agree with most of these. I do not agree that " " (a space) is blank though. >For people without last names, this is often their last name to pass >validation on forms. This is firmly into "space-bar heating" [https://xkcd.com/1172/] terr

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-06 Thread Iliya Miroslavov Iliev
On Sun, Apr 6, 2025 at 9:52 AM Hans Henrik Bergan wrote: > Maybe a > #[\SuppressUndefinedWarning] > > Parameter attribute could work, then everyone could implement their own > blank() function with their own preferred logic > > Not sure if it's technically feasible tho, now the php engine would n

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Hans Henrik Bergan
Maybe a #[\SuppressUndefinedWarning] Parameter attribute could work, then everyone could implement their own blank() function with their own preferred logic Not sure if it's technically feasible tho, now the php engine would need to inspect the parameter attributes before deciding on generating a

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Iliya Miroslavov Iliev
On Sat, Apr 5, 2025 at 11:04 PM Rob Landers wrote: > On Sat, Apr 5, 2025, at 14:15, Kayck Matias wrote: > > *INTRODUCTION* > This RFC proposes the addition of a new global function blank() to PHP’s > core, intended to provide a more intuitive and context-sensitive way of > checking for "blank" va

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Rob Landers
On Sat, Apr 5, 2025, at 14:15, Kayck Matias wrote: > *INTRODUCTION* > This RFC proposes the addition of a new global function `blank()` to PHP’s > core, intended to provide a more intuitive and context-sensitive way of > checking for "blank" values. This function is *not a replacement* for > `em

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Rob Landers
On Sat, Apr 5, 2025, at 21:23, Bilge wrote: > On 05/04/2025 20:18, Rob Landers wrote: >> On Sat, Apr 5, 2025, at 21:10, Bilge wrote: >>> On 05/04/2025 19:41, Rob Landers wrote: empty() has very many uses. >>> That is exactly the same as saying `==` has many uses. It does. So many >>> uses t

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Bilge
On 05/04/2025 20:18, Rob Landers wrote: On Sat, Apr 5, 2025, at 21:10, Bilge wrote: On 05/04/2025 19:41, Rob Landers wrote: empty() has very many uses. That is exactly the same as saying `==` has many uses. It does. So many uses that it's useless. Its semantics are nonsense. if (isset($var)

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Rob Landers
On Sat, Apr 5, 2025, at 21:10, Bilge wrote: > On 05/04/2025 19:41, Rob Landers wrote: >> empty() has very many uses. > That is exactly the same as saying `==` has many uses. It does. So many uses > that it's useless. Its semantics are nonsense. >> >> if (isset($var) && $varl != false) { >> foo(

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Bilge
On 05/04/2025 19:41, Rob Landers wrote: empty() has very many uses. That is exactly the same as saying `==` has many uses. It does. So many uses that it's useless. Its semantics are nonsense. if (isset($var) && $varl != false) {   foo($bool); } >$varl != false You should never be doing this

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Iliya Miroslavov Iliev
> echo blank(" "); // true This case is not blank `empty` checks if a variable is set and contains something so basically what your blank function does. In this example it contains character 32. If you want to remove the "\0" (null terminator) from the language, that's a different story. On Sat,

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Rob Landers
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

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Bilge
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

Re: [PHP-DEV] RFC: blank() Function as a Complement to empty()

2025-04-05 Thread Kamil Tekiela
Hi Kayck, Thanks for your proposal. Here are some points from me: empty() is not a function, it's a language construct that's a shorthand for !isset($var) || $var == false. While it has its uses empty() should be avoided whenever possible. It's generally a sign of the programmer being lazy not d