Re: [CONCEPT][DISCUSSION] Instance as boolean
| From: | Marcio Almada | Date: | Thu, 09 Jul 2020 18:33:55 +0000 |
| Subject: | Re: [CONCEPT][DISCUSSION] Instance as boolean | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110906@lists.php.net to get a copy of this message | ||
Hi,
>
> Hey Marcio,
>
>>
>> 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.
>>
>
> Not sure what's "subject to personal opinions" in the objective bug exposed in
> the snippet above?
>
So there is a bug in a contrived code snippet therefore casting is a
universal bad practice?
It's at least a huge stretch. Some might say your bad practice was
actually using
null ;)
> Greets,
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/