Documentation

Horde_Pear_Package_Xml
in package

Handles package.xml files.

Tags
author

Gunnar Wrobel wrobel@pardus.de

category

Horde

copyright

2011-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Table of Contents

XMLNAMESPACE  = 'http://pear.php.net/dtd/package-2.0'
The package.xml namespace
XMLTASKSNAMESPACE  = 'http://pear.php.net/dtd/tasks-1.0'
The package.xml tasks namespace
$_factory  : Horde_Pear_Package_Xml_Factory
The factory for required instances.
$_namespace_prefix  : string
The XPath namespace prefix (if necessary).
$_path  : string
The path to the XML file.
$_xml  : DOMDocument
The parsed XML.
$_xpath  : DOMXpath
The XPath query handler.
__call()  : mixed
Catch undefined method calls and try to run them as task.
__construct()  : mixed
Constructor.
__toString()  : string
Return the complete package.xml as string.
_insertWhiteSpace()  : DOMNode
Insert some white space.
addAuthor()  : mixed
Adds a new author to the package.xml
addDependency()  : mixed
Adds a new dependency to the package.xml
addNextVersion()  : mixed
Add the next version to the package.xml
addNote()  : mixed
Add a new note to the package.xml
addVersion()  : mixed
Adds a new version to the package.xml
append()  : mixed
createComment()  : mixed
createNode()  : mixed
createText()  : mixed
findNode()  : DOMNode|false
Return a single named node matching the given XPath query.
findNodeRelativeTo()  : DOMNode|false
Return a single named node below the given context matching the given XPath query.
findNodes()  : DOMNodeList
Return all nodes matching the given XPath query.
findNodesRelativeTo()  : DOMNodeList
Return all nodes matching the given XPath query.
getChannel()  : string
Return the package channel.
getContent()  : Horde_Pear_Package_Contents_List
Return the list of contents.
getDate()  : string
Return the release date.
getDependencies()  : array<string|int, mixed>
Return the package dependencies.
getDescription()  : string
Return the package description.
getLeads()  : string
Return the package lead developers.
getLicense()  : string
Return the license name.
getLicenseLocation()  : string
Return the URL to the license information.
getName()  : string
Return the package name.
getNodeText()  : string|false
Return the content of a single named node matching the given XPath query.
getNodeTextRelativeTo()  : string|false
Return the content of a single named node below the given context and matching the given XPath query.
getNotes()  : string
Return the package notes.
getState()  : string
Return the stability of the release or api.
getSummary()  : string
Return the package summary.
getVersion()  : string
Return the package version.
getVersions()  : array<string|int, mixed>
Returns all package versions from the changelog.
insert()  : mixed
removeComment()  : mixed
removeWhitespace()  : mixed
replaceTextNode()  : DOMNodeList
Replace a specific text node
replaceTextNodeRelativeTo()  : DOMNodeList
Replace a specific text node
setNotes()  : mixed
Sets notes in the package.xml
setState()  : null
Set the state in the package.xml
setVersion()  : null
Set the version in the package.xml
syncCurrentVersion()  : null
Synchronizes the current version information with the release information in the changelog.
timestamp()  : mixed
Mark the package as being release and set the timestamps to now.
updateContents()  :
_fetchCurrentRelease()  : DOMElement|null
Fetch the node holding the current release information in the changelog.
_fetchRelease()  : DOMElement|null
Fetch the node holding release information in the changelog.
_warnOnEmptyInfo()  : mixed
Write a warning to STDERR when missing the specified entries in the $info array.
_appendChild()  : DOMNode
Append a new child.
_appendLicense()  : null
Append license information.
_appendStability()  : null
Append stability information.
_appendVersion()  : null
Append version information.
_completeDependencies()  : null
Complete the dependency information.
_dependencyInputValue()  : null
Generate one element of the input data.
_findSingleNode()  : DOMNode|false
Return a single node for the result set.
_replacementNode()  : DOMNode
Generate a replacement node.
_requireCurrentRelease()  : DOMElement|null
Fetch the node holding the current release information in the changelog and fail if there is no such node.

