package.xml 0000664 0001750 0001750 00000171144 12630260406 013012 0 ustar michiel michiel
phingpear.phing.infoPHP5 project build system based on Apache AntPHing Is Not GNU make; it's a project build system based on Apache Ant.
You can do anything with it that you could do with a traditional build system like GNU make, and its use of
simple XML build files and extensible PHP "task" classes make it an easy-to-use and highly flexible build framework.
Features include file transformations (e.g. token replacement, XSLT transformation, Smarty template transformations,
etc.), file system operations, interactive build support, SQL execution, and much more.Michiel Rookmrookmrook@php.netyes2015-12-042.13.02.13.0stablestableLGPL
This is the latest stable release of Phing.
5.2.01.8.0phingdocspear.phing.info2.13.0VersionControl_SVNpear.php.net0.4.0VersionControl_Gitpear.php.net0.4.3Xdebugpecl.php.net2.0.5Archive_Tarpear.php.net1.3.8PEAR_PackageFileManagerpear.php.net1.5.2Services_Amazon_S3pear.php.net0.3.1HTTP_Request2pear.php.net2.1.1PHP_Dependpear.pdepend.org0.10.0PHP_PMDpear.phpmd.org1.1.0phpDocumentorpear.phpdoc.org2.0.0b7PHP_CodeSnifferpear.php.net1.5.0Net_Growlpear.php.net2.6.0windows2.13.02.13.0stablestable2015-12-04LGPL
This is the latest stable release of Phing.
phing-2.13.0/contrib/DocBlox/Parallel/WorkerPipe.php 0000664 0001750 0001750 00000006266 12630260403 022046 0 ustar michiel michiel
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docblox-project.org
*/
/**
* Class that represents a named pipe for a Worker.
*
* This class manages the named pipe for a worker and is able to push and pull
* specific data to facilitate IPC (interprocess communication).
*
* @category DocBlox
* @package Parallel
* @author Mike van Riel
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docblox-project.org
*/
class DocBlox_Parallel_WorkerPipe
{
/** @var DocBlox_Parallel_Worker worker class that is associated */
protected $worker;
/** @var string Path to the pipe */
protected $path;
/**
* Initializes the named pipe.
*
* @param DocBlox_Parallel_Worker $worker Associated worker.
*/
public function __construct(DocBlox_Parallel_Worker $worker)
{
$this->worker = $worker;
$this->path = tempnam(sys_get_temp_dir(), 'dpm_');
posix_mkfifo($this->path, 0750);
}
/**
* If the named pipe was not cleaned up, do so now.
*/
public function __destruct()
{
if (file_exists($this->path)) {
$this->release();
}
}
/**
* Pull the worker data into the named pipe.
*
* @return void
*/
public function pull()
{
$this->writePipeContents();
}
/**
* Push the worker data back onto the worker and release the pipe.
*
* @return void
*/
public function push()
{
list($result, $error, $return_code) = $this->readPipeContents();
$this->release();
$this->worker->setResult($result);
$this->worker->setError($error);
$this->worker->setReturnCode($return_code);
}
/**
* Convenience method to show relation to readPipeContents.
*
* @return void
*/
protected function writePipeContents()
{
// push the gathered data onto a name pipe
$pipe = fopen($this->path, 'w');
fwrite(
$pipe,
serialize(
array(
$this->worker->getResult(),
$this->worker->getError(),
$this->worker->getReturnCode()
)
)
);
fclose($pipe);
}
/**
* Returns the unserialized contents of the pipe.
*
* @return array
*/
protected function readPipeContents()
{
$pipe = @fopen($this->path, 'r+');
if (! $pipe) {
$arguments = $this->worker->getArguments();
return array(
'',
'Worker died unexpectedly',
255
);
}
$result = unserialize(fread($pipe, filesize($this->path)));
fclose($pipe);
return $result;
}
/**
* Releases the pipe.
*
* @return void
*/
protected function release()
{
@unlink($this->path);
}
}
phing-2.13.0/contrib/DocBlox/Parallel/Manager.php 0000664 0001750 0001750 00000022222 12630260403 021317 0 ustar michiel michiel
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docblox-project.org
*/
/**
* Manager class for Parallel processes.
*
* This class will manage the workers and make sure all processes are executed
* in parallel and not too many at the same time.
*
* @category DocBlox
* @package Parallel
* @author Mike van Riel
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docblox-project.org
*/
class DocBlox_Parallel_Manager extends ArrayObject
{
/** @var int The maximum number of processes to run simultaneously */
protected $process_limit = 2;
/** @var boolean Tracks whether this manager is currently executing */
protected $is_running = false;
/**
* Tries to autodetect the optimal number of process by counting the number
* of processors.
*
* @param array $input Input for the array object.
* @param int $flags flags for the array object.
* @param string $iterator_class Iterator class for this array object.
*/
public function __construct(
$input = array(),
$flags = 0,
$iterator_class = "ArrayIterator"
) {
parent::__construct($input, $flags, $iterator_class);
if (is_readable('/proc/cpuinfo')) {
$processors = 0;
exec("cat /proc/cpuinfo | grep processor | wc -l", $processors);
$this->setProcessLimit(reset($processors));
}
}
/**
* Adds a worker to the queue.
*
* This method will prepare a worker to be executed in parallel once the
* execute method is invoked.
* A fluent interface is provided so that you can chain multiple workers
* in one call.
*
* Example:
*
* $cb1 = function () { var_dump('a'); sleep(1); };
* $cb2 = function () { var_dump('b'); sleep(1); };
*
* $mgr = new DocBlox_Parallel_Manager();
* $mgr->setProcessLimit(2)
* ->addWorker(new DocBlox_Parallel_Worker($cb1))
* ->addWorker(new DocBlox_Parallel_Worker($cb2))
* ->execute();
*
* @param int $index The key for this worker.
* @param DocBlox_Parallel_Worker $newval The worker to add onto the queue.
*
* @see DocBlox_Parallel_Manager::execute()
*
* @throws RuntimeException if this method is invoked while the
* manager is busy executing tasks.
* @throws InvalidArgumentException if the provided element is not of type
* DocBlox_Parallel_Worker.
*
* @return void
*/
public function offsetSet($index, $newval)
{
if (!$newval instanceof DocBlox_Parallel_Worker) {
throw new InvalidArgumentException(
'Provided element must be of type DocBlox_Parallel_Worker'
);
}
if ($this->isRunning()) {
throw new RuntimeException(
'Workers may not be added during execution of the manager'
);
}
parent::offsetSet($index, $newval);
}
/**
* Convenience method to make the addition of workers explicit and allow a
* fluent interface.
*
* @param DocBlox_Parallel_Worker $worker The worker to add onto the queue.
*
* @return self
*/
public function addWorker(DocBlox_Parallel_Worker $worker)
{
$this[] = $worker;
return $this;
}
/**
* Sets how many processes at most to execute at the same time.
*
* A fluent interface is provided so that you can chain multiple workers
* in one call.
*
* @param int $process_limit The limit, minimum of 1
*
* @see DocBlox_Parallel_Manager::addWorker() for an example
*
* @return self
*/
public function setProcessLimit($process_limit)
{
if ($process_limit < 1) {
throw new InvalidArgumentException(
'Number of simultaneous processes may not be less than 1'
);
}
$this->process_limit = $process_limit;
return $this;
}
/**
* Returns the current limit on the amount of processes that can be
* executed at the same time.
*
* @return int
*/
public function getProcessLimit()
{
return $this->process_limit;
}
/**
* Returns whether the manager is executing the workers.
*
* @return boolean
*/
public function isRunning()
{
return $this->is_running;
}
/**
* Executes each worker.
*
* This method loops through the list of workers and tries to fork as
* many times as the ProcessLimit dictates at the same time.
*
* @return void
*/
public function execute()
{
/** @var int[] $processes */
$processes = $this->startExecution();
/** @var DocBlox_Parallel_Worker $worker */
foreach ($this as $worker) {
// if requirements are not met, execute workers in series.
if (!$this->checkRequirements()) {
$worker->execute();
continue;
}
$this->forkAndRun($worker, $processes);
}
$this->stopExecution($processes);
}
/**
* Notifies manager that execution has started, checks requirements and
* returns array for child processes.
*
* If forking is not available because library requirements are not met
* than the list of workers is processed in series and a E_USER_NOTICE is
* triggered.
*
* @return int[]
*/
protected function startExecution()
{
$this->is_running = true;
// throw a E_USER_NOTICE if the requirements are not met.
if (!$this->checkRequirements()) {
trigger_error(
'The PCNTL extension is not available, running workers in series '
. 'instead of parallel',
E_USER_NOTICE
);
}
return array();
}
/**
* Waits for all processes to have finished and notifies the manager that
* execution has stopped.
*
* @param int[] &$processes List of running processes.
*
* @return void
*/
protected function stopExecution(array &$processes)
{
// starting of processes has ended but some processes might still be
// running wait for them to finish
while (!empty($processes)) {
pcntl_waitpid(array_shift($processes), $status);
}
/** @var DocBlox_Parallel_Worker $worker */
foreach ($this as $worker) {
$worker->pipe->push();
}
$this->is_running = false;
}
/**
* Forks the current process and calls the Worker's execute method OR
* handles the parent process' execution.
*
* This is the really tricky part of the forking mechanism. Here we invoke
* {@link http://www.php.net/manual/en/function.pcntl-fork.php pcntl_fork}
* and either execute the forked process or deal with the parent's process
* based on in which process we are.
*
* To fully understand what is going on here it is recommended to read the
* PHP manual page on
* {@link http://www.php.net/manual/en/function.pcntl-fork.php pcntl_fork}
* and associated articles.
*
* If there are more workers than may be ran simultaneously then this method
* will wait until a slot becomes available and then starts the next worker.
*
* @param DocBlox_Parallel_Worker $worker The worker to process.
* @param int[] &$processes The list of running processes.
*
* @throws RuntimeException if we are unable to fork.
*
* @return void
*/
protected function forkAndRun(
DocBlox_Parallel_Worker $worker,
array &$processes
) {
$worker->pipe = new DocBlox_Parallel_WorkerPipe($worker);
// fork the process and register the PID
$pid = pcntl_fork();
switch ($pid) {
case -1:
throw new RuntimeException('Unable to establish a fork');
case 0: // Child process
$worker->execute();
$worker->pipe->pull();
// Kill -9 this process to prevent closing of shared file handlers.
// Not doing this causes, for example, MySQL connections to be cleaned.
posix_kill(getmypid(), SIGKILL);
default: // Parent process
// Keep track if the worker children
$processes[] = $pid;
if (count($processes) >= $this->getProcessLimit()) {
pcntl_waitpid(array_shift($processes), $status);
}
break;
}
}
/**
* Returns true when all requirements are met.
*
* @return bool
*/
protected function checkRequirements()
{
return (bool) (extension_loaded('pcntl'));
}
}
phing-2.13.0/contrib/DocBlox/Parallel/Worker.php 0000664 0001750 0001750 00000012020 12630260403 021211 0 ustar michiel michiel
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docblox-project.org
*/
/**
* Class that represents the execution of a single task within a parallelized
* frame.
*
* @category DocBlox
* @package Parallel
* @author Mike van Riel
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docblox-project.org
*/
class DocBlox_Parallel_Worker
{
/** @var callback the task to execute for this worker */
protected $task = null;
/** @var mixed[] A list of argument to pass to the task */
protected $arguments = array();
/** @var int The return code to tell the parent process how it went */
protected $return_code = -1;
/** @var mixed The result of the given task */
protected $result = '';
/** @var string The error message, if an error occurred */
protected $error = '';
/**
* Creates the worker and sets the task to execute optionally including
* the arguments that need to be passed to the task.
*
* @param callback $task The task to invoke upon execution.
* @param mixed[] $arguments The arguments to provide to the task.
*/
public function __construct($task, array $arguments = array())
{
$this->setTask($task);
$this->arguments = $arguments;
}
/**
* Returns the list of arguments as provided in the constructor.
*
* @see DocBlox_Parallel_Worker::__construct()
*
* @return mixed[]
*/
public function getArguments()
{
return $this->arguments;
}
/**
* Returns the task as provided in the constructor.
*
* @see DocBlox_Parallel_Worker::__construct()
*
* @return callback
*/
public function getTask()
{
return $this->task;
}
/**
* Returns the available return code.
*
* This method may return -1 if no return code is available yet.
*
* @return int
*/
public function getReturnCode()
{
return $this->return_code;
}
/**
* Sets the return code for this worker.
*
* Recommended is to use the same codes as are used with
* {@link http://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
* exit codes}.
*
* In short: 0 means that the task succeeded and a any other positive value
* indicates an error condition.
*
* @param int $return_code Recommended to be a positive number
*
* @throw InvalidArgumentException if the code is not a number or negative
*
* @return void
*/
public function setReturnCode($return_code)
{
if (!is_numeric($return_code) || ($return_code < 0)) {
throw new InvalidArgumentException(
'Expected the return code to be a positive number'
);
}
$this->return_code = $return_code;
}
/**
* Returns the error message associated with the return code.
*
* @return string
*/
public function getError()
{
return $this->error;
}
/**
* Sets the error message.
*
* @param string $error The error message.
*
* @return void
*/
public function setError($error)
{
$this->error = $error;
}
/**
* Returns the result for this task run.
*
* @return null|mixed
*/
public function getResult()
{
return $this->result;
}
/**
* Sets the result for this task run.
*
* @param mixed $result The value that is returned by the task; can be anything.
*
* @return void
*/
public function setResult($result)
{
$this->result = $result;
}
/**
* Invokes the task with the given arguments and processes the output.
*
* @return void.
*/
public function execute()
{
$this->setReturnCode(0);
try {
$this->setResult(
call_user_func_array($this->getTask(), $this->getArguments())
);
} catch (Exception $e) {
$this->setError($e->getMessage());
$this->setReturnCode($e->getCode());
}
}
/**
* Sets the task for this worker and validates whether it is callable.
*
* @param callback $task The task to execute when the execute method
* is invoked.
*
* @throws InvalidArgumentException if the given argument is not a callback.
*
* @see DocBlox_Parallel_Worker::__construct()
* @see DocBlox_Parallel_Worker::execute()
*
* @return void
*/
protected function setTask($task)
{
if (!is_callable($task)) {
throw new InvalidArgumentException(
'Worker task is not a callable object'
);
}
$this->task = $task;
}
}
phing-2.13.0/etc/phpunit-frames.xsl 0000775 0001750 0001750 00000063425 12630260403 016770 0 ustar michiel michiel
.Unit Test Results.
body {
font-family: verdana,arial,helvetica;
color:#000000;
font-size: 12px;
}
table tr td, table tr th {
font-family: verdana,arial,helvetica;
font-size: 12px;
}
table.details tr th{
font-family: verdana,arial,helvetica;
font-weight: bold;
text-align:left;
background:#a6caf0;
}
table.details tr td{
background:#eeeee0;
}
p {
line-height:1.5em;
margin-top:0.5em; margin-bottom:1.0em;
font-size: 12px;
}
h1 {
margin: 0px 0px 5px;
font-family: verdana,arial,helvetica;
}
h2 {
margin-top: 1em; margin-bottom: 0.5em;
font-family: verdana,arial,helvetica;
}
h3 {
margin-bottom: 0.5em;
font-family: verdana,arial,helvetica;
}
h4 {
margin-bottom: 0.5em;
font-family: verdana,arial,helvetica;
}
h5 {
margin-bottom: 0.5em;
font-family: verdana,arial,helvetica;
}
h6 {
margin-bottom: 0.5em;
font-family: verdana,arial,helvetica;
}
.Error {
font-weight:bold; color:red;
}
.Failure {
font-weight:bold; color:purple;
}
.small {
font-size: 9px;
}
a {
color: #003399;
}
a:hover {
color: #888888;
}
.sortable th {
cursor: pointer;
}
.Unit Test Results: Class