/** * Compare two package's package.xml, and sort * so that dependencies are uninstalled last * * This is a crude compare, real dependency checking is done on uninstall. * The only purpose this serves is to make the command-line * order-independent (you can list a dependency first, and * uninstallation occurs in the order required) * @access private */ function _sortPkgDepsRev($p1, $p2) { $p1name = $p1['info']['package']; $p2name = $p2['info']['package']; $p1deps = PEAR_Common::_getRevPkgDeps($p1); $p2deps = PEAR_Common::_getRevPkgDeps($p2); if (!count($p1deps) && !count($p2deps)) { return 0; // order makes no difference } if (!count($p1deps)) { return 1; // package 2 has dependencies, package 1 doesn't } if (!count($p2deps)) { return -1; // package 2 has dependencies, package 1 doesn't } // both have dependencies if (in_array($p1name, $p2deps)) { return 1; // put package 1 last } if (in_array($p2name, $p1deps)) { return -1; // put package 2 last } // doesn't really matter if neither depends on the other return 0; }