Skip to content

Commit

Permalink
- Fix php#521, incorrect filename in CS warnings
Browse files Browse the repository at this point in the history
pierrejoye committed Jan 26, 2004
1 parent b240239 commit 477de56
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions pear/PEAR/Common.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 5 |
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// | Copyright (c) 1997-2003 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 |
@@ -148,6 +148,12 @@ class PEAR_Common extends PEAR
* @access private
*/
var $_packageSortTree;
/**
* Temporary variable used to store the current package name
* @var string
* @access private
*/
var $_validPackageName;

// }}}

@@ -1052,13 +1058,16 @@ function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
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) {
@@ -1175,12 +1184,13 @@ function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
$this->buildProvidesArray($srcinfo);
}
}

// (ssb) Any checks we can do for baseinstalldir?
// (cox) Perhaps checks that either the target dir and
// baseInstall doesn't cointain "../../"
}
}
$pn = $info['package'];
$this->_packageName = $pn = $info['package'];
$pnl = strlen($pn);
foreach ((array)$this->pkginfo['provides'] as $key => $what) {
if (isset($what['explicit'])) {
@@ -1200,8 +1210,9 @@ function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
}
$warnings[] = "in $file: function \"$name\" not prefixed with package name \"$pn\"";
}
//print "$file: provides $what[type] $what[name]\n";
}


return true;
}

@@ -1229,13 +1240,16 @@ function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
*/
function buildProvidesArray($srcinfo)
{
$file = basename($srcinfo['source_file']);
$pn = $this->_packageName;
$pnl = strlen($pn);
foreach ($srcinfo['declared_classes'] as $class) {
$key = "class;$class";
if (isset($this->pkginfo['provides'][$key])) {
continue;
}
$this->pkginfo['provides'][$key] =
array('type' => 'class', 'name' => $class);
array('file'=> $file, 'type' => 'class', 'name' => $class);
if (isset($srcinfo['inheritance'][$class])) {
$this->pkginfo['provides'][$key]['extends'] =
$srcinfo['inheritance'][$class];
@@ -1250,16 +1264,20 @@ function buildProvidesArray($srcinfo)
continue;
}
$this->pkginfo['provides'][$key] =
array('type' => 'function', 'name' => $function);
array('file'=> $file, 'type' => 'function', 'name' => $function);
}
}

foreach ($srcinfo['declared_functions'] as $function) {
$key = "function;$function";
if ($function{0} == '_' || isset($this->pkginfo['provides'][$key])) {
continue;
}
if (!strstr($function, '::') && strncasecmp($function, $pn, $pnl)) {
$warnings[] = "in1 " . $file . ": function \"$function\" not prefixed with package name \"$pn\"";
}
$this->pkginfo['provides'][$key] =
array('type' => 'function', 'name' => $function);
array('file'=> $file, 'type' => 'function', 'name' => $function);
}
}

@@ -1405,6 +1423,7 @@ function analyzeSourceCode($file)
}
}
return array(
"source_file" => $file,
"declared_classes" => $declared_classes,
"declared_methods" => $declared_methods,
"declared_functions" => $declared_functions,

0 comments on commit 477de56

Please sign in to comment.