function _analyzePhpFiles() { if (!$this->_isValid) { return false; } if (!isset($this->_pf->_packageFile)) { $this->_cannotValidateNoPathSet(); 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'); $info = $this->_pf->getContents(); if (!$info || !isset($info['dir']['file'])) { $this->_tagCannotBeEmpty('contents><dir'); return false; } $info = $info['dir']['file']; if (isset($info['attribs'])) { $info = array($info); } $provides = array(); foreach ($info as $fa) { $fa = $fa['attribs']; $file = $fa['name']; if (!file_exists($dir_prefix . DIRECTORY_SEPARATOR . $file)) { $this->_fileNotFound($dir_prefix . DIRECTORY_SEPARATOR . $file); $this->_isValid = 0; continue; } if (in_array($fa['role'], PEAR_Installer_Role::getPhpRoles()) && $dir_prefix) { call_user_func_array($log, array(1, "Analyzing {$file}")); $srcinfo = $this->analyzeSourceCode($dir_prefix . DIRECTORY_SEPARATOR . $file); if ($srcinfo) { $provides = array_merge($provides, $this->_buildProvidesArray($srcinfo)); } } } $this->_packageName = $pn = $this->_pf->getPackage(); $pnl = strlen($pn); foreach ($provides as $key => $what) { if (isset($what['explicit']) || !$what) { // skip conformance checks if the provides entry is // specified in the package.xml file continue; } extract($what); if ($type == 'class') { if (!strncasecmp($name, $pn, $pnl)) { continue; } $this->_stack->push(__FUNCTION__, 'warning', array('file' => $file, 'type' => $type, 'name' => $name, 'package' => $pn), 'in %file%: %type% "%name%" not prefixed with package name "%package%"'); } elseif ($type == 'function') { if (strstr($name, '::') || !strncasecmp($name, $pn, $pnl)) { continue; } $this->_stack->push(__FUNCTION__, 'warning', array('file' => $file, 'type' => $type, 'name' => $name, 'package' => $pn), 'in %file%: %type% "%name%" not prefixed with package name "%package%"'); } } return $this->_isValid; }
/** * Scan through the Command directory looking for classes * and see what commands they implement. * @param string which directory to look for classes, defaults to * the Installer/Roles subdirectory of * the directory from where this file (__FILE__) is * included. * * @return bool TRUE on success, a PEAR error on failure * @access public * @static */ function registerRoles($dir = null) { $GLOBALS['_PEAR_INSTALLER_ROLES'] = array(); $parser = new PEAR_XMLParser(); if ($dir === null) { $dir = dirname(__FILE__) . '/Role'; } if (!file_exists($dir) || !is_dir($dir)) { return PEAR::raiseError("registerRoles: opendir({$dir}) failed"); } $dp = @opendir($dir); if (empty($dp)) { return PEAR::raiseError("registerRoles: opendir({$dir}) failed"); } while ($entry = readdir($dp)) { if ($entry[0] == '.' || substr($entry, -4) != '.xml') { continue; } $class = "PEAR_Installer_Role_" . substr($entry, 0, -4); // List of roles if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) { $file = "{$dir}/{$entry}"; $parser->parse(file_get_contents($file)); $data = $parser->getData(); if (!is_array($data['releasetypes'])) { $data['releasetypes'] = array($data['releasetypes']); } $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data; } } closedir($dp); ksort($GLOBALS['_PEAR_INSTALLER_ROLES']); PEAR_Installer_Role::getBaseinstallRoles(true); PEAR_Installer_Role::getInstallableRoles(true); PEAR_Installer_Role::getPhpRoles(true); PEAR_Installer_Role::getValidRoles('****', true); return true; }
/** * Scan through the Command directory looking for classes * and see what commands they implement. * @param string which directory to look for classes, defaults to * the Installer/Roles subdirectory of * the directory from where this file (__FILE__) is * included. * * @return bool TRUE on success, a PEAR error on failure * @access public * @static */ function registerRoles($dir = null) { if ($dir === null) { $dir = dirname(__FILE__) . '/Role'; } $dp = @opendir($dir); if (empty($dp)) { return PEAR::raiseError("registerRoles: opendir({$dir}) failed"); } while ($entry = readdir($dp)) { if ($entry[0] == '.' || substr($entry, -4) != '.php' || $entry == 'Common.php') { continue; } $class = "PEAR_Installer_Role_" . substr($entry, 0, -4); $file = "{$dir}/{$entry}"; include_once $file; // List of roles if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) { $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = call_user_func(array($class, 'getInfo')); } } @closedir($dp); ksort($GLOBALS['_PEAR_INSTALLER_ROLES']); PEAR_Installer_Role::getBaseinstallRoles(true); PEAR_Installer_Role::getInstallableRoles(true); PEAR_Installer_Role::getPhpRoles(true); PEAR_Installer_Role::getValidRoles('****', true); return true; }