On 5/26/2016 7:20 PM, Rowan Collins wrote:
> I think the difference is the emphasis of whose responsibility it is to
> fix it: a TypeError confirms that the error is in the O class for
> exposing an incorrectly typed property; a NullPointerException, as you
> put it, makes it my fault for trusting the class.
> 
> Or to put it a different way, is the error in the first arrow (accessing
> "->d") or the second one (de-referencing "d->").
> 
> 
> At the end of the day, all the type notations being added to PHP are
> just assertions anyway. So the same could be said of this:
> 
> function foo(\DateTime $d) {
>    echo $d->format('Y-m-d H:i:s');
> }
> foo(null);
> 
> If this didn't throw an error at "foo(null)", it would throw an error at
> "$d->format".
> 

Yes, they are just assertions and design by contract and you make a very
good point here for an actual error. I am convinced. ;)

However, it should not throw an error for isset() and empty() to allow
more special constructs. As we already have it in place everywhere with
the two.

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to