Newsgroups: php.doc,php.internals Path: news.php.net Xref: news.php.net php.doc:969379097 php.internals:38949 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73489 invoked from network); 15 Jul 2008 09:58:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2008 09:58:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:60576] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/94-48479-CC47C784 for ; Tue, 15 Jul 2008 05:58:38 -0400 Received: from MBOERGER-ZRH (unknown [80.179.124.65]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 6552911F29F; Tue, 15 Jul 2008 11:58:31 +0200 (CEST) Date: Sat, 12 Jul 2008 12:29:31 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1672378551.20080712122931@marcus-boerger.de> To: Jochem Maas CC: Derick Rethans , Gergely Hodicska , PHP Documentation List , "internals@lists.php.net" In-Reply-To: <48764379.3010304@iamjochem.com> References: <4875821E.9020504@avalon.aut.bme.hu> <20080710045418.GA22262@panix.com> <487599FA.9000207@avalon.aut.bme.hu> <4875CE7F.9090308@avalon.aut.bme.hu> <48764379.3010304@iamjochem.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] strange autoload behavior From: helly@php.net (Marcus Boerger) Hello Jochem, seems like we have quite some nice additions to the manual here in this thread. Now to the real issue, Exceptions don't bubble up. That is they are simply ignored. And once all __autoload work is done and the class still doesn't exist an E_ERROR is issued. The work around for cases where the class must not exist (e.g. when no E_ERROR is needed would be collecting the exceptions. That is the base Exception class would get an additional property and getter: private $previous_exception; function public getPreviousException(); That way we could let the exceptions bubble up (though some smaller engine changes are necessary). marcus Thursday, July 10, 2008, 7:14:33 PM, you wrote: > Derick Rethans schreef: >> On Thu, 10 Jul 2008, Gergely Hodicska wrote: >> >>>> exceptions thrown during autoload are ignored. >>> And one more thing, this is in the manual: >>> "Note: Exceptions thrown in __autoload function cannot be caught in the catch >>> block and results in a fatal error." >>> >>> I think your explanation makes much more clear what happens, maybe it would >>> worth to upgrade the manual. While the quoted text suggests that that if throw >>> an exception I just can't catch it and will bubble up to top level and this >>> cause the fatal error. >> >> You can actually catch it *in* the autoload method, it just wouldn't >> bubble out of it. > the manual could do with that tidbit, maybe also the hack for 'getting the > exception out' of __autoload() ... > function __autoload($class) > { > try { > throw new Exception('foo'); > } catch (Exception $e) { > self::handleDebug($e); > > if (!class_exists($class, false)) > eval(sprintf(' > class %1$s > { > public function __construct() { > throw new AL_Exception("Class %1$s not found: %2$s"); } > public function __call($m, $a) { > throw new AL_Exception("Class %1$s not found: %2$s"); } > public static function __callStatic($m, $a) { > throw new AL_Exception("Class %1$s not found: %2$s"); } > }', $class, $e->__toString())); > } > } > which works best when __autoload() isn't triggered by class_exists("Foo", true) >> >> regards, >> Derick >> Best regards, Marcus