Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hej Jochem,

I understand there are many PHP beginners flooding the wrong lists with
the wrong questions, so I don't mind your harsh response. But I am not
one of them.

> please don't post this kind of question to internals. use php-general@xxxxxxxxxxxxxx

This was/is a question if something is worth a change request. This
concerns the development of PHP and in my eyes belongs on internals. Am
I mistaken here?

> plenty, I suggest taking the time to get a better understanding of OO,
> the php implementation and the various related tools it offers
> (instanceof, "method-chaining", exceptions, etc, etc).

I have a good understanding of OOP. This is not a start for me. I am
just refactoring existing PHP code to be object-oriented. You say there
are plenty of reasons for a Fatal error, so please tell me a few, so I
understand the reasons.

> calling a method on an object that doesn't exist is tantamount to calling a function
> which doesn't exist ... both are a fatal error.

Yes and maybe that is wrong two. But besides that, there is a difference
between the two. It hardly happens that a bug results in a call to a
non-existing function. But a bug can easily lead to an uninitialized
variable which is then treated as an object.

The problem with Fatal errors is that there is no way for me to handle
them. I use an error_handler in the production system. When an error or
unhandled exception occurs it displays an end-user-friendly error
message and then sends an email to our team's mailbox. Working with
arrays I can handle all sensible run-time errors using this methods.
Working with objects, I apparently cannot, because Fatal Error aren't
handled by the error_handler.

That's a serious problem because it completely hides a likely group of
errors from the notification system. I hopes this motivates the question
a little better.

But the question remains. Are there reasons to have a Fatal error here?

For comparison: Python throws an exception in a comparable case,
allowing me to handle the error.

Best regards

Christopher

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux