示例#1
0
文件: v1.php 项目: michabbb/pear-core
 /**
  * Validate XML package definition file.
  *
  * @access public
  * @return boolean
  */
 function validate($state = PEAR_VALIDATE_NORMAL, $nofilechecking = false)
 {
     if (($this->_isValid & $state) == $state) {
         return true;
     }
     $this->_isValid = true;
     $info = $this->_packageInfo;
     if (empty($info['package'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NAME);
         $this->_packageName = $pn = 'unknown';
     } else {
         $this->_packageName = $pn = $info['package'];
     }
     if (empty($info['summary'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_SUMMARY);
     } elseif (strpos(trim($info['summary']), "\n") !== false) {
         $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_MULTILINE_SUMMARY, array('summary' => $info['summary']));
     }
     if (empty($info['description'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DESCRIPTION);
     }
     if (empty($info['release_license'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_LICENSE);
     }
     if (empty($info['version'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_VERSION);
     }
     if (empty($info['release_state'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_STATE);
     }
     if (empty($info['release_date'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DATE);
     }
     if (empty($info['release_notes'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NOTES);
     }
     if (empty($info['maintainers'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTAINERS);
     } else {
         $haslead = false;
         $i = 1;
         foreach ($info['maintainers'] as $m) {
             if (empty($m['handle'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTHANDLE, array('index' => $i));
             }
             if (empty($m['role'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE, array('index' => $i, 'roles' => PEAR_Common::getUserRoles()));
             } elseif ($m['role'] == 'lead') {
                 $haslead = true;
             }
             if (empty($m['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME, array('index' => $i));
             }
             if (empty($m['email'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTEMAIL, array('index' => $i));
             }
             $i++;
         }
         if (!$haslead) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_LEAD);
         }
     }
     if (!empty($info['release_deps'])) {
         $i = 1;
         foreach ($info['release_deps'] as $d) {
             if (!isset($d['type']) || empty($d['type'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE, array('index' => $i, 'types' => PEAR_Common::getDependencyTypes()));
                 continue;
             }
             if (!isset($d['rel']) || empty($d['rel'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPREL, array('index' => $i, 'rels' => PEAR_Common::getDependencyRelations()));
                 continue;
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPOPTIONAL, array('index' => $i, 'opt' => $d['optional']));
                 }
             }
             if ($d['rel'] != 'has' && $d['rel'] != 'not' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPVERSION, array('index' => $i));
             } elseif (($d['rel'] == 'has' || $d['rel'] == 'not') && !empty($d['version'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPVERSION_IGNORED, array('index' => $i, 'rel' => $d['rel']));
             }
             if ($d['type'] == 'php' && !empty($d['name'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPNAME_IGNORED, array('index' => $i, 'name' => $d['name']));
             } elseif ($d['type'] != 'php' && empty($d['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPNAME, array('index' => $i));
             }
             if ($d['type'] == 'php' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPPHPVERSION, array('index' => $i));
             }
             if ($d['rel'] == 'not' && $d['type'] == 'php') {
                 $this->_validateError(PEAR_PACKAGEFILE_PHP_NO_NOT, array('index' => $i));
             }
             $i++;
         }
     }
     if (!empty($info['configure_options'])) {
         $i = 1;
         foreach ($info['configure_options'] as $c) {
             if (empty($c['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_CONFNAME, array('index' => $i));
             }
             if (empty($c['prompt'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_CONFPROMPT, array('index' => $i));
             }
             $i++;
         }
     }
     if (empty($info['filelist'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_FILES);
         $errors[] = 'no files';
     } else {
         foreach ($info['filelist'] as $file => $fa) {
             if (empty($fa['role'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_FILEROLE, array('file' => $file, 'roles' => PEAR_Common::getFileRoles()));
                 continue;
             } elseif (!in_array($fa['role'], PEAR_Common::getFileRoles())) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE, array('file' => $file, 'role' => $fa['role'], 'roles' => PEAR_Common::getFileRoles()));
             }
             if (preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $file))) {
                 // file contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file));
             }
             if (isset($fa['install-as']) && preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $fa['install-as']))) {
                 // install-as contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file . ' [installed as ' . $fa['install-as'] . ']'));
             }
             if (isset($fa['baseinstalldir']) && preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $fa['baseinstalldir']))) {
                 // install-as contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file . ' [baseinstalldir ' . $fa['baseinstalldir'] . ']'));
             }
         }
     }
     if (isset($this->_registry) && $this->_isValid) {
         $chan = $this->_registry->getChannel('pear.php.net');
         if (PEAR::isError($chan)) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $chan->getMessage());
             return $this->_isValid = 0;
         }
         $validator = $chan->getValidationObject();
         $validator->setPackageFile($this);
         $validator->validate($state);
         $failures = $validator->getFailures();
         foreach ($failures['errors'] as $error) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $error);
         }
         foreach ($failures['warnings'] as $warning) {
             $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $warning);
         }
     }
     if ($this->_isValid && $state == PEAR_VALIDATE_PACKAGING && !$nofilechecking) {
         if ($this->_analyzePhpFiles()) {
             $this->_isValid = true;
         }
     }
     if ($this->_isValid) {
         return $this->_isValid = $state;
     }
     return $this->_isValid = 0;
 }
示例#2
0
 function getFileRoles()
 {
     return PEAR_Common::getFileRoles();
 }
示例#3
0
 function _convertPackage($packagexml)
 {
     $pkg =& $this->getPackageFile($this->config);
     $pf2 =& $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
     if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
         return $this->raiseError('Cannot process "' . $packagexml . '", is not a package.xml 2.0');
     }
     require_once 'PEAR/PackageFile/v1.php';
     $pf = new PEAR_PackageFile_v1();
     $pf->setConfig($this->config);
     if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", is not an extension source package.  Using a PEAR_PackageFileManager-based ' . 'script is an option');
     }
     if (is_array($pf2->getUsesRole())) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles.  Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
     }
     if (is_array($pf2->getUsesTask())) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom tasks.  Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
     }
     $deps = $pf2->getDependencies();
     if (isset($deps['group'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains dependency groups.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
     }
     if (isset($deps['required']['subpackage']) || isset($deps['optional']['subpackage'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains subpackage dependencies.  Using a PEAR_PackageFileManager-based  ' . 'script is an option');
     }
     if (isset($deps['required']['os'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains os dependencies.  Using a PEAR_PackageFileManager-based  ' . 'script is an option');
     }
     if (isset($deps['required']['arch'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains arch dependencies.  Using a PEAR_PackageFileManager-based  ' . 'script is an option');
     }
     $pf->setPackage($pf2->getPackage());
     $pf->setSummary($pf2->getSummary());
     $pf->setDescription($pf2->getDescription());
     foreach ($pf2->getMaintainers() as $maintainer) {
         $pf->addMaintainer($maintainer['role'], $maintainer['handle'], $maintainer['name'], $maintainer['email']);
     }
     $pf->setVersion($pf2->getVersion());
     $pf->setDate($pf2->getDate());
     $pf->setLicense($pf2->getLicense());
     $pf->setState($pf2->getState());
     $pf->setNotes($pf2->getNotes());
     $pf->addPhpDep($deps['required']['php']['min'], 'ge');
     if (isset($deps['required']['php']['max'])) {
         $pf->addPhpDep($deps['required']['php']['max'], 'le');
     }
     if (isset($deps['required']['package'])) {
         if (!isset($deps['required']['package'][0])) {
             $deps['required']['package'] = array($deps['required']['package']);
         }
         foreach ($deps['required']['package'] as $dep) {
             if (!isset($dep['channel'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains dependency on a non-standard channel package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['conflicts'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addPackageDep($dep['name'], $dep['min'], 'ge');
             }
             if (isset($dep['max'])) {
                 $pf->addPackageDep($dep['name'], $dep['max'], 'le');
             }
         }
     }
     if (isset($deps['required']['extension'])) {
         if (!isset($deps['required']['extension'][0])) {
             $deps['required']['extension'] = array($deps['required']['extension']);
         }
         foreach ($deps['required']['extension'] as $dep) {
             if (isset($dep['conflicts'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
             }
             if (isset($dep['max'])) {
                 $pf->addExtensionDep($dep['name'], $dep['max'], 'le');
             }
         }
     }
     if (isset($deps['optional']['package'])) {
         if (!isset($deps['optional']['package'][0])) {
             $deps['optional']['package'] = array($deps['optional']['package']);
         }
         foreach ($deps['optional']['package'] as $dep) {
             if (!isset($dep['channel'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains dependency on a non-standard channel package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
             }
             if (isset($dep['max'])) {
                 $pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
             }
         }
     }
     if (isset($deps['optional']['extension'])) {
         if (!isset($deps['optional']['extension'][0])) {
             $deps['optional']['extension'] = array($deps['optional']['extension']);
         }
         foreach ($deps['optional']['extension'] as $dep) {
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes');
             }
             if (isset($dep['max'])) {
                 $pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
             }
         }
     }
     $contents = $pf2->getContents();
     $release = $pf2->getReleases();
     if (isset($releases[0])) {
         return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' . 'multiple extsrcrelease/zendextsrcrelease tags.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
     }
     if ($configoptions = $pf2->getConfigureOptions()) {
         foreach ($configoptions as $option) {
             $pf->addConfigureOption($option['name'], $option['prompt'], isset($option['default']) ? $option['default'] : false);
         }
     }
     if (isset($release['filelist']['ignore'])) {
         return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' . 'ignore tags.  Using a PEAR_PackageFileManager-based script or the convert' . ' command is an option');
     }
     if (isset($release['filelist']['install']) && !isset($release['filelist']['install'][0])) {
         $release['filelist']['install'] = array($release['filelist']['install']);
     }
     if (isset($contents['dir']['attribs']['baseinstalldir'])) {
         $baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
     } else {
         $baseinstalldir = false;
     }
     if (!isset($contents['dir']['file'][0])) {
         $contents['dir']['file'] = array($contents['dir']['file']);
     }
     foreach ($contents['dir']['file'] as $file) {
         if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
             $file['attribs']['baseinstalldir'] = $baseinstalldir;
         }
         $processFile = $file;
         unset($processFile['attribs']);
         if (count($processFile)) {
             foreach ($processFile as $name => $task) {
                 if ($name != $pf2->getTasksNs() . ':replace') {
                     return $this->raiseError('Cannot safely process "' . $packagexml . '" contains tasks other than replace.  Using a ' . 'PEAR_PackageFileManager-based script is an option.');
                 }
                 $file['attribs']['replace'][] = $task;
             }
         }
         if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
             return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
         }
         if (isset($release['filelist']['install'])) {
             foreach ($release['filelist']['install'] as $installas) {
                 if ($installas['attribs']['name'] == $file['attribs']['name']) {
                     $file['attribs']['install-as'] = $installas['attribs']['as'];
                 }
             }
         }
         $pf->addFile('/', $file['attribs']['name'], $file['attribs']);
     }
     if ($pf2->getChangeLog()) {
         $this->ui->outputData('WARNING: changelog is not translated to package.xml ' . '1.0, use PEAR_PackageFileManager-based script if you need changelog-' . 'translation for package.xml 1.0');
     }
     $gen =& $pf->getDefaultGenerator();
     $gen->toPackageFile('.');
 }
示例#4
0
 /**
  * Validate XML package definition file.
  *
  * @param  string $info Filename of the package archive or of the
  *                package definition file
  * @param  array $errors Array that will contain the errors
  * @param  array $warnings Array that will contain the warnings
  * @param  string $dir_prefix (optional) directory where source files
  *                may be found, or empty if they are not available
  * @access public
  * @return boolean
  */
 function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
 {
     if (PEAR::isError($info = $this->infoFromAny($info))) {
         return $this->raiseError($info);
     }
     if (!is_array($info)) {
         return false;
     }
     $errors = array();
     $warnings = array();
     if (!isset($info['package'])) {
         $errors[] = 'missing package name';
     } elseif (!$this->validPackageName($info['package'])) {
         $errors[] = 'invalid package name';
     }
     $this->_packageName = $pn = $info['package'];
     if (empty($info['summary'])) {
         $errors[] = 'missing summary';
     } elseif (strpos(trim($info['summary']), "\n") !== false) {
         $warnings[] = 'summary should be on a single line';
     }
     if (empty($info['description'])) {
         $errors[] = 'missing description';
     }
     if (empty($info['release_license'])) {
         $errors[] = 'missing license';
     }
     if (!isset($info['version'])) {
         $errors[] = 'missing version';
     } elseif (!$this->validPackageVersion($info['version'])) {
         $errors[] = 'invalid package version';
     }
     if (empty($info['release_state'])) {
         $errors[] = 'missing release state';
     } elseif (!in_array($info['release_state'], PEAR_Common::getReleaseStates())) {
         $errors[] = "invalid release state `{$info['release_state']}', should be one of: " . implode(' ', PEAR_Common::getReleaseStates());
     }
     if (empty($info['release_date'])) {
         $errors[] = 'missing release date';
     } elseif (!preg_match('/^\\d{4}-\\d\\d-\\d\\d$/', $info['release_date'])) {
         $errors[] = "invalid release date `{$info['release_date']}', format is YYYY-MM-DD";
     }
     if (empty($info['release_notes'])) {
         $errors[] = "missing release notes";
     }
     if (empty($info['maintainers'])) {
         $errors[] = 'no maintainer(s)';
     } else {
         $i = 1;
         foreach ($info['maintainers'] as $m) {
             if (empty($m['handle'])) {
                 $errors[] = "maintainer {$i}: missing handle";
             }
             if (empty($m['role'])) {
                 $errors[] = "maintainer {$i}: missing role";
             } elseif (!in_array($m['role'], PEAR_Common::getUserRoles())) {
                 $errors[] = "maintainer {$i}: invalid role `{$m['role']}', should be one of: " . implode(' ', PEAR_Common::getUserRoles());
             }
             if (empty($m['name'])) {
                 $errors[] = "maintainer {$i}: missing name";
             }
             if (empty($m['email'])) {
                 $errors[] = "maintainer {$i}: missing email";
             }
             $i++;
         }
     }
     if (!empty($info['deps'])) {
         $i = 1;
         foreach ($info['deps'] as $d) {
             if (empty($d['type'])) {
                 $errors[] = "dependency {$i}: missing type";
             } elseif (!in_array($d['type'], PEAR_Common::getDependencyTypes())) {
                 $errors[] = "dependency {$i}: invalid type, should be one of: " . implode(' ', PEAR_Common::getDependencyTypes());
             }
             if (empty($d['rel'])) {
                 $errors[] = "dependency {$i}: missing relation";
             } elseif (!in_array($d['rel'], PEAR_Common::getDependencyRelations())) {
                 $errors[] = "dependency {$i}: invalid relation, should be one of: " . implode(' ', PEAR_Common::getDependencyRelations());
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $errors[] = "dependency {$i}: invalid relation optional attribute, should be one of: yes no";
                 }
             }
             if ($d['rel'] != 'has' && empty($d['version'])) {
                 $warnings[] = "dependency {$i}: missing version";
             } elseif ($d['rel'] == 'has' && !empty($d['version'])) {
                 $warnings[] = "dependency {$i}: version ignored for `has' dependencies";
             }
             if ($d['type'] == 'php' && !empty($d['name'])) {
                 $warnings[] = "dependency {$i}: name ignored for php type dependencies";
             } elseif ($d['type'] != 'php' && empty($d['name'])) {
                 $errors[] = "dependency {$i}: missing name";
             }
             $i++;
         }
     }
     if (!empty($info['configure_options'])) {
         $i = 1;
         foreach ($info['configure_options'] as $c) {
             if (empty($c['name'])) {
                 $errors[] = "configure option {$i}: missing name";
             }
             if (empty($c['prompt'])) {
                 $errors[] = "configure option {$i}: missing prompt";
             }
             $i++;
         }
     }
     if (empty($info['filelist'])) {
         $errors[] = 'no files';
     } else {
         foreach ($info['filelist'] as $file => $fa) {
             if (empty($fa['role'])) {
                 $errors[] = "file {$file}: missing role";
                 continue;
             } elseif (!in_array($fa['role'], PEAR_Common::getFileRoles())) {
                 $errors[] = "file {$file}: invalid role, should be one of: " . implode(' ', PEAR_Common::getFileRoles());
             }
             if ($fa['role'] == 'php' && $dir_prefix) {
                 $this->log(1, "Analyzing {$file}");
                 $srcinfo = $this->analyzeSourceCode($dir_prefix . DIRECTORY_SEPARATOR . $file);
                 if ($srcinfo) {
                     $this->buildProvidesArray($srcinfo);
                 }
             }
             // (ssb) Any checks we can do for baseinstalldir?
             // (cox) Perhaps checks that either the target dir and
             //       baseInstall doesn't cointain "../../"
         }
     }
     $this->_packageName = $pn = $info['package'];
     $pnl = strlen($pn);
     foreach ((array) $this->pkginfo['provides'] as $key => $what) {
         if (isset($what['explicit'])) {
             // 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;
             }
             $warnings[] = "in {$file}: class \"{$name}\" not prefixed with package name \"{$pn}\"";
         } elseif ($type == 'function') {
             if (strstr($name, '::') || !strncasecmp($name, $pn, $pnl)) {
                 continue;
             }
             $warnings[] = "in {$file}: function \"{$name}\" not prefixed with package name \"{$pn}\"";
         }
     }
     return true;
 }