apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: PEAR_Common

Source Location: /PEAR-1.3.5/PEAR/Common.php

Class Overview

PEAR
   |
   --PEAR_Common

Class providing common functionality for PEAR administration classes.


Author(s):

Variables

Methods


Child classes:

PEAR_Downloader
Administration class used to download PEAR packages and maintain the installed package database.
PEAR_Builder
Class to handle building (compiling) extensions.
PEAR_Packager
Administration class used to make a PEAR release tarball.

Inherited Variables

Inherited Methods

Class: PEAR

PEAR::PEAR()
Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.
PEAR::delExpect()
This method deletes all occurences of the specified element from the expected error codes stack.
PEAR::expectError()
This method is used to tell which errors you expect to get.
PEAR::getStaticProperty()
If you have a class that's mostly/entirely static, and you need static
PEAR::isError()
Tell whether a value is a PEAR error.
PEAR::loadExtension()
OS independant PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.
PEAR::popErrorHandling()
Pop the last error handler used
PEAR::popExpect()
This method pops one element off the expected error codes stack.
PEAR::pushErrorHandling()
Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.
PEAR::raiseError()
This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.
PEAR::registerShutdownFunc()
Use this function to register a shutdown method for static classes.
PEAR::setErrorHandling()
Sets how errors generated by this object should be handled.
PEAR::staticPopErrorHandling()
PEAR::staticPushErrorHandling()
PEAR::throwError()
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
PEAR::_PEAR()
Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

Class Details

[line 105]
Class providing common functionality for PEAR administration classes.
  • Author: Stig Bakken <ssb@php.net>
  • Deprecated: This class will disappear, and its components will be spread into smaller classes, like the AT&T breakup


[ Top ]


Class Variables

$config =  null

[line 132]

Configuration object (PEAR_Config).

Type:   object


[ Top ]

$current_attributes = array()

[line 116]

array of attributes of the currently parsed XML element

Type:   mixed


[ Top ]

$current_element =

[line 113]

name of currently parsed XML element

Type:   mixed


[ Top ]

$current_path =  null

[line 134]


Type:   mixed


[ Top ]

$element_stack = array()

[line 110]

stack of elements, gives some sort of XML context

Type:   mixed


[ Top ]

$pkginfo = array()

[line 119]

assoc with information about a package

Type:   mixed


[ Top ]

$source_analyzer =  null

[line 140]

PEAR_SourceAnalyzer instance

Type:   object


[ Top ]

$ui =  null

[line 126]

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

Type:   object


[ Top ]



Method Detail

PEAR_Common (Constructor)   [line 157]

PEAR_Common PEAR_Common( )

PEAR_Common constructor
  • Access: public

[ Top ]

addTempFile   [line 200]

void addTempFile( string $file)

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

Parameters:

string   $file   —  name of file or directory

[ Top ]

analyzeSourceCode   [line 1300]

mixed analyzeSourceCode( string $file)

Analyze the source code of the given PHP file
  • Access: public

Parameters:

string   $file   —  Filename of the PHP file

[ Top ]

betterStates   [line 1497]

false|array betterStates( string $state, [boolean $include = false])

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

Parameters:

string   $state   —  Release state
boolean   $include   —  Determines whether to include $state in the list

[ Top ]

buildProvidesArray   [line 1244]

void buildProvidesArray( array $srcinfo)

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

Parameters:

array   $srcinfo   —  array with information about a source file as returned by the analyzeSourceCode() method.

[ Top ]

detectDependencies   [line 1513]

void detectDependencies( $any, [ $status_callback = null])


Parameters:

   $any   — 
   $status_callback   — 

[ Top ]

downloadHttp   [line 1742]

string downloadHttp( string $url, &$ui, [string $save_dir = '.'], [mixed $callback = null], object $ui, object $config)

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

Parameters:

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
   &$ui   — 

[ Top ]

getDependencyRelations   [line 1597]

array getDependencyRelations( )

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

[ Top ]

getDependencyTypes   [line 1583]

array getDependencyTypes( )

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

[ Top ]

