Newsgroups: php.general,php.internals Path: news.php.net Xref: news.php.net php.general:283342 php.internals:41960 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65158 invoked from network); 17 Nov 2008 09:47:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2008 09:47:45 -0000 X-Host-Fingerprint: 134.130.78.10 unknown Received: from [134.130.78.10] ([134.130.78.10:12302] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/A1-53741-0CD31294 for ; Mon, 17 Nov 2008 04:47:44 -0500 To: internals@lists.php.net,php-general@lists.php.net,Jochem Maas Message-ID: <49213DBD.8070609@rwth-aachen.de> Date: Mon, 17 Nov 2008 10:47:41 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666 MIME-Version: 1.0 Followup-To: php.internals References: <28.8E.39815.8C421294@pb1.pair.com> <49212EEF.5070409@iamjochem.com> In-Reply-To: <49212EEF.5070409@iamjochem.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Posted-By: 134.130.78.10 Subject: Re: [PHP-DEV] Fatal error: Call to a member function on a non-object From: christopher.vogt@rwth-aachen.de (Christopher Vogt) 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@lists.php.net. 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