Newsgroups: php.doc,php.internals Path: news.php.net Xref: news.php.net php.doc:969379084 php.internals:38907 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16153 invoked from network); 10 Jul 2008 17:14:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2008 17:14:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=jochem@iamjochem.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jochem@iamjochem.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain iamjochem.com from 194.109.193.121 cause and error) X-PHP-List-Original-Sender: jochem@iamjochem.com X-Host-Fingerprint: 194.109.193.121 mx1.moulin.nl Linux 2.6 Received: from [194.109.193.121] ([194.109.193.121:50278] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/68-11681-38346784 for ; Thu, 10 Jul 2008 13:14:44 -0400 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id BBA5D26D049; Thu, 10 Jul 2008 19:14:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at moulin.nl Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (mx1.moulin.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EsuWWpgqJu+f; Thu, 10 Jul 2008 19:14:33 +0200 (CEST) Received: from [192.168.2.104] (dhcp-077-250-159-054.chello.nl [77.250.159.54]) by mx1.moulin.nl (Postfix) with ESMTP id F3AB826D023; Thu, 10 Jul 2008 19:14:32 +0200 (CEST) Message-ID: <48764379.3010304@iamjochem.com> Date: Thu, 10 Jul 2008 19:14:33 +0200 User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: Derick Rethans CC: Gergely Hodicska , PHP Documentation List , "internals@lists.php.net" References: <4875821E.9020504@avalon.aut.bme.hu> <20080710045418.GA22262@panix.com> <487599FA.9000207@avalon.aut.bme.hu> <4875CE7F.9090308@avalon.aut.bme.hu> In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] strange autoload behavior From: jochem@iamjochem.com (Jochem Maas) 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 >