Class PEAR_Common

Description

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

Located in /maintenance/libraries/pear/PEAR/Common.php (line 105)

PEAR
   |
   --PEAR_Common
Direct descendents
Class Description
 class PEAR_Packager Administration class used to make a PEAR release tarball.
 class PEAR_Downloader Administration class used to download PEAR packages and maintain the installed package database.
 class PEAR_Builder Class to handle building (compiling) extensions.
Variable Summary
Method Summary
 PEAR_Common PEAR_Common ()
 void addTempFile (string $file)
 mixed analyzeSourceCode (string $file)
 false|array betterStates (string $state, [boolean $include = false])
 void buildProvidesArray (array $srcinfo)
 void detectDependencies (mixed $any, [mixed $status_callback = null])
 string downloadHttp (string $url, object &$ui, [string $save_dir = '.'], [mixed $callback = null], object $config)
 array getFileRoles ()
 array getProvideTypes ()
 array getReleaseStates ()
 array getScriptPhases ()
 array getUserRoles ()
 string infoFromAny (string $info)
 array infoFromDescriptionFile (string $descfile)
 array infoFromString (string $data)
 array infoFromTgzFile (string $file)
 void log (int $level, string $msg, [mixed $append_crlf = true])
 bool mkDirHier (string $dir)
 string mkTempDir ([string $tmpdir = ''])
 void setFrontendObject (object Reference &$ui)
 array sortPkgDeps (array &$packages, [boolean $uninstall = false])
 boolean validatePackageInfo (string $info, array &$errors, array &$warnings, [string $dir_prefix = ''])
 bool validPackageName (string $name)
 bool validPackageVersion (string $ver)
 string xmlFromInfo (array $pkginfo)
 void _element_end (resource $xp, string $name)
 void _element_end_1_0 (resource $xp, string $name)
 void _element_start (resource $xp, string $name, array $attribs)
 void _element_start_1_0 (resource $xp, string $name, mixed $attribs)
 array _getPkgDeps (array $p)
 array _getPkgDepTree (mixed $packages)
 array _getRevPkgDeps (array $p)
 string _makeReleaseXml (array $pkginfo, [bool $changelog = false])
 void _PEAR_Common ()
 void _pkginfo_cdata_1_0 (resource $xp, mixed $data, string $name)
 bool _removedDependency (string $p1, string $p2)
 void _sortPkgDeps (mixed $p1, mixed $p2)
 void _sortPkgDepsRev (mixed $p1, mixed $p2)
 string _unIndent (string $str)
Variables
object $config = null (line 132)

Configuration object (PEAR_Config).

mixed $current_attributes = array() (line 116)

array of attributes of the currently parsed XML element

mixed $current_element (line 113)

name of currently parsed XML element

mixed $current_path = null (line 134)
mixed $element_stack = array() (line 110)

stack of elements, gives some sort of XML context

mixed $pkginfo = array() (line 119)

assoc with information about a package

object $source_analyzer = null (line 140)

PEAR_SourceAnalyzer instance

object $ui = null (line 126)

User Interface object (PEAR_Frontend_* class). If null, the log() method uses print.

boolean $_validPackageFile (line 146)

Flag variable used to mark a valid package file

  • access: private
Methods
Constructor PEAR_Common (line 157)

PEAR_Common constructor

  • access: public
PEAR_Common PEAR_Common ()
addTempFile (line 200)

Register a temporary file or directory. When the destructor is executed, all registered temporary files and directories are removed.

  • access: public
void addTempFile (string $file)
  • string $file: name of file or directory
analyzeSourceCode (line 1284)

Analyze the source code of the given PHP file

  • access: public
mixed analyzeSourceCode (string $file)
  • string $file: Filename of the PHP file
betterStates (line 1481)

Return an array containing all of the states that are more stable than or equal to the passed in state

  • return: False if $state is not a valid release state
false|array betterStates (string $state, [boolean $include = false])
  • string $state: Release state
  • boolean $include: Determines whether to include $state in the list
buildProvidesArray (line 1228)

Build a "provides" array from data returned by analyzeSourceCode(). The format of the built array is like this:

