Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41857 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80676 invoked from network); 11 Nov 2008 22:00:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2008 22:00:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.251 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.132.251 an-out-0708.google.com Received: from [209.85.132.251] ([209.85.132.251:45218] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/92-07308-5800A194 for ; Tue, 11 Nov 2008 17:00:37 -0500 Received: by an-out-0708.google.com with SMTP id b2so58365ana.38 for ; Tue, 11 Nov 2008 14:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=GS/UKDjg36tmWYfNxinkXWSr3WKlYdEPS7c8fls3mJw=; b=Uw1O4hwifRXFjmkFhp6h0eyuERLD1oefpT0PBk0bv4SwOQ2jWeKMueh0hJvlOsKsWB H4OOj2bx4RiqD83XuREMPjIlRtlW+NYtHGBKo1nQrO8g8rSqcCn6dpMKIoO2udkuk1I9 oSfCZXKBR33gcZw7c4Wp8RTLZcdS2g87PCXbY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=p9gL0srpvzeAgndvtdIvmpNxdEy9jiYxceTf6vATmXdkHJA2bMPAQ2iiAZVTE9jJjF 29euxgGDevc6g4iWFHsEOOiJKKlbzzVWeWivhdXkdRUZ0LU6KezNoySa0DQvwa0vU25C Q4CK7a3SJDkNczH60RQSRnkD4JBnsXnq4ww0k= Received: by 10.100.9.19 with SMTP id 19mr3595519ani.8.1226440834556; Tue, 11 Nov 2008 14:00:34 -0800 (PST) Received: by 10.100.95.14 with HTTP; Tue, 11 Nov 2008 14:00:34 -0800 (PST) Message-ID: Date: Tue, 11 Nov 2008 23:00:34 +0100 Sender: ekneuss@gmail.com To: "David Grudl" Cc: "PHP internals" , marcus.boerger@post.rwth-aachen.de In-Reply-To: <4919AFE5.5000203@grudl.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4919AFE5.5000203@grudl.com> X-Google-Sender-Auth: ba16dcd4d9a7e801 Subject: Re: [PHP-DEV] New SPL exceptions proposal From: colder@php.net ("Etienne Kneuss") Hello David, On Tue, Nov 11, 2008 at 5:16 PM, David Grudl wrote: > Hello *internals* and Marcus! > > What do you think about possibility to implement to PHP 5.3 several useful > default exceptions? > > (note that InvalidArgumentException, RuntimeException and LogicException > exists since PHP 5.1) > > /** > * The exception that is thrown when the value of an argument is > * outside the allowable range of values as defined by the invoked method. > */ > class ArgumentOutOfRangeException extends InvalidArgumentException > {} Looks a bit redundant with OutOfRangeException > > /** > * The exception that is thrown when a method call is invalid for the > object's > * current state, method has been invoked at an illegal or inappropriate > time. > */ > class InvalidStateException extends RuntimeException > {} > > /** > * The exception that is thrown when a requested method or operation is not > implemented. > */ > class NotImplementedException extends LogicException > {} > > /** > * The exception that is thrown when a requested method or operation is > deprecated. > */ > class DeprecatedException extends LogicException > {} > > /** > * The exception that is thrown when an invoked method is not supported. For > scenarios where > * it is sometimes possible to perform the requested operation, see > InvalidStateException. > */ > class NotSupportedException extends LogicException > {} > > /** > * The exception that is thrown when an I/O error occurs. > */ > class IOException extends RuntimeException > {} > > /** > * The exception that is thrown when accessing a file that does not exist on > disk. > */ > class FileNotFoundException extends IOException > {} > > /** > * The exception that is thrown when part of a file or directory cannot be > found. > */ > class DirectoryNotFoundException extends IOException > {} > > > And the last one (this is something like BadMethodException, but for > properties) > > /** > * The exception that is thrown when accessing a class member (property or > method) fails. > */ > class MemberAccessException extends LogicException > {} > The main problem about adding such classes is that it may/will break BC, so for one they will have to be renamed Spl*Exception. Additionally, there is little point in defining these exceptions if we don't use them internally, and afaik SPL wouldn't need all of them. On the other hand, we still have lot or generic RuntimeExceptions [1], we might want to use more specific classes for them but I believe the currently available exceptions will suffice in most cases. Regards 1: colder@larry ~/cvs/php-src $ fgrep -r "zend_throw_exception" ext/spl/*.c | php -R 'preg_match("/spl_ce_(\w+)/", $argn, $match); echo $match[1]."\n";' | sort | uniq -c 12 BadMethodCallException 1 DomainException 17 InvalidArgumentException 12 LogicException 3 OutOfBoundsException 10 OutOfRangeException 40 RuntimeException 7 UnexpectedValueException > > David Grudl > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- Etienne Kneuss http://www.colder.ch Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal