PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #5353

suppress deprecated is_a warning in PHP5

Details

Submitted2005-09-09 20:41 UTC
Fromjbyers at jbyers dot com
StatusWont fix
PackageDB
PHP Version4.3.10
OSany
Roadmaps(Not assigned)

Comments

[2005-09-09 20:41 UTC] jbyers at jbyers dot com

Description:
------------
In PHP5, is_a is deprecated in favor of instanceof. Under many configurations, users of PEAR DB will see the following warning:

is_a(): Deprecated. Please use the instanceof operator in DB-1.7.6/DB.php at line 590

Patch below. There's probably a better way of testing the version, but this does seem to work.

Test script:
---------------
Index: DB.php
===================================================================
--- DB.php (revision 2060)
+++ DB.php (working copy)
@@ -587,7 +587,11 @@
*/
function isError($value)
{
- return is_a($value, 'DB_Error');
+ if (intval(substr(phpversion(), 0, 1)) >= 5) {
+ return ($value instanceof DB_Error);
+ } else {
+ return is_a($value, 'DB_Error');
+ }
}

// }}}

[2005-09-09 21:12 UTC] at php dot net

since DB has all sorts of similar warnings poping up in php5 this is somewhat moot. also is_a() will soon be undeprecated.