Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56635 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90597 invoked from network); 25 Nov 2011 12:34:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Nov 2011 12:34:46 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:43622] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/52-12107-46B8FCE4 for ; Fri, 25 Nov 2011 07:34:45 -0500 Received: by qabg40 with SMTP id g40so323337qab.8 for ; Fri, 25 Nov 2011 04:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5ukyVnetKJ/os5qHghBW/qraLaYyFfrLKJV73bO9ce0=; b=gDMy4fxQIYiKZsyXgqDxXVPIk7H5Xpei0OzPtcnJZo6ZhqTXaJT9dZrNI7YWUW638K GobfyrCYIExc+EQWbmBH8utGnKH0FmmyzD5GT2B7e5awJ1mP1QVSdlcosEAiLnxhe/+e zTmOaSIoOfgG+/gsfFyhhq7wzB4FKNCGxQI4U= MIME-Version: 1.0 Received: by 10.224.189.66 with SMTP id dd2mr5404060qab.48.1322224481561; Fri, 25 Nov 2011 04:34:41 -0800 (PST) Received: by 10.229.38.134 with HTTP; Fri, 25 Nov 2011 04:34:41 -0800 (PST) In-Reply-To: References: <4ECEC513.9040706@mohiva.com> <06acba1a1c53ac9527beb807787c92aa@mohiva.com> Date: Fri, 25 Nov 2011 13:34:41 +0100 Message-ID: To: Christian Kaps Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf30334655896b0904b28e607b Subject: Re: [PHP-DEV] Re: [RFC] Autoloader Error Handling From: tyra3l@gmail.com (Ferenc Kovacs) --20cf30334655896b0904b28e607b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Nov 25, 2011 at 1:28 PM, Christian Kaps wrote: > Am 25.11.2011 13:13, schrieb Ferenc Kovacs: > >> On Fri, Nov 25, 2011 at 12:56 PM, Christian Kaps >> **wrote: >> >> I surround my application with a try/catch block to catch uncaught >>> exceptions. An autoloader exception could be one of them. >>> >>> But I use also similar calls to reformat error messages. >>> >>> try { >>> $class =3D new ReflectionClass($****annotationName); >>> >>> } catch (ClassNotFoundException $e) { >>> $message =3D "The annotation class `{$annotationName}` cannot be found= ; "; >>> $message .=3D "called in DocBlock for: {$this->context->getLocation()*= * >>> **}; >>> "; >>> throw new ClassNotFoundException($****message, null, $e); >>> } >>> >>> >>> if(!class_exists('**ReflectionClass')){ >> // call your error handler here or throw Exception as you like >> } >> else{ >> $class =3D new ReflectionClass($****annotationName); >> } >> >> > Reflection class triggers also the autoloader, because it tries to load > the class $annotationName. then class_exists($annotationName)? btw. I think that ReflectionClass::__construct will throw a LogicException if the classname you passed couldn't be loaded. so you don't need your special autoloader for handling that. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf30334655896b0904b28e607b--