Re: [CONCEPT][DISCUSSION] Allow objects to declare emptiness and by extension truthiness
| From: | Josh Bruce | Date: | Mon, 13 Jul 2020 15:18:00 +0000 |
| Subject: | Re: [CONCEPT][DISCUSSION] Allow objects to declare emptiness and by extension truthiness | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110974@lists.php.net to get a copy of this message | ||
>> Latest version as we zero in on what this is really about:
>> https://bit.ly/php-0002
>> <https://bit.ly/php-0002>
>>
> 1) The 2 places that you have lists of "this thing produces true/false" could likely
> stand to be turned into tables to make it clearer, especially when demonstrating that isEmpty() and
> __toBool() are effectively opposites of each other so we get a 2-for-1 deal.
I appreciate this idea - done.
>
> 2) Include some less-random examples of real "empty" objects.
>
I’m having difficulty with this, to be honest. I think there are two reasons for this:
1. I avoid null to the point of going out of my way to make it not happen - including implementing
“isEmpty” - simultaneously I’m having a hard time, which could mean it’s a solution looking
for a problem (was thinking about a file cabinet with drawers that would accept folders).
2. I have a very specific use case where this would solve a problem for me. It mainly revolves
around the ability in PHP to make an object in such a way that it “feels” like an array - and
“feels” like a string - and can become an integer - but there’s no way to make the object feel
like and be interacted with like a bool. I don’t want my use case to be the only reason a change
like this is introduced to PHP - I want to make sure “it’s not just me” - you know??
Re the wiki: I can edit pages now, it doesn’t look like I can create them. There’s another
thread I’ve been watching and I think I need more karma to make that a thing. I will continue
working on this and if it generates enough pull then maybe I’ll be let in - I’ll also contribute
where I can to start earning karma.
Updated: https://bit.ly/php-0002 <https://bit.ly/php-0002>
Cheers,
Josh