Inheritance information in package.xml

From: Date: Tue, 29 Apr 2003 11:50:20 +0000
Subject: Inheritance information in package.xml
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15700@lists.php.net to get a copy of this message
Hello, attached is a patch that adds functionality to add inheritance information into the provides section of the package.xml file if you do "pear package". Please comment on this, by approval I will commit. Derick -- "my other box is your windows PC" ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------

Index: package.dtd =================================================================== RCS file: /repository/php4/pear/package.dtd,v retrieving revision 1.30 diff -u -r1.30 package.dtd --- package.dtd 18 Mar 2003 12:06:06 -0000 1.30 +++ package.dtd 29 Apr 2003 11:47:04 -0000 @@ -90,7 +90,8 @@ <!ELEMENT provides (#PCDATA)> <!ATTLIST provides type (ext|prog|class|function|feature|api) #REQUIRED - name CDATA #REQUIRED> + name CDATA #REQUIRED + extends CDATA #IMPLIED> <!ELEMENT script (#PCDATA)> <!ATTLIST script Index: PEAR/Common.php =================================================================== RCS file: /repository/php4/pear/PEAR/Common.php,v retrieving revision 1.90 diff -u -r1.90 Common.php --- PEAR/Common.php 3 Apr 2003 23:04:52 -0000 1.90 +++ PEAR/Common.php 29 Apr 2003 11:47:04 -0000 @@ -935,7 +935,11 @@ if (isset($pkginfo['provides'])) { foreach ($pkginfo['provides'] as $key => $what) { $ret .= "$indent <provides type=\"$what[type]\" "; - $ret .= "name=\"$what[name]\" />\n"; + $ret .= "name=\"$what[name]\" "; + if (isset($what['extends'])) { + $ret .= "extends=\"$what[extends]\" "; + } + $ret .= "/>\n"; } } if (isset($pkginfo['filelist'])) { @@ -1175,6 +1179,10 @@ } $this->pkginfo['provides'][$key] = array('type' => 'class', 'name' => $class); + if (isset($srcinfo['inheritance'][$class])) { + $this->pkginfo['provides'][$key]['extends'] = + $srcinfo['inheritance'][$class]; + } } foreach ($srcinfo['declared_methods'] as $class => $methods) { foreach ($methods as $method) { @@ -1243,6 +1251,7 @@ $declared_methods = array(); $used_classes = array(); $used_functions = array(); + $extends = array(); $nodeps = array(); for ($i = 0; $i < sizeof($tokens); $i++) { if (is_array($tokens[$i])) { @@ -1273,6 +1282,7 @@ case T_CLASS: case T_FUNCTION: case T_NEW: + case T_EXTENDS: $look_for = $token; continue 2; case T_STRING: @@ -1280,6 +1290,11 @@ $current_class = $data; $current_class_level = $brace_level; $declared_classes[] = $current_class; + if (!isset($extends[$current_class])) { + $extends[$current_class] = array(); + } + } elseif ($look_for == T_EXTENDS) { + $extends[$current_class] = $data; } elseif ($look_for == T_FUNCTION) { if ($current_class) { $current_function = "$current_class::$data"; @@ -1319,6 +1334,7 @@ "declared_methods" => $declared_methods, "declared_functions" => $declared_functions, "used_classes" => array_diff(array_keys($used_classes), $nodeps), + "inheritance" => $extends, ); } @@ -1344,6 +1360,7 @@ $decl_c = @array_merge($decl_c, $tmp['declared_classes']); $decl_f = @array_merge($decl_f, $tmp['declared_functions']); $decl_m = @array_merge($decl_m, $tmp['declared_methods']); + $inheri = @array_merge($inheri, $tmp['inheritance']); } $used_c = array_unique($used_c); $decl_c = array_unique($decl_c); @@ -1353,6 +1370,7 @@ 'declared_methods' => $decl_m, 'declared_functions' => $decl_f, 'undeclared_classes' => $undecl_c, + 'inheritance' => $inheri, ); }
« previous php.pear.dev (#15700) next »