1,28 → 1,27 |
<?php |
// |
// +----------------------------------------------------------------------+ |
// | PHP Version 5 | |
// +----------------------------------------------------------------------+ |
// | Copyright (c) 1997-2004 The PHP Group | |
// +----------------------------------------------------------------------+ |
// | This source file is subject to version 3.0 of the PHP license, | |
// | that is bundled with this package in the file LICENSE, and is | |
// | available through the world-wide-web at the following url: | |
// | http://www.php.net/license/3_0.txt. | |
// | If you did not receive a copy of the PHP license and are unable to | |
// | obtain it through the world-wide-web, please send a note to | |
// | license@php.net so we can mail you a copy immediately. | |
// +----------------------------------------------------------------------+ |
// | Author: Greg Beaver <cellog@php.net> | |
// | | |
// +----------------------------------------------------------------------+ |
// |
// $Id: Validator.php,v 1.97 2007/02/10 05:56:18 cellog Exp $ |
/** |
* PEAR_PackageFile_v2, package.xml version 2.0, read/write version |
* |
* PHP versions 4 and 5 |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a8 |
*/ |
/** |
* Private validation class used by PEAR_PackageFile_v2 - do not use directly, its |
* sole purpose is to split up the PEAR/PackageFile/v2.php file to make it smaller |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a8 |
* @author Greg Beaver <cellog@php.net> |
* @access private |
*/ |
class PEAR_PackageFile_v2_Validator |
72,8 → 71,7 |
} |
if (!isset($this->_packageInfo['attribs']['version']) || |
($this->_packageInfo['attribs']['version'] != '2.0' && |
$this->_packageInfo['attribs']['version'] != '2.1') |
) { |
$this->_packageInfo['attribs']['version'] != '2.1')) { |
$this->_noPackageVersion(); |
} |
$structure = |
111,10 → 109,8 |
isset($test['dependencies']['required']) && |
isset($test['dependencies']['required']['pearinstaller']) && |
isset($test['dependencies']['required']['pearinstaller']['min']) && |
'1.10.1' != '@package' . '_version@' && |
version_compare('1.10.1', |
$test['dependencies']['required']['pearinstaller']['min'], '<') |
) { |
version_compare('1.5.1', |
$test['dependencies']['required']['pearinstaller']['min'], '<')) { |
$this->_pearVersionTooLow($test['dependencies']['required']['pearinstaller']['min']); |
return false; |
} |
134,13 → 130,18 |
if (array_key_exists('_lastversion', $test)) { |
unset($test['_lastversion']); |
} |
if (!$this->_stupidSchemaValidate($structure, $test, '<package>')) { |
if (!$this->_stupidSchemaValidate($structure, |
$test, '<package>')) { |
return false; |
} |
if (empty($this->_packageInfo['name'])) { |
$this->_tagCannotBeEmpty('name'); |
} |
$test = isset($this->_packageInfo['uri']) ? 'uri' :'channel'; |
if (isset($this->_packageInfo['uri'])) { |
$test = 'uri'; |
} else { |
$test = 'channel'; |
} |
if (empty($this->_packageInfo[$test])) { |
$this->_tagCannotBeEmpty($test); |
} |
232,17 → 233,14 |
} |
} |
} |
|
if ($fail) { |
return false; |
} |
|
$list = $this->_packageInfo['contents']; |
if (isset($list['dir']) && is_array($list['dir']) && isset($list['dir'][0])) { |
$this->_multipleToplevelDirNotAllowed(); |
return $this->_isValid = 0; |
} |
|
$this->_validateFilelist(); |
$this->_validateRelease(); |
if (!$this->_stack->hasErrors()) { |
256,10 → 254,11 |
$validator = $chan->getValidationObject($this->_pf->getPackage()); |
if (!$validator) { |
$this->_stack->push(__FUNCTION__, 'error', |
array('channel' => $chan->getName(), |
'package' => $this->_pf->getPackage(), |
'name' => $valpack['_content'], |
'version' => $valpack['attribs']['version']), |
array_merge( |
array('channel' => $chan->getName(), |
'package' => $this->_pf->getPackage()), |
$valpack |
), |
'package "%channel%/%package%" cannot be properly validated without ' . |
'validation package "%channel%/%name%-%version%"'); |
return $this->_isValid = 0; |
277,7 → 276,6 |
} |
} |
} |
|
$this->_pf->_isValid = $this->_isValid = !$this->_stack->hasErrors('error'); |
if ($this->_isValid && $state == PEAR_VALIDATE_PACKAGING && !$this->_filesValid) { |
if ($this->_pf->getPackageType() == 'bundle') { |
294,11 → 292,9 |
} |
} |
} |
|
if ($this->_isValid) { |
return $this->_pf->_isValid = $this->_isValid = $state; |
} |
|
return $this->_pf->_isValid = $this->_isValid = 0; |
} |
|
470,21 → 466,21 |
$a = $this->_stupidSchemaValidate($structure, $this->_packageInfo['version'], '<version>'); |
$a &= $this->_stupidSchemaValidate($structure, $this->_packageInfo['stability'], '<stability>'); |
if ($a) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$this->_packageInfo['version']['release'])) { |
$this->_invalidVersion('release', $this->_packageInfo['version']['release']); |
} |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$this->_packageInfo['version']['api'])) { |
$this->_invalidVersion('api', $this->_packageInfo['version']['api']); |
} |
if (!in_array($this->_packageInfo['stability']['release'], |
array('snapshot', 'devel', 'alpha', 'beta', 'stable'))) { |
$this->_invalidState('release', $this->_packageInfo['stability']['release']); |
$this->_invalidState('release', $this->_packageinfo['stability']['release']); |
} |
if (!in_array($this->_packageInfo['stability']['api'], |
array('devel', 'alpha', 'beta', 'stable'))) { |
$this->_invalidState('api', $this->_packageInfo['stability']['api']); |
$this->_invalidState('api', $this->_packageinfo['stability']['api']); |
} |
} |
} |
523,13 → 519,13 |
$type = $installcondition ? '<installcondition><php>' : '<dependencies><required><php>'; |
$this->_stupidSchemaValidate($structure, $dep, $type); |
if (isset($dep['min'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/', |
$dep['min'])) { |
$this->_invalidVersion($type . '<min>', $dep['min']); |
} |
} |
if (isset($dep['max'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/', |
$dep['max'])) { |
$this->_invalidVersion($type . '<max>', $dep['max']); |
} |
540,7 → 536,7 |
} |
foreach ($dep['exclude'] as $exclude) { |
if (!preg_match( |
'/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/', |
'/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/', |
$exclude)) { |
$this->_invalidVersion($type . '<exclude>', $exclude); |
} |
558,7 → 554,7 |
); |
$this->_stupidSchemaValidate($structure, $dep, '<dependencies><required><pearinstaller>'); |
if (isset($dep['min'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['min'])) { |
$this->_invalidVersion('<dependencies><required><pearinstaller><min>', |
$dep['min']); |
565,7 → 561,7 |
} |
} |
if (isset($dep['max'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['max'])) { |
$this->_invalidVersion('<dependencies><required><pearinstaller><max>', |
$dep['max']); |
572,7 → 568,7 |
} |
} |
if (isset($dep['recommended'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['recommended'])) { |
$this->_invalidVersion('<dependencies><required><pearinstaller><recommended>', |
$dep['recommended']); |
583,7 → 579,7 |
$dep['exclude'] = array($dep['exclude']); |
} |
foreach ($dep['exclude'] as $exclude) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$exclude)) { |
$this->_invalidVersion('<dependencies><required><pearinstaller><exclude>', |
$exclude); |
645,19 → 641,19 |
$this->_DepchannelCannotBeUri('<dependencies>' . $group . $type); |
} |
if (isset($dep['min'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['min'])) { |
$this->_invalidVersion('<dependencies>' . $group . $type . '<min>', $dep['min']); |
} |
} |
if (isset($dep['max'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['max'])) { |
$this->_invalidVersion('<dependencies>' . $group . $type . '<max>', $dep['max']); |
} |
} |
if (isset($dep['recommended'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['recommended'])) { |
$this->_invalidVersion('<dependencies>' . $group . $type . '<recommended>', |
$dep['recommended']); |
668,7 → 664,7 |
$dep['exclude'] = array($dep['exclude']); |
} |
foreach ($dep['exclude'] as $exclude) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$exclude)) { |
$this->_invalidVersion('<dependencies>' . $group . $type . '<exclude>', |
$exclude); |
717,19 → 713,19 |
} |
$this->_stupidSchemaValidate($structure, $dep, $type); |
if (isset($dep['min'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['min'])) { |
$this->_invalidVersion(substr($type, 1) . '<min', $dep['min']); |
} |
} |
if (isset($dep['max'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['max'])) { |
$this->_invalidVersion(substr($type, 1) . '<max', $dep['max']); |
} |
} |
if (isset($dep['recommended'])) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$dep['recommended'])) { |
$this->_invalidVersion(substr($type, 1) . '<recommended', $dep['recommended']); |
} |
739,7 → 735,7 |
$dep['exclude'] = array($dep['exclude']); |
} |
foreach ($dep['exclude'] as $exclude) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$exclude)) { |
$this->_invalidVersion(substr($type, 1) . '<exclude', $exclude); |
} |
936,13 → 932,13 |
} |
$this->_stupidSchemaValidate($required, $package, $type); |
if (is_array($package) && array_key_exists('min', $package)) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$package['min'])) { |
$this->_invalidVersion(substr($type, 1) . '<min', $package['min']); |
} |
} |
if (is_array($package) && array_key_exists('max', $package)) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$package['max'])) { |
$this->_invalidVersion(substr($type, 1) . '<max', $package['max']); |
} |
952,7 → 948,7 |
$package['exclude'] = array($package['exclude']); |
} |
foreach ($package['exclude'] as $exclude) { |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/', |
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/', |
$exclude)) { |
$this->_invalidVersion(substr($type, 1) . '<exclude', $exclude); |
} |
1011,11 → 1007,6 |
$dirname = $iscontents ? '<contents>' : $unknown; |
} else { |
$dirname = '<dir name="' . $list['attribs']['name'] . '">'; |
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~', |
str_replace('\\', '/', $list['attribs']['name']))) { |
// file contains .. parent directory or . cur directory |
$this->_invalidDirName($list['attribs']['name']); |
} |
} |
$res = $this->_stupidSchemaValidate($struc, $list, $dirname); |
if ($allowignore && $res) { |
1045,12 → 1036,6 |
$ignored_or_installed[$file['attribs']['name']] = array(); |
} |
$ignored_or_installed[$file['attribs']['name']][] = 1; |
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~', |
str_replace('\\', '/', $file['attribs']['as']))) { |
// file contains .. parent directory or . cur directory references |
$this->_invalidFileInstallAs($file['attribs']['name'], |
$file['attribs']['as']); |
} |
} |
} |
if (isset($list['ignore'])) { |
1069,10 → 1054,6 |
} |
} |
if (!$allowignore && isset($list['file'])) { |
if (is_string($list['file'])) { |
$this->_oldStyleFileNotAllowed(); |
return false; |
} |
if (!isset($list['file'][0])) { |
// single file |
$list['file'] = array($list['file']); |
1079,17 → 1060,11 |
} |
foreach ($list['file'] as $i => $file) |
{ |
if (isset($file['attribs']) && isset($file['attribs']['name'])) { |
if ($file['attribs']['name']{0} == '.' && |
$file['attribs']['name']{1} == '/') { |
// name is something like "./doc/whatever.txt" |
$this->_invalidFileName($file['attribs']['name'], $dirname); |
} |
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~', |
str_replace('\\', '/', $file['attribs']['name']))) { |
// file contains .. parent directory or . cur directory |
$this->_invalidFileName($file['attribs']['name'], $dirname); |
} |
if (isset($file['attribs']) && isset($file['attribs']['name']) && |
$file['attribs']['name']{0} == '.' && |
$file['attribs']['name']{1} == '/') { |
// name is something like "./doc/whatever.txt" |
$this->_invalidFileName($file['attribs']['name']); |
} |
if (isset($file['attribs']) && isset($file['attribs']['role'])) { |
if (!$this->_validateRole($file['attribs']['role'])) { |
1329,7 → 1304,7 |
} |
if (is_array($rel) && array_key_exists('filelist', $rel)) { |
if ($rel['filelist']) { |
|
|
$this->_validateFilelist($rel['filelist'], true); |
} |
} |
1350,7 → 1325,7 |
$this->_stack->push(__FUNCTION__, 'error', |
array('version' => $version), |
'This package.xml requires PEAR version %version% to parse properly, we are ' . |
'version 1.10.1'); |
'version 1.5.1'); |
} |
|
function _invalidTagOrder($oktags, $actual, $root) |
1374,13 → 1349,6 |
'<contents>, use <ignore> and <install> only'); |
} |
|
function _oldStyleFileNotAllowed() |
{ |
$this->_stack->push(__FUNCTION__, 'error', array(), |
'Old-style <file>name</file> is not allowed. Use' . |
'<file name="name" role="role"/>'); |
} |
|
function _tagMissingAttribute($tag, $attr, $context) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array('tag' => $tag, |
1413,23 → 1381,9 |
{ |
$this->_stack->push(__FUNCTION__, 'error', array( |
'file' => $file), |
'File "%file%" in directory "%dir%" cannot begin with "./" or contain ".."'); |
'File "%file%" cannot begin with "."'); |
} |
|
function _invalidFileInstallAs($file, $as) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array( |
'file' => $file, 'as' => $as), |
'File "%file%" <install as="%as%"/> cannot contain "./" or contain ".."'); |
} |
|
function _invalidDirName($dir) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array( |
'dir' => $file), |
'Directory "%dir%" cannot begin with "./" or contain ".."'); |
} |
|
function _filelistCannotContainFile($filelist) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array('tag' => $filelist), |
1671,13 → 1625,13 |
function _usesroletaskMustHaveChannelOrUri($role, $tag) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array('role' => $role, 'tag' => $tag), |
'<%tag%> for role "%role%" must contain either <uri>, or <channel> and <package>'); |
'<%tag%> must contain either <uri>, or <channel> and <package>'); |
} |
|
function _usesroletaskMustHavePackage($role, $tag) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array('role' => $role, 'tag' => $tag), |
'<%tag%> for role "%role%" must contain <package>'); |
'<%tag%> must contain <package>'); |
} |
|
function _usesroletaskMustHaveRoleTask($tag, $type) |
1694,7 → 1648,7 |
|
function _invalidDepGroupName($name) |
{ |
$this->_stack->push(__FUNCTION__, 'error', array('name' => $name), |
$this->_stack->push(__FUNCTION__, 'error', array('group' => $name), |
'Invalid dependency group name "%name%"'); |
} |
|
1729,15 → 1683,14 |
return false; |
} |
$dir_prefix = dirname($this->_pf->_packageFile); |
$common = new PEAR_Common; |
$log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') : |
array($common, 'log'); |
array('PEAR_Common', 'log'); |
$info = $this->_pf->getContents(); |
$info = $info['bundledpackage']; |
if (!is_array($info)) { |
$info = array($info); |
} |
$pkg = new PEAR_PackageFile($this->_pf->_config); |
$pkg = &new PEAR_PackageFile($this->_pf->_config); |
foreach ($info as $package) { |
if (!file_exists($dir_prefix . DIRECTORY_SEPARATOR . $package)) { |
$this->_fileNotFound($dir_prefix . DIRECTORY_SEPARATOR . $package); |
1845,19 → 1798,15 |
'Parser error: token_get_all() function must exist to analyze source code, PHP may have been compiled with --disable-tokenizer'); |
return false; |
} |
|
if (!defined('T_DOC_COMMENT')) { |
define('T_DOC_COMMENT', T_COMMENT); |
} |
|
if (!defined('T_INTERFACE')) { |
define('T_INTERFACE', -1); |
} |
|
if (!defined('T_IMPLEMENTS')) { |
define('T_IMPLEMENTS', -1); |
} |
|
if ($string) { |
$contents = $file; |
} else { |
1867,18 → 1816,7 |
fclose($fp); |
$contents = file_get_contents($file); |
} |
|
// Silence this function so we can catch PHP Warnings and show our own custom message |
$tokens = @token_get_all($contents); |
if (isset($php_errormsg)) { |
if (isset($this->_stack)) { |
$pn = $this->_pf->getPackage(); |
$this->_stack->push(__FUNCTION__, 'warning', |
array('file' => $file, 'package' => $pn), |
'in %file%: Could not process file for unknown reasons,' . |
' possibly a PHP parse error in %file% from %package%'); |
} |
} |
$tokens = token_get_all($contents); |
/* |
for ($i = 0; $i < sizeof($tokens); $i++) { |
@list($token, $data) = $tokens[$i]; |
1918,7 → 1856,6 |
$token = $tokens[$i]; |
$data = ''; |
} |
|
if ($inquote) { |
if ($token != '"' && $token != T_END_HEREDOC) { |
continue; |
1927,7 → 1864,6 |
continue; |
} |
} |
|
switch ($token) { |
case T_WHITESPACE : |
continue; |
1963,14 → 1899,8 |
$interface = true; |
case T_CLASS: |
if (($current_class_level != -1) || ($current_function_level != -1)) { |
if (isset($this->_stack)) { |
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file), |
'Parser error: invalid PHP found in file "%file%"'); |
} else { |
PEAR::raiseError("Parser error: invalid PHP found in file \"$file\"", |
PEAR_COMMON_ERROR_INVALIDPHP); |
} |
|
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file), |
'Parser error: invalid PHP found in file "%file%"'); |
return false; |
} |
case T_FUNCTION: |
1980,6 → 1910,17 |
$look_for = $token; |
continue 2; |
case T_STRING: |
if (version_compare(zend_version(), '2.0', '<')) { |
if (in_array(strtolower($data), |
array('public', 'private', 'protected', 'abstract', |
'interface', 'implements', 'throw') |
)) { |
$this->_stack->push(__FUNCTION__, 'warning', array( |
'file' => $file), |
'Error, PHP5 token encountered in %file%,' . |
' analysis should be in PHP5'); |
} |
} |
if ($look_for == T_CLASS) { |
$current_class = $data; |
$current_class_level = $brace_level; |
2003,13 → 1944,11 |
$current_function = $data; |
$declared_functions[] = $current_function; |
} |
|
$current_function_level = $brace_level; |
$m = array(); |
} elseif ($look_for == T_NEW) { |
$used_classes[$data] = true; |
} |
|
$look_for = 0; |
continue 2; |
case T_VARIABLE: |
2025,28 → 1964,18 |
} |
continue 2; |
case T_DOUBLE_COLON: |
$token = $tokens[$i - 1][0]; |
if (!($token == T_WHITESPACE || $token == T_STRING || $token == T_STATIC || $token == T_VARIABLE)) { |
if (isset($this->_stack)) { |
$this->_stack->push(__FUNCTION__, 'warning', array('file' => $file), |
'Parser error: invalid PHP found in file "%file%"'); |
} else { |
PEAR::raiseError("Parser error: invalid PHP found in file \"$file\"", |
PEAR_COMMON_ERROR_INVALIDPHP); |
} |
|
if (!($tokens[$i - 1][0] == T_WHITESPACE || $tokens[$i - 1][0] == T_STRING)) { |
$this->_stack->push(__FUNCTION__, 'warning', array('file' => $file), |
'Parser error: invalid PHP found in file "%file%"'); |
return false; |
} |
|
$class = $tokens[$i - 1][1]; |
if (strtolower($class) != 'parent') { |
$used_classes[$class] = true; |
} |
|
continue 2; |
} |
} |
|
return array( |
"source_file" => $file, |
"declared_classes" => $declared_classes, |
2056,7 → 1985,7 |
"used_classes" => array_diff(array_keys($used_classes), $nodeps), |
"inheritance" => $extends, |
"implements" => $implements, |
); |
); |
} |
|
/** |
2083,17 → 2012,15 |
if (!$this->_isValid) { |
return array(); |
} |
|
$providesret = array(); |
$file = basename($srcinfo['source_file']); |
$pn = isset($this->_pf) ? $this->_pf->getPackage() : ''; |
$pnl = strlen($pn); |
$file = basename($srcinfo['source_file']); |
$pn = $this->_pf->getPackage(); |
$pnl = strlen($pn); |
foreach ($srcinfo['declared_classes'] as $class) { |
$key = "class;$class"; |
if (isset($providesret[$key])) { |
continue; |
} |
|
$providesret[$key] = |
array('file'=> $file, 'type' => 'class', 'name' => $class); |
if (isset($srcinfo['inheritance'][$class])) { |
2101,7 → 2028,6 |
$srcinfo['inheritance'][$class]; |
} |
} |
|
foreach ($srcinfo['declared_methods'] as $class => $methods) { |
foreach ($methods as $method) { |
$function = "$class::$method"; |
2110,7 → 2036,6 |
isset($providesret[$key])) { |
continue; |
} |
|
$providesret[$key] = |
array('file'=> $file, 'type' => 'function', 'name' => $function); |
} |
2121,15 → 2046,13 |
if ($function{0} == '_' || isset($providesret[$key])) { |
continue; |
} |
|
if (!strstr($function, '::') && strncasecmp($function, $pn, $pnl)) { |
$warnings[] = "in1 " . $file . ": function \"$function\" not prefixed with package name \"$pn\""; |
} |
|
$providesret[$key] = |
array('file'=> $file, 'type' => 'function', 'name' => $function); |
} |
|
return $providesret; |
} |
} |
?> |