getFileRoles   [line 1611]

array getFileRoles( )

Get the implemented file roles

[ Top ]

getProvideTypes   [line 1639]

array getProvideTypes( )

Get the implemented file replacement types in

[ Top ]

getReleaseStates   [line 1569]

array getReleaseStates( )

Get the valid package release states of packages

[ Top ]

getReplacementTypes   [line 1625]

array getReplacementTypes( )

Get the implemented file replacement types in

[ Top ]

getScriptPhases   [line 1653]

array getScriptPhases( )

Get the implemented file replacement types in

[ Top ]

getUserRoles   [line 1555]

array getUserRoles( )

Get the valid roles for a PEAR package maintainer

[ Top ]

infoFromAny   [line 836]

string infoFromAny( string $info)

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

Parameters:

string   $info   —  Filename of the source ('package.xml', '<package>.tgz')

[ Top ]

infoFromDescriptionFile   [line 748]

array infoFromDescriptionFile( string $descfile)

Returns information about a package file. Expects the name of a package xml file as input.
  • Return: array with package information
  • Access: public

Parameters:

string   $descfile   —  name of package xml file

[ Top ]

infoFromString   [line 775]

array infoFromString( string $data)

Returns information about a package file. Expects the contents of a package xml file as input.
  • Return: array with package information
  • Access: public

Parameters:

string   $data   —  name of package xml file

[ Top ]

infoFromTgzFile   [line 697]

array infoFromTgzFile( string $file)

Returns information about a package file. Expects the name of a gzipped tar file as input.
  • Return: array with package information
  • Access: public

Parameters:

string   $file   —  name of .tgz file

[ Top ]

log   [line 237]

void log( int $level, string $msg, [ $append_crlf = true])

Logging method.
  • Access: public

Overridden in child classes as:

PEAR_Builder::log()

Parameters:

int   $level   —  log level (0 is quiet, higher is noisier)
string   $msg   —  message to write to the log
   $append_crlf   — 

[ Top ]

mkDirHier   [line 218]

bool mkDirHier( string $dir)

Wrapper to System::mkDir(), creates a directory as well as any necessary parent directories.
  • Return: TRUE on success, or a PEAR error
  • Access: public

Overridden in child classes as:

PEAR_Installer::mkDirHier()

Parameters:

string   $dir   —  directory name

[ Top ]

mkTempDir   [line 262]

string mkTempDir( [string $tmpdir = ''])

Create and register a temporary directory.
  • Return: name of created directory
  • Access: public

Parameters:

string   $tmpdir   —  (optional) Directory to use as tmpdir. Will use system defaults (for example /tmp or c:\windows\temp) if not specified

[ Top ]

setFrontendObject   [line 287]

void setFrontendObject( object Reference &$ui)

Set object that represents the frontend to be used.
  • Access: public

Parameters:

object Reference   &$ui   —  of the frontend object

[ Top ]

sortPkgDeps   [line 1872]

array sortPkgDeps( array &$packages, [boolean $uninstall = false])

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

It also removes duplicate dependencies

  • Return: array of array(packagefilename, package.xml contents)

Parameters:

array   &$packages   — 
boolean   $uninstall   —  Sort packages in reverse order if true

[ Top ]

validatePackageInfo   [line 1043]

boolean validatePackageInfo( string $info, &$errors, &$warnings, [string $dir_prefix = ''], array $errors, array $warnings)

Validate XML package definition file.
  • Access: public

Parameters:

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
   &$errors   — 
   &$warnings   — 

[ Top ]

validPackageName   [line 1670]

bool validPackageName( string $name)

Test whether a string contains a valid package name.
  • Access: public

Parameters:

string   $name   —  the package name to test

[ Top ]

validPackageVersion   [line 1688]

bool validPackageVersion( string $ver)

Test whether a string contains a valid package version.
  • Access: public

Parameters:

string   $ver   —  the package version to test

[ Top ]

xmlFromInfo   [line 874]

string xmlFromInfo( array $pkginfo)

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

Parameters:

array   $pkginfo   —  package info

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:23:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.