* @author Laurent Laville * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: function_exceptions.php,v 1.5 2008/12/29 10:27:42 farell Exp $ * @link http://pear.php.net/package/PHP_CompatInfo */ $function_exceptions = array(); $ds = DIRECTORY_SEPARATOR; $version_pattern = '\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?'; $ext_pattern = '(.*)\\'.$ds.'phpdocref\\'.$ds.'(.*)\\'.$ds.'versions.xml'; $data_dir = '@data_dir@'.$ds.'@package_name@'.$ds.'data'.$ds.'phpdocref'.$ds; $aliases = array('bc' => 'bcmath', 'bzip2' => 'bz2', 'datetime' => 'date', 'image' => 'gd', 'pdo' => 'PDO', 'simplexml' => 'SimpleXML', 'spl' => 'SPL' ); // Iterating over extension specific version files foreach(glob($data_dir.'*'.$ds.'versions.xml') as $file) { preg_match('/'.$ext_pattern.'/', $file, $matches); $ext = $matches[2]; // real extension name, is case sensitive if (isset($aliases[$ext])) { $ext = $aliases[$ext]; } $xml = simplexml_load_file($file); foreach ($xml->function as $function) { $name = (string) $function['name']; if (strpos($name, '::') !== false) { // Do not keep extension methods class continue; } $from = (string) $function['from']; /** * Match strings like : * "PHP 3 >= 3.0.7, PHP 4, PHP 5" for _ * "PHP 5 >= 5.1.0RC1" for date_modify * "PHP 3 >= 3.0.7, PHP 4 <= 4.2.3" for aspell_check * "PHP 5 >= 5.2.0, PECL zip:1.1.0-1.9.0" for addfile */ if (preg_match('/>= ('.$version_pattern.')/', $from, $matches)) { $init = $matches[1]; if (preg_match('/<= ('.$version_pattern.')/', $from, $matches)) { $end = $matches[1]; } else { $end = false; } if (preg_match('/(\.*)PECL ([a-zA-Z_]+):('.$version_pattern.')-('. $version_pattern.')/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[3]; $function_exceptions[$ext][$name]['end'] = $matches[4]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = true; } elseif (preg_match('/(\.*)PECL ([a-zA-Z_]+):('.$version_pattern.')/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[3]; $function_exceptions[$ext][$name]['end'] = $matches[3]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = true; } else { $function_exceptions[$ext][$name]['init'] = $init; if ($end !== false) { $function_exceptions[$ext][$name]['end'] = $end; } $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; } continue; /** * Match string like : * "PHP 5 <= 5.0.4" for php_check_syntax * "PHP 4 <= 4.2.3, PECL cybercash:1.18" for cybercash_base64_decode */ } elseif (preg_match('/<= ('.$version_pattern.')/', $from, $matches)) { $end = $matches[1]; if (preg_match('/(\.*)PECL ([a-zA-Z_]+):('.$version_pattern.')-('. $version_pattern.')/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[3]; $function_exceptions[$ext][$name]['end'] = $matches[4]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = true; continue; } elseif (preg_match('/(\.*)PECL ([a-zA-Z_]+):('.$version_pattern.')/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[3]; $function_exceptions[$ext][$name]['end'] = $matches[3]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = true; continue; } $function_exceptions[$ext][$name]['end'] = $end; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; /** * Match string like : * "4.0.2 - 4.0.6 only" for accept_connect */ } elseif (preg_match('/('.$version_pattern.') - ('.$version_pattern.') only/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[1]; $function_exceptions[$ext][$name]['end'] = $matches[2]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; continue; /** * Match string like : * "PHP 3.0.5 only" for PHP3_UODBC_FIELD_NUM * "PHP 4.0.6 only" for ocifreecoll */ } elseif (preg_match('/PHP (\d)('.$version_pattern.') only/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[1] .'.0.0'; $function_exceptions[$ext][$name]['end'] = $matches[2]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; continue; /** * Match string like : * "PHP 5, PECL oci8:1.1-1.2.4" for oci_error */ } elseif (preg_match('/(\.*)PECL ([a-zA-Z_]+):('.$version_pattern.')-('. $version_pattern.')/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[3]; $function_exceptions[$ext][$name]['end'] = $matches[4]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = true; continue; /** * Match string like : * "PHP 4, PHP 5, PECL mysql:1.0" for mysql_connect */ } elseif (preg_match('/(\.*)PECL ([a-zA-Z_]+):('.$version_pattern.')/', $from, $matches)) { $function_exceptions[$ext][$name]['init'] = $matches[3]; $function_exceptions[$ext][$name]['end'] = $matches[3]; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = true; continue; } if (strpos($function['from'], 'PHP 3') !== false) { $function_exceptions[$ext][$name]['init'] = '3.0.0'; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; continue; } if (strpos($function['from'], 'PHP 4') !== false) { $function_exceptions[$ext][$name]['init'] = '4.0.0'; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; continue; } if (strpos($function['from'], 'PHP 5') !== false) { $function_exceptions[$ext][$name]['init'] = '5.0.0'; $function_exceptions[$ext][$name]['ext'] = $ext; $function_exceptions[$ext][$name]['pecl'] = false; continue; } } } // end-iterating over extension specific version files ?>