Re: RFC: Catchable "call to a member function of a non-object"
Derick Rethans wrote on 29.04.2014 10:26:
> On Sun, 27 Apr 2014, php@thekid.de wrote:
>
>> Hello everyone,
>>
>> as per the RFC process I'd like to start a discussion on the RFC
>> I've put up on the RFC Wiki:
>>
>> Â https://wiki.php.net/rfc/catchable-call-to-member-of-non-object
>> Â RFC: Catchable "call to a member function of a non-object", 1.0
>>
>> The essence of this pull request is that it converts this fatal error
>> into E_RECOVERABLE_ERRORs. Framework authors may choose to convert
>> these into exceptions, as they already do with argument type mismatches.
>>
>> Feedback is welcome!
>
> Besides the technical issues that Johannes already mentions, I am also
> against this for logic reasons.
>
> Calling methods on NULL objects is a programming mistake. You either
> have a bug in the code that creates the objects, and in cases where it
> is somethings OK to not have an object, you forgot to check whether you
> have an objects. Programming mistakes should not be hidden by error
> handlers.
Hello Derick,
the RFC is not about hiding programming mistakes, it is still possible to return false in the error
handler.
Btw. PHP tolerates a lot of programming mistakes, see Warning, Notice and that's why we like
PHP.
In most cases (like concurrent deletes), additional checks take a lot of time for implementation and
testing and in most cases, the code is never executed.
There are many functions (like mysqli::query, mysqli::prepare) that return false|null|object.
Covering everything with if(...) makes the code bigger and less readable.
Regards,
Thomas
Thread (11 messages)