Re: PHP Standards and Best Practices for PHP 5.3+ Frameworks and Libraries

From: Date: Tue, 26 May 2009 20:09:01 +0000
Subject: Re: PHP Standards and Best Practices for PHP 5.3+ Frameworks and Libraries
Groups: php.standards 
Request: Send a blank email to standards-+get-3@lists.php.net to get a copy of this message
> **Exceptions and Exception Handling** > Each package must provide a base exception of the following name: >   vendor\package\Exception Err. So every package namespace must have an Exception class/interface called literally 'Exception'? That feels a bit of an overkill. How about "SHOULD provide"? > Examples: > File - vendor/packagename/Exception.php > <?php > namespace vendor\packagename; > interface Exception {} > > File - vendor/packagename/UnexpectedValueException.php > <?php > namespace vendor\packagename; > class UnexpectedValueException extends UnexpectedValueException > implements Exception {} I don't even know what this does it is so confusing :) are you sure the example doesn't contain typos? > Exception throwing example: > File - vendor/packagename/Foo.php; > <?php > namespace vendor\packagename; [..] >               throw new UnexpectedValueException($method . ' is not Are you sure this is the most readable way you guys could come up with? > The goal of this meeting was to develop a set of common standards > which PHP projects can strive towards adopting. Kudos. Was there any talk about use statements? Many frameworks seem to reuse exceptions from other packages, thats still valid - or does the package still have to create that "local exception"? -Hannes

« previous php.standards (#3) next »