Constants

XMLNAMESPACE

The package.xml namespace

public mixed XMLNAMESPACE = 'http://pear.php.net/dtd/package-2.0'

XMLTASKSNAMESPACE

The package.xml tasks namespace

public mixed XMLTASKSNAMESPACE = 'http://pear.php.net/dtd/tasks-1.0'

Properties

$_namespace_prefix

The XPath namespace prefix (if necessary).

private string $_namespace_prefix = ''

$_path

The path to the XML file.

private string $_path

$_xml

The parsed XML.

private DOMDocument $_xml

$_xpath

The XPath query handler.

private DOMXpath $_xpath

Methods

__call()

Catch undefined method calls and try to run them as task.

public __call(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string

The method/task name.

$arguments : array<string|int, mixed>

The arguments for the call.

Return values
mixed

__construct()

Constructor.

public __construct(resource|string $xml[, mixed $factory = null ]) : mixed
Parameters
$xml : resource|string

The package.xml as stream or path.

$factory : mixed = null
Return values
mixed

__toString()

Return the complete package.xml as string.

public __toString() : string
Return values
string

The package.xml content.

_insertWhiteSpace()

Insert some white space.

public _insertWhiteSpace(DOMNode $parent, string $ws) : DOMNode
Parameters
$parent : DOMNode

The parent DOMNode.

$ws : string

Additional white space that should be inserted.

Return values
DOMNode

The inserted white space node.

addAuthor()

Adds a new author to the package.xml

public addAuthor(string $name, string $user, string $email, bool $active, string $role) : mixed
Parameters
$name : string

A name.

$user : string

A user name.

$email : string

An email address.

$active : bool

Still active?

$role : string

An author role.

Return values
mixed

addDependency()

Adds a new dependency to the package.xml

public addDependency(string $required, string $type, mixed $constraints) : mixed
Parameters
$required : string

A dependency requirement, either 'required' or 'optional'.

$type : string

A dependency type, either 'package' or 'extension'.

$constraints : mixed
Return values
mixed

addNextVersion()

Add the next version to the package.xml

public addNextVersion(string $version, string $initial_note[, string $stability_api = null ][, string $stability_release = null ][, bool $keepTime = false ]) : mixed
Parameters
$version : string

The new version number.

$initial_note : string

The text for the initial note.

$stability_api : string = null

The API stability for the next release.

$stability_release : string = null

The stability for the next release.

$keepTime : bool = false

Keep the

Return values
mixed

addNote()

Add a new note to the package.xml

public addNote(string $note) : mixed
Parameters
$note : string

The note text.

Return values
mixed

addVersion()

Adds a new version to the package.xml

public addVersion(string $version, string $api, string $stability_release, string $stability_api, string $date, string $license, string $licenseLocation, string $notes) : mixed
Parameters
$version : string

The new version number.

$api : string

The new api number.

$stability_release : string

The stability for the next release.

$stability_api : string

The API stability for the next release.

$date : string

The release date.

$license : string

The license identifier.

$licenseLocation : string

The license URI.

$notes : string

The text for the release notes.

Return values
mixed

append()

public append(mixed $elements, mixed $parent) : mixed
Parameters
$elements : mixed
$parent : mixed
Return values
mixed

createComment()

public createComment(mixed $comment) : mixed
Parameters
$comment : mixed
Return values
mixed

createNode()

public createNode(mixed $name[, mixed $attributes = array() ][, mixed $ns = null ]) : mixed
Parameters
$name : mixed
$attributes : mixed = array()
$ns : mixed = null
Return values
mixed

createText()

public createText(mixed $text) : mixed
Parameters
$text : mixed
Return values
mixed

findNode()

Return a single named node matching the given XPath query.

public findNode(string $query) : DOMNode|false
Parameters
$query : string

The query.

Return values
DOMNode|false

The named DOMNode or empty if no node was found.

findNodeRelativeTo()

Return a single named node below the given context matching the given XPath query.

public findNodeRelativeTo(string $query, DOMNode $context) : DOMNode|false
Parameters
$query : string

The query.

$context : DOMNode

Search below this node.

Return values
DOMNode|false

The named DOMNode or empty if no node was found.

findNodes()

Return all nodes matching the given XPath query.

public findNodes(string $query) : DOMNodeList
Parameters
$query : string

The query.

Return values
DOMNodeList

The list of DOMNodes.

findNodesRelativeTo()

Return all nodes matching the given XPath query.

public findNodesRelativeTo(string $query, mixed $context) : DOMNodeList
Parameters
$query : string

The query.

$context : mixed
Return values
DOMNodeList

The list of DOMNodes.

getChannel()

Return the package channel.

public getChannel() : string
Return values
string

The channel of the package.

getDate()

Return the release date.

public getDate() : string
Return values
string

The date for the current release.

getDependencies()

Return the package dependencies.

public getDependencies() : array<string|int, mixed>
Return values
array<string|int, mixed>

The package dependencies.

getDescription()

Return the package description.

public getDescription() : string
Return values
string

The description of the package.

getLeads()

Return the package lead developers.

public getLeads() : string
Return values
string

The package lead developers.

getLicense()

Return the license name.

public getLicense() : string
Return values
string

The name of the license.

getLicenseLocation()

Return the URL to the license information.

public getLicenseLocation() : string
Return values
string

The license URI.

getName()

Return the package name.

public getName() : string
Return values
string

The name of the package.

getNodeText()

Return the content of a single named node matching the given XPath query.

public getNodeText(string $path) : string|false
Parameters
$path : string

The node path.

Return values
string|false

The node content as string or empty if no node was found.

getNodeTextRelativeTo()

Return the content of a single named node below the given context and matching the given XPath query.

public getNodeTextRelativeTo(string $path, DOMNode $context) : string|false
Parameters
$path : string

The node path.

$context : DOMNode

Search below this node.

Return values
string|false

The node content as string or empty if no node was found.

getNotes()

Return the package notes.

public getNotes() : string
Return values
string

The notes for the current release.

getState()

Return the stability of the release or api.

public getState([string $key = 'release' ]) : string
Parameters
$key : string = 'release'

"release" or "api"

Return values
string

The stability.

getSummary()

Return the package summary.

public getSummary() : string
Return values
string

The summary of the package.

getVersion()

Return the package version.

public getVersion() : string
Return values
string

The version of the package.

getVersions()

Returns all package versions from the changelog.

public getVersions() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of versions and stabilities.

insert()

public insert(mixed $elements, mixed $point) : mixed
Parameters
$elements : mixed
$point : mixed
Return values
mixed

removeComment()

public removeComment(mixed $node, mixed $comment) : mixed
Parameters
$node : mixed
$comment : mixed
Return values
mixed

removeWhitespace()

public removeWhitespace(mixed $node) : mixed
Parameters
$node : mixed
Return values
mixed

replaceTextNode()

Replace a specific text node

public replaceTextNode(string $path, string $value) : DOMNodeList
Parameters
$path : string

The XPath query pointing to the node.

$value : string

The new text value.

Return values
DOMNodeList

The list of DOMNodes.

replaceTextNodeRelativeTo()

Replace a specific text node

public replaceTextNodeRelativeTo(string $path, DOMNode $context, string $value[, mixed $attributes = array() ]) : DOMNodeList
Parameters
$path : string

The XPath query pointing to the node.

$context : DOMNode

Search below this node.

$value : string

The new text value.

$attributes : mixed = array()
Return values
DOMNodeList

The list of DOMNodes.

setNotes()

Sets notes in the package.xml

public setNotes(array<string|int, mixed> $notes) : mixed
Parameters
$notes : array<string|int, mixed>
Return values
mixed

setState()

Set the state in the package.xml

public setState([string $rel_state = null ][, string $api_state = null ]) : null
Parameters
$rel_state : string = null

The new release state number.

$api_state : string = null

The new api state number.

Return values
null

setVersion()

Set the version in the package.xml

public setVersion([string $rel_version = null ][, string $api_version = null ]) : null
Parameters
$rel_version : string = null

The new release version number.

$api_version : string = null

The new api version number.

Return values
null

syncCurrentVersion()

Synchronizes the current version information with the release information in the changelog.

public syncCurrentVersion() : null
Return values
null

timestamp()

Mark the package as being release and set the timestamps to now.

public timestamp([bool $keepTime = false ]) : mixed
Parameters
$keepTime : bool = false

Keep the

Return values
mixed

_fetchCurrentRelease()

Fetch the node holding the current release information in the changelog.

protected _fetchCurrentRelease() : DOMElement|null
Return values
DOMElement|null

The release node or empty if no such node was found.

_fetchRelease()

Fetch the node holding release information in the changelog.

protected _fetchRelease(string $version) : DOMElement|null
Parameters
$version : string

Version to fetch the release information from.

Return values
DOMElement|null

The release node or empty if no such node was found.

_warnOnEmptyInfo()

Write a warning to STDERR when missing the specified entries in the $info array.

protected _warnOnEmptyInfo(string $version, array<string|int, mixed> $info) : mixed
Parameters
$version : string

The version the note entry is for.

$info : array<string|int, mixed>

The note info entry.

Return values
mixed

_appendChild()

Append a new child.

private _appendChild(DOMNode $parent, string $name, string $value[, string $ws = '' ]) : DOMNode
Parameters
$parent : DOMNode

The parent DOMNode.

$name : string

The tag name of the new node.

$value : string

The text content of the new node.

$ws : string = ''

Additional white space that should be inserted.

Return values
DOMNode

The appended child.

_appendLicense()

Append license information.

private _appendLicense(DOMNode $parent, string $license, string $uri[, string $ws = null ]) : null
Parameters
$parent : DOMNode

The parent DOMNode.

$license : string

The license name.

$uri : string

The license URI.

$ws : string = null

Additional white space that should be inserted.

Return values
null

_appendStability()

Append stability information.

private _appendStability(DOMNode $parent, string $release, string $api[, string $ws = null ]) : null
Parameters
$parent : DOMNode

The parent DOMNode.

$release : string

The release stability.

$api : string

The api stability.

$ws : string = null

Additional white space that should be inserted.

Return values
null

_appendVersion()

Append version information.

private _appendVersion(DOMNode $parent, string $version, string $api[, string $ws = '' ]) : null
Parameters
$parent : DOMNode

The parent DOMNode.

$version : string

The version.

$api : string

The api version.

$ws : string = ''

Additional white space that should be inserted.

Return values
null

_completeDependencies()

Complete the dependency information.

private _completeDependencies(DOMNode $parent, array<string|int, mixed> &$result, string $optional) : null
Parameters
$parent : DOMNode

The parent node ("required" or "optional").

$result : array<string|int, mixed>

The result array.

$optional : string

Optional dependency or not?

Return values
null

_dependencyInputValue()

Generate one element of the input data.

private _dependencyInputValue(array<string|int, mixed> &$input, string $name, DOMNode $node) : null
Parameters
$input : array<string|int, mixed>

The input array.

$name : string

Value name.

$node : DOMNode

The dependency node.

Return values
null

_findSingleNode()

Return a single node for the result set.

private _findSingleNode(DOMNodeList $result) : DOMNode|false
Parameters
$result : DOMNodeList

The query result.

Return values
DOMNode|false

The DOMNode or empty if no node was found.

_replacementNode()

Generate a replacement node.

private _replacementNode(DOMNode $old_node, string $value) : DOMNode
Parameters
$old_node : DOMNode

The old DOMNode to be replaced.

$value : string

The new text value.

Return values
DOMNode

The new DOMNode.

_requireCurrentRelease()

Fetch the node holding the current release information in the changelog and fail if there is no such node.

private _requireCurrentRelease() : DOMElement|null
Tags
throws
Horde_Pear_Exception

If the node does not exist.

Return values
DOMElement|null

The release node.

Search results