On Tue, Jul 14, 2020, at 11:48 PM, Matthew Brown wrote:
> On Tue, 14 Jul 2020 at 19:59, Josh Bruce <j...@joshbruce.dev> wrote:
> 
> > 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
> 
> 
> I'm not sure I love this (mostly from a static analysis standpoint).
> 
> It means that there would exist some `$foo` with the property that `$foo &&
> !$foo` evaluates to true.
> 
> That seems to be a bad place for a language to go, and it would increase
> the false-negative rate of static analysis tools.

I don't see how that would happen.  What non-pathological case would allow for 
$foo && !$foo == true?

(I know you could do something stupid like return random_int() from __toBool(), 
but I'm ignoring that as "you're dumb so of course your code is dumb.)

>From the RFC, I don't quite get this line: 

"Further, the union type bool|Falsifiable will be dynamically added at run time 
to any object implementing the reserved __toBool() method, which would allow 
stdClass() objects to be defined as Falsifiable also. "

What's that about?  

"(Including __construct() replacing old style constructors in PHP 7.)" - 
__construct replaced old-style constructors in PHP 5. :-)

I think the truth tables have a formatting error; check the last line that goes 
wider than the rest.  Also, watch out for "smart quotes" in the string parts.  
Also, YAY summary tables!

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to