I really appreciate any effort that can make PHP a more powerful language. However, for this item, I believe it will generate much greater cognitive complexity for new users (and I hate to assume that this is a problem, but we have to remember our roots).
Why, for now a variable $x will be truth, since it is an instance of an object, now it could be false, because it implements __toBool() and Falsiable interface in a "magic" way, making everything very confusing if the user is not aware of each class that he is instantiating (or even receiving from other places without much condition to know precisely what it is). For this type of situation, I still prefer the introduction of clearer methods that suggest the validation of your own properties, in order to make it much more flexible than simply returning a single "general" boolean by-instance. For example: isValid(). if ($entity?->isAdministrator()) { /** Entity is an administrator. */ } else if ($entity?->isModerator()) { /** Entity is a moderator. */ } else if ($entity) { /** Entity should be an user or similar. */ } else { /** Entity is not defined. */ } On the other hand, the implicity (bool) cast working together with __toBool() is a good one, but I think that it is being discussed in another topic. Atenciosamente, David Rodrigues Em ter., 14 de jul. de 2020 às 20:59, Josh Bruce <j...@joshbruce.dev> escreveu: > Implement an interface and magic method to allow objects to represent > false (or empty) while still be valid instances of the custom object (type). > > https://wiki.php.net/rfc/objects-can-be-falsifiable < > https://wiki.php.net/rfc/objects-can-be-falsifiable> > > If you saw the latest from this morning, not much has changed except > hopefully improved formatting and now being the official mix of things. > > If this is your first time, the cues are taken from: > > - __toString() > - Stringable > - and __toArray() (not accepted or approved yet) > > Thank you for all the feedback and patience so far, appreciate it! > > Cheers, > Josh