Re: Suggestion for constants required by classes
| From: | Justin Patrin | Date: | Wed, 11 Jan 2006 20:49:45 +0000 |
| Subject: | Re: Suggestion for constants required by classes | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-3376@lists.php.net to get a copy of this message | ||
On 1/11/06, Gustavo Narea <gustavo@php.net> wrote:
> Dear PEAR QA:
>
> I think constants required by classes should not be defined in a global
> scope but within the same class. I suggest this because of semantic
> reasons, as well as in order to avoid them to be already defined in
> another place within the script.
>
> For instance, use this line in PEAR::DB:
>
> const ERROR = -1;
>
> instead of:
>
> define('DB_ERROR', -1);
>
>
> What do you think about it? Could it be taken into account for the
> coding standards?
>
Sounds like a good idea. Unfortunately this will only work with PHP5,
so most PEAR packages won't be able to take advantage of it as yet. It
certainly couldn't be changed in stable classes as this would be a BC
break. For PHP5 packages going forward it sounds like a great idea to
me.
--
Justin Patrin