Re: [CONCEPT][DISCUSSION] Instance as boolean

From: Date: Thu, 09 Jul 2020 17:49:11 +0000
Subject: Re: [CONCEPT][DISCUSSION] Instance as boolean
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-110903@lists.php.net to get a copy of this message
Hi > > Re casting - In the previous thread the following concern was presented and I don’t know > enough about that area to respond effectively: "I'd endorse avoiding > object-to-<scalar> casts via cast operations: they are a good source of bugs. My rationale for > the discouragement of magic cast methods is explained with some code examples at > https://github.com/ShittySoft/symfony-live-berlin-2018-doctrine-tutorial/pull/3#issuecomment-460441229” > Frankly this is something subject to personal opinions and will change over time according to community shifts. I think the main obligation of languages and runtimes is to show consistency in their design and behavior. If somehow part of the community wants to enforce that "casting is a bad practice" (because IDE support or whatever valid reason in our current decade) it's ok. But making the language behave differently for each casting scenario actually makes it harder for userland to apply the good practices of the moment consistently. > I concur with the Stringable mention - thank you for that - I have updated based on this > feedback: https://bit.ly/php-0001 > Given that the goal would be to have the class be used in place of a bool everywhere, I would > think we would need to make it cast-able to a bool, yeah? > Yes, precisely. Thanks, Márcio

« previous php.internals (#110903) next »