Re: Re: question about defining constants and pear coding standards

From: Date: Sun, 24 Sep 2006 00:03:58 +0000
Subject: Re: Re: question about defining constants and pear coding standards
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-44021@lists.php.net to get a copy of this message
On 9/23/06, Pierre <pierre.php@gmail.com> wrote:
On Sat, 23 Sep 2006 10:18:33 -0500 terrafrost@gmail.com (Terra Frost) wrote: <? define('SOME_OBJECT_MODE',SOME_OBJECT_PHP); $a = new Some_Object(); echo $a->toString(); ?> If SOME_OBJECT_MODE wasn't specified, a default mode could be used, by (in Some_Object.php) doing something like... if ( !defined('SOME_OBJECT_MODE') ) { define('SOME_OBJECT_MODE',SOME_OBJECT_PHP); } Anyway, the only thing I'm wondering is... would this be okay, per the Pear coding standards? It is. I would name the constant SOME_OBJECT_DEFAULT_MODE though.
I disagree. For PHP4 code you should use PEAR::getStaticProperty(). $options =& PEAR::getStaticProperty('SomeObject', 'options'); $options = array('mode' => SOME_OBJECT_PHP); and for PHP5 code you should use a class static property (which can be overridden by an instance property or something passed into the constructor). SomeObject::$mode = SomeObject::MODE_OBJECT_PHP; -- Justin Patrin

« previous php.pear.dev (#44021) next »