array( 'class;MyClass' => 'array('type' => 'class', 'name' => 'MyClass'), ... )

  • access: public
void buildProvidesArray (array $srcinfo)
  • array $srcinfo: array with information about a source file as returned by the analyzeSourceCode() method.
detectDependencies (line 1497)
void detectDependencies (mixed $any, [mixed $status_callback = null])
downloadHttp (line 1726)

Download a file through HTTP. Considers suggested file name in

Content-disposition: header and can run a callback function for different events. The callback will be called with two parameters: the callback type, and parameters. The implemented callback types are:

'setup' called at the very beginning, parameter is a UI object that should be used for all output 'message' the parameter is a string with an informational message 'saveas' may be used to save with a different file name, the parameter is the filename that is about to be used. If a 'saveas' callback returns a non-empty string, that file name will be used as the filename instead. Note that $save_dir will not be affected by this, only the basename of the file. 'start' download is starting, parameter is number of bytes that are expected, or -1 if unknown 'bytesread' parameter is the number of bytes read so far 'done' download is complete, parameter is the total number of bytes read 'connfailed' if the TCP connection fails, this callback is called with array(host,port,errno,errmsg) 'writefailed' if writing to disk fails, this callback is called with array(destfile,errmsg)

If an HTTP proxy has been configured (http_proxy PEAR_Config setting), the proxy will be used.

  • return: Returns the full path of the downloaded file or a PEAR error on failure. If the error is caused by socket-related errors, the error object will have the fsockopen error code available through getCode().
  • access: public
string downloadHttp (string $url, object &$ui, [string $save_dir = '.'], [mixed $callback = null], object $config)
  • string $url: the URL to download
  • object $ui: PEAR_Frontend_* instance
  • object $config: PEAR_Config instance
  • string $save_dir: (optional) directory to save file in
  • mixed $callback: (optional) function/method to call for status updates
getDependencyRelations (line 1581)

Get the implemented dependency relations (has, lt, ge etc.)

  • static:
array getDependencyRelations ()
getDependencyTypes (line 1567)

Get the implemented dependency types (php, ext, pkg etc.)

  • static:
array getDependencyTypes ()
getFileRoles (line 1595)

Get the implemented file roles

  • static:
array getFileRoles ()
getProvideTypes (line 1623)

Get the implemented file replacement types in

  • static:
array getProvideTypes ()
getReleaseStates (line 1553)

Get the valid package release states of packages

  • static:
array getReleaseStates ()
getReplacementTypes (line 1609)

Get the implemented file replacement types in

  • static:
array getReplacementTypes ()
getScriptPhases (line 1637)

Get the implemented file replacement types in

  • static:
array getScriptPhases ()
getUserRoles (line 1539)

Get the valid roles for a PEAR package maintainer

  • static:
array getUserRoles ()
infoFromAny (line 836)

Returns package information from different sources

This method is able to extract information about a package from a .tgz archive or from a XML package definition file.

  • access: public
string infoFromAny (string $info)
  • string $info: Filename of the source ('package.xml', '<package>.tgz')
infoFromDescriptionFile (line 748)

Returns information about a package file. Expects the name of a package xml file as input.

  • return: array with package information
  • access: public
array infoFromDescriptionFile (string $descfile)
  • string $descfile: name of package xml file
infoFromString (line 775)

Returns information about a package file. Expects the contents of a package xml file as input.

  • return: array with package information
  • access: public
array infoFromString (string $data)
  • string $data: name of package xml file
infoFromTgzFile (line 697)

Returns information about a package file. Expects the name of a gzipped tar file as input.

  • return: array with package information
  • access: public
array infoFromTgzFile (string $file)
  • string $file: name of .tgz file
log (line 237)

Logging method.

  • access: public
void log (int $level, string $msg, [mixed $append_crlf = true])
  • int $level: log level (0 is quiet, higher is noisier)
  • string $msg: message to write to the log

Redefined in descendants as:
mkDirHier (line 218)

Wrapper to System::mkDir(), creates a directory as well as any necessary parent directories.

  • return: TRUE on success, or a PEAR error
  • access: public
bool mkDirHier (string $dir)
  • string $dir: directory name

Redefined in descendants as:
mkTempDir (line 262)

Create and register a temporary directory.

  • return: name of created directory
  • access: public
string mkTempDir ([string $tmpdir = ''])
  • string $tmpdir: (optional) Directory to use as tmpdir. Will use system defaults (for example /tmp or c:\windows\temp) if not specified
setFrontendObject (line 287)

Set object that represents the frontend to be used.

  • access: public
void setFrontendObject (object Reference &$ui)
  • object Reference &$ui: of the frontend object
sortPkgDeps (line 1856)

Sort a list of arrays of array(downloaded packagefilename) by dependency.

It also removes duplicate dependencies

  • return: array of array(packagefilename, package.xml contents)
array sortPkgDeps (array &$packages, [boolean $uninstall = false])
  • array &$packages
  • boolean $uninstall: Sort packages in reverse order if true
validatePackageInfo (line 1040)

Validate XML package definition file.

  • access: public
boolean validatePackageInfo (string $info, array &$errors, array &$warnings, [string $dir_prefix = ''])
  • string $info: Filename of the package archive or of the package definition file
  • array $errors: Array that will contain the errors
  • array $warnings: Array that will contain the warnings
  • string $dir_prefix: (optional) directory where source files may be found, or empty if they are not available
validPackageName (line 1654)

Test whether a string contains a valid package name.

  • access: public
bool validPackageName (string $name)
  • string $name: the package name to test
validPackageVersion (line 1672)

Test whether a string contains a valid package version.

  • access: public
bool validPackageVersion (string $ver)
  • string $ver: the package version to test
xmlFromInfo (line 874)

Return an XML document based on the package info (as returned by the PEAR_Common::infoFrom* methods).

  • return: XML data
  • access: public
string xmlFromInfo (array $pkginfo)
  • array $pkginfo: package info
_element_end (line 380)

XML parser callback for ending elements. Used while package format version is not yet known.

  • access: private
void _element_end (resource $xp, string $name)
  • resource $xp: XML parser resource
  • string $name: name of ending element
_element_end_1_0 (line 527)

XML parser callback for ending elements. Used for version 1.0 packages.

  • access: private
void _element_end_1_0 (resource $xp, string $name)
  • resource $xp: XML parser resource
  • string $name: name of ending element
_element_start (line 335)

XML parser callback for starting elements. Used while package format version is not yet known.

  • access: private
void _element_start (resource $xp, string $name, array $attribs)
  • resource $xp: XML parser resource
  • string $name: name of starting element
  • array $attribs: element attributes, name => value
_element_start_1_0 (line 400)

XML parser callback for ending elements. Used for version 1.0 packages.

  • access: private
void _element_start_1_0 (resource $xp, string $name, mixed $attribs)
  • resource $xp: XML parser resource
  • string $name: name of ending element
_getPkgDeps (line 1989)

get an array of package dependency names

  • access: private
array _getPkgDeps (array $p)
  • array $p
_getPkgDepTree (line 2015)

get an array representation of the package dependency tree

  • access: private
array _getPkgDepTree (mixed $packages)
_getRevPkgDeps (line 2061)

get an array of package dependency names for uninstall

  • access: private
array _getRevPkgDeps (array $p)
  • array $p
_makeReleaseXml (line 922)

Generate part of an XML description with release information.

  • return: XML data
  • access: private
string _makeReleaseXml (array $pkginfo, [bool $changelog = false])
  • array $pkginfo: array with release information
  • bool $changelog: whether the result will be in a changelog element
_PEAR_Common (line 172)

PEAR_Common destructor

  • access: private
void _PEAR_Common ()
_pkginfo_cdata_1_0 (line 675)

XML parser callback for character data. Used for version 1.0 packages.

  • access: private
void _pkginfo_cdata_1_0 (resource $xp, mixed $data, string $name)
  • resource $xp: XML parser resource
  • string $name: character data
_removedDependency (line 2036)

get an array of package dependency names for uninstall

  • access: private
bool _removedDependency (string $p1, string $p2)
  • string $p1: package 1 name
  • string $p2: package 2 name
_sortPkgDeps (line 1903)

Compare two package's package.xml, and sort so that dependencies are installed first

This is a crude compare, real dependency checking is done on install. The only purpose this serves is to make the command-line order-independent (you can list a dependent package first, and installation occurs in the order required)

  • access: private
void _sortPkgDeps (mixed $p1, mixed $p2)
_sortPkgDepsRev (line 1948)

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
void _sortPkgDepsRev (mixed $p1, mixed $p2)
_unIndent (line 303)

Unindent given string (?)

  • access: private
string _unIndent (string $str)
  • string $str: The string that has to be unindented.

Documentation generated on Fri, 24 Dec 2004 13:01:43 +0000 by phpDocumentor 1.3.0RC3