cvs: php-src /pear/PEAR Common.php

From: Date: Mon, 26 Jan 2004 00:49:17 +0000
Subject: cvs: php-src /pear/PEAR Common.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-74@lists.php.net to get a copy of this message
pajoye Sun Jan 25 19:49:17 2004 EDT Modified files: /php-src/pear/PEAR Common.php Log: - Fix #521, incorrect filename in CS warnings http://cvs.php.net/diff.php/php-src/pear/PEAR/Common.php?r1=1.117&r2=1.118&ty=u Index: php-src/pear/PEAR/Common.php diff -u php-src/pear/PEAR/Common.php:1.117 php-src/pear/PEAR/Common.php:1.118 --- php-src/pear/PEAR/Common.php:1.117 Sat Jan 17 12:19:45 2004 +++ php-src/pear/PEAR/Common.php Sun Jan 25 19:49:16 2004 @@ -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 | @@ -17,7 +17,7 @@ // | Tomas V.V.Cox <cox@idecnet.com> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.117 2004/01/17 17:19:45 cellog Exp $ +// $Id: Common.php,v 1.118 2004/01/26 00:49:16 pajoye Exp $ require_once 'PEAR.php'; require_once 'Archive/Tar.php'; @@ -148,6 +148,12 @@ * @access private */ var $_packageSortTree; + /** + * Temporary variable used to store the current package name + * @var string + * @access private + */ + var $_validPackageName; // }}} @@ -1052,6 +1058,7 @@ if (!is_array($info)) { return false; } + $errors = array(); $warnings = array(); if (!isset($info['package'])) { @@ -1059,6 +1066,8 @@ } 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 @@ $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 @@ } $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 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 @@ 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 @@ } } return array( + "source_file" => $file, "declared_classes" => $declared_classes, "declared_methods" => $declared_methods, "declared_functions" => $declared_functions,

« previous php.pear.core (#74) next »