Re: svn: /pear/packages/Log/trunk/ package.php package.xml
| From: | Jon Parise | Date: | Tue, 29 Dec 2009 02:34:01 +0000 |
| Subject: | Re: svn: /pear/packages/Log/trunk/ package.php package.xml | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.cvs php.pear.dev |
| Request: | Send a blank email to pear-dev+get-53174@lists.php.net to get a copy of this message | ||
On Mon, Dec 28, 2009 at 2:16 PM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
> Jon Parise wrote:
>> On Mon, Dec 28, 2009 at 10:37 AM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
>>
>>>> PHP5 introduced a deprecation warning for the '$a = &new' syntax that
>>>> worked in (and is required by?) PHP4. Because this warning is emitted
>>>> at compile-time, the syntax can't be conditionally based on a
>>>> version_compare() result (which is how I work around the other PHP4
>>>> vs. PHP5 incompatibilities).
>>>>
>>>> This warning is only emitted under E_STRICT, but I don't think it's
>>>> reasonable to continue asking all PHP5 users of the PEAR Log package
>>>> to disable E_STRICT reporting.
>>> Keep in mind that E_STRICT is not part of E_ALL, so people who have it
>>> on have explicitly enabled it.
>>
>> I was mistaken. The warning is tagged as E_DEPRECATED, which is part of E_ALL.
>>
>> These are the recommended error_reporting levels:
>>
>> ; Default Value: E_ALL & ~E_NOTICE
>> ; Development Value: E_ALL | E_STRICT
>> ; Production Value: E_ALL & ~E_DEPRECATED
>>
>> ... so end-users tend to see this everywhere except in production
>> (assuming they follow these recommended values).
>
> The other thing to check is why exactly you need a reference to the
> object. Are you passing it around and changing properties in it or
> something? Seems to me like it would be cleaner if you used some access
> methods to modify the object as opposed to passing it around by
> reference in PHP 4.
It's been years since that code was written, but I believe it uses a
reference to support the singleton implementation:
static $instances;
if (!isset($instances)) $instances = array();
$signature = serialize(array($handler, $name, $ident, $conf, $level));
if (!isset($instances[$signature])) {
$instances[$signature] = &Log::factory($handler, $name, $ident,
$conf, $level);
}
return $instances[$signature];
While there may be criticisms of this approach, it's unfortunately not
changeable without breaking backwards compatibility.
I'm certainly open to any other suggestions, of course.
--
Jon Parise (jon of php.net) :: The PHP Project (http://www.php.net/)