Re: Suggestion for constants required by classes
| From: | Philippe Jausions | Date: | Wed, 11 Jan 2006 21:05:59 +0000 |
| Subject: | Re: Suggestion for constants required by classes | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-3374@lists.php.net to get a copy of this message | ||
Hi Gustavo,
Obviously, this is not backward-compatible with PHP 4. Maybe for
PHP5-only packages, but that's introducing a double standard for
constants naming, which makes it difficult to use in PHP5 environment
using PHP4 PEAR packages...
I think this is a bad idea, for now at least, until all PHP4 packages
are deprecated for their PHP5 version. So not in a foreseeable future.
Only solution: have both define and const used in the class declaration.
define('DB_ERROR', -1); .... const ERROR = DB_ERROR;
But yet again, not really ideal for userland.
-Philippe
Gustavo Narea 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?
>
> Thanks for your attention.
>
> Regards.
>
> Gustavo Narea.