cvs: pear-core(PEAR_1_3) /PEAR Common.php
| From: | Greg Beaver | Date: | Tue, 19 Oct 2004 04:20:58 +0000 |
| Subject: | cvs: pear-core(PEAR_1_3) /PEAR Common.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-1066@lists.php.net to get a copy of this message | ||
cellog Tue Oct 19 00:20:58 2004 EDT
Modified files: (Branch: PEAR_1_3)
/pear-core/PEAR Common.php
Log:
MFH php5 fixes to php analysis
http://cvs.php.net/diff.php/pear-core/PEAR/Common.php?r1=1.126&r2=1.126.2.1&ty=u
Index: pear-core/PEAR/Common.php
diff -u pear-core/PEAR/Common.php:1.126 pear-core/PEAR/Common.php:1.126.2.1
--- pear-core/PEAR/Common.php:1.126 Sat Jun 12 02:15:55 2004
+++ pear-core/PEAR/Common.php Tue Oct 19 00:20:58 2004
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.126 2004/06/12 06:15:55 cellog Exp $
+// $Id: Common.php,v 1.126.2.1 2004/10/19 04:20:58 cellog Exp $
require_once 'PEAR.php';
require_once 'Archive/Tar.php';
@@ -34,7 +34,7 @@
define('PEAR_COMMON_PACKAGE_NAME_PREG', '/^' . _PEAR_COMMON_PACKAGE_NAME_PREG .
'$/');
// this should allow: 1, 1.0, 1.0RC1, 1.0dev, 1.0dev123234234234, 1.0a1, 1.0b1, 1.0pl1
-define('_PEAR_COMMON_PACKAGE_VERSION_PREG', '\d+(?:\.\d+)*(?:[a-z]+\d*)?');
+define('_PEAR_COMMON_PACKAGE_VERSION_PREG', '\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?');
define('PEAR_COMMON_PACKAGE_VERSION_PREG', '/^' .
_PEAR_COMMON_PACKAGE_VERSION_PREG . '$/i');
// XXX far from perfect :-)
@@ -98,7 +98,9 @@
// }}}
/**
- * Class providing common functionality for PEAR adminsitration classes.
+ * Class providing common functionality for PEAR administration classes.
+ * @deprecated This class will disappear, and its components will be spread
+ * into smaller classes, like the AT&T breakup
*/
class PEAR_Common extends PEAR
{
@@ -142,12 +144,6 @@
* @access private
*/
var $_validPackageFile;
- /**
- * Temporary variable used in sorting packages by dependency in {@link sortPkgDeps()}
- * @var array
- * @access private
- */
- var $_packageSortTree;
// }}}
@@ -1293,6 +1289,15 @@
if (!function_exists("token_get_all")) {
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 (!$fp = @fopen($file, "r")) {
return false;
}
@@ -1315,17 +1320,21 @@
$brace_level = 0;
$lastphpdoc = '';
$current_class = '';
+ $current_interface = '';
$current_class_level = -1;
$current_function = '';
$current_function_level = -1;
$declared_classes = array();
+ $declared_interfaces = array();
$declared_functions = array();
$declared_methods = array();
$used_classes = array();
$used_functions = array();
$extends = array();
+ $implements = array();
$nodeps = array();
$inquote = false;
+ $interface = false;
for ($i = 0; $i < sizeof($tokens); $i++) {
if (is_array($tokens[$i])) {
list($token, $data) = $tokens[$i];
@@ -1341,6 +1350,14 @@
}
}
switch ($token) {
+ case T_WHITESPACE:
+ continue;
+ case ';':
+ if ($interface) {
+ $current_function = '';
+ $current_function_level = -1;
+ }
+ break;
case '"':
$inquote = true;
break;
@@ -1362,6 +1379,8 @@
case ']': $bracket_level--; continue 2;
case '(': $paren_level++; continue 2;
case ')': $paren_level--; continue 2;
+ case T_INTERFACE:
+ $interface = true;
case T_CLASS:
if (($current_class_level != -1) || ($current_function_level != -1)) {
PEAR::raiseError("Parser error: Invalid PHP file $file",
@@ -1371,19 +1390,38 @@
case T_FUNCTION:
case T_NEW:
case T_EXTENDS:
+ case T_IMPLEMENTS:
$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', 'clone',
'throw')
+ )) {
+ PEAR::raiseError('Error: PHP5 packages must be packaged by php 5
PEAR');
+ return false;
+ }
+ }
if ($look_for == T_CLASS) {
$current_class = $data;
$current_class_level = $brace_level;
$declared_classes[] = $current_class;
+ } elseif ($look_for == T_INTERFACE) {
+ $current_interface = $data;
+ $current_class_level = $brace_level;
+ $declared_interfaces[] = $current_interface;
+ } elseif ($look_for == T_IMPLEMENTS) {
+ $implements[$current_class] = $data;
} elseif ($look_for == T_EXTENDS) {
$extends[$current_class] = $data;
} elseif ($look_for == T_FUNCTION) {
if ($current_class) {
$current_function = "$current_class::$data";
$declared_methods[$current_class][] = $data;
+ } elseif ($current_interface) {
+ $current_function = "$current_interface::$data";
+ $declared_methods[$current_interface][] = $data;
} else {
$current_function = $data;
$declared_functions[] = $current_function;
@@ -1398,6 +1436,7 @@
case T_VARIABLE:
$look_for = 0;
continue 2;
+ case T_DOC_COMMENT:
case T_COMMENT:
if (preg_match('!^/\*\*\s!', $data)) {
$lastphpdoc = $data;
@@ -1422,10 +1461,12 @@
return array(
"source_file" => $file,
"declared_classes" => $declared_classes,
+ "declared_interfaces" => $declared_interfaces,
"declared_methods" => $declared_methods,
"declared_functions" => $declared_functions,
"used_classes" => array_diff(array_keys($used_classes), $nodeps),
"inheritance" => $extends,
+ "implements" => $implements,
);
}