Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14211 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65708 invoked by uid 1010); 25 Dec 2004 11:16:18 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 65565 invoked from network); 25 Dec 2004 11:16:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Dec 2004 11:16:18 -0000 X-Host-Fingerprint: 64.233.170.204 rproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.170.204:55667] helo=rproxy.gmail.com) by pb1.pair.com (ecelerity HEAD (r3985)) with SMTP id 1B/FE-29078-8EB4DC14 for ; Sat, 25 Dec 2004 06:15:52 -0500 Received: by rproxy.gmail.com with SMTP id r35so112375rna for ; Sat, 25 Dec 2004 03:15:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=WvCBtO2OJRkeCyJ1sp17lN9B0rMkaIOwKxku3dm3bgE+ddceOVLa7o0mX84aqwX+l2YyOdCsN9w7JVG7fcwuIO/ZDMjjs0N23u3GKRW27F4AP/O5P/B6loVBiLKeTsLWD7oS8R4aV9iDF87LfKLQuSyTXYZS/qK2ZvHlJFGO3n4= Received: by 10.38.67.64 with SMTP id p64mr239055rna; Sat, 25 Dec 2004 03:15:50 -0800 (PST) Received: by 10.38.86.30 with HTTP; Sat, 25 Dec 2004 03:15:50 -0800 (PST) Message-ID: Date: Sat, 25 Dec 2004 13:15:50 +0200 Reply-To: "ilya77@gmail.com" To: Sebastian Bergmann Cc: internals@lists.php.net In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <5.1.0.14.2.20041222142706.02653980@localhost> <5.1.0.14.2.20041223133804.0265d4c0@localhost> <41CC25D1.5080408@cschneid.com> <41CC562E.6090005@cschneid.com> Subject: Re: [PHP-DEV] ReflectionClass::getMethod() From: ilya77@gmail.com ("ilya77@gmail.com") This doesn't really clear it out. I can either use the "cleaner" method, and an exception would be raised when I'd try to call NULL(), or, have the OPTION to check whether it's NULL before calling it. IMHO It's much more consistent and clean. You STILL can use exceptions the way you did, and in ADDITION you can write cleaner code which doesn't rely on exceptions. On Sat, 25 Dec 2004 11:31:58 +0100, Sebastian Bergmann wrote: > ilya77@gmail.com wrote: > > Why not just returning null when a method does not exist? > > Actually CALLING a non-existing method should be treated as an error... > > Because > > try { > $class = new ReflectionClass($this); > $method = $class->getMethod($this->name); > } > > catch (ReflectionException $e) { > $this->fail($e->getMessage()); > } > > is clearer than > > try { > $class = new ReflectionClass($this); > } > > catch (ReflectionException $e) { > $this->fail($e->getMessage()); > } > > $method = $class->getMethod($this->name); > > if ($method !== NULL) { > // ... > } else { > // ... > } > > I fail to see why exceptions wee introduced when they are not to be > consistently used in functionality that was added at the same time, like > for instance the Reflection API. > > -- > Sebastian Bergmann http://www.sebastian-bergmann.de/ > GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >