Re: [CONCEPT][DISCUSSION] Instance as boolean

From: Date: Wed, 08 Jul 2020 17:54:33 +0000
Subject: Re: [CONCEPT][DISCUSSION] Instance as boolean
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-110882@lists.php.net to get a copy of this message
Hello Josh, > Link to working draft: https://bit.ly/php-0001 > <https://bit.ly/php-0001> From a type safety POV I'd prefer to have an interface available, the same way we did to the Stringable interface RFC. But I'd rather keep these engine affecting behaviors with the same magic method naming conventions and its __ prefix. So implements Bool + function __toBool() : bool is the only path that seems entirely consistent with what we already have. The draft doesn't mention (bool) casting behavior at the time I'm reading it, but you do mention the possibility. It seems necessary to me. Why wouldn't (bool) $my_bool_obj behave differently from (string) $my_stringable_obj? > > ps. If you have any feedback or information on social interactions here that might help, please > do let me know, normally I would have watched for a while before putting my foot in - hopefully it > doesn’t end up in my mouth. :) Thanks, Márcio Almada

« previous php.internals (#110882) next »