Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use namespace instead of prefix.

  • Loading branch information...
commit 0b1727efaf550a602cb6004208403728f83f8740 1 parent 376082c
@manuelpichler manuelpichler authored
View
7 src/main/php/classes/argument.php → src/main/php/SystemProcess/Argument.php
@@ -20,6 +20,8 @@
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
*/
+namespace SystemProcess;
+
/**
* Argument base class
*
@@ -30,7 +32,7 @@
* @author Kore Nordmann <kore@php.net>
* @license LGPLv3
*/
-abstract class pbsArgument
+abstract class Argument
{
/**
* Raw argument value
@@ -42,8 +44,7 @@
/**
* Construct argument from argument value
*
- * @param string $value
- * @return void
+ * @param string $value
*/
public function __construct( $value )
{
View
6 src/main/php/classes/argument/escaped.php → ...ystemProcess/Argument/EscapedArgument.php
@@ -20,6 +20,10 @@
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
*/
+namespace SystemProcess\Argument;
+
+use \SystemProcess\Argument;
+
/**
* Escaped argument
*
@@ -30,7 +34,7 @@
* @author Kore Nordmann <kore@php.net>
* @license LGPLv3
*/
-class pbsEscapedArgument extends pbsArgument
+class EscapedArgument extends Argument
{
/**
* Get prepared argument value
View
4 src/main/php/classes/argument/path.php → ...p/SystemProcess/Argument/PathArgument.php
@@ -20,6 +20,8 @@
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
*/
+namespace SystemProcess\Argument;
+
/**
* Path argument
*
@@ -29,7 +31,7 @@
* @author Kore Nordmann <kore@php.net>
* @license LGPLv3
*/
-class pbsPathArgument extends pbsEscapedArgument
+class PathArgument extends EscapedArgument
{
/**
* Get prepared argument value
View
6 src/main/php/classes/argument/unescaped.php → ...temProcess/Argument/UnescapedArgument.php
@@ -20,6 +20,10 @@
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
*/
+namespace SystemProcess\Argument;
+
+use \SystemProcess\Argument;
+
/**
* Unescaped argument
*
@@ -30,7 +34,7 @@
* @author Kore Nordmann <kore@php.net>
* @license LGPLv3
*/
-class pbsUnescapedArgument extends pbsArgument
+class UnescapedArgument extends Argument
{
/**
* Get prepared argument value
View
4 ...emProcess/invalidCustomFileDescriptor.php → ...cess/InvalidCustomDescriptorException.php
@@ -1,6 +1,8 @@
<?php
-class pbsSystemProcessInvalidCustomDescriptorException extends Exception
+namespace SystemProcess;
+
+class InvalidCustomDescriptorException extends \Exception
{
public function __construct( $fd )
{
View
6 ...eptions/systemProcess/nonZeroExitCode.php → ...ystemProcess/NonZeroExitCodeException.php
@@ -1,5 +1,7 @@
<?php
+namespace SystemProcess;
+
/**
* Exception thrown if an executed application returns a non zero exit code
*
@@ -8,7 +10,7 @@
* @author Jakob Westhoff <jakob@php.net>
* @license LGPLv3
*/
-class pbsSystemProcessNonZeroExitCodeException extends Exception
+class NonZeroExitCodeException extends \Exception
{
public $exitCode;
public $stdoutOutput;
@@ -36,5 +38,3 @@ public function __construct( $exitCode, $stdoutOutput, $stderrOutput, $command )
$this->command = $command;
}
}
-
-?>
View
4 ...p/exceptions/systemProcess/notRunning.php → ...php/SystemProcess/NotRunningException.php
@@ -1,6 +1,8 @@
<?php
-class pbsSystemProcessNotRunningException extends Exception
+namespace SystemProcess;
+
+class NotRunningException extends \Exception
{
public function __construct()
{
View
8 ...xceptions/systemProcess/recursivePipe.php → .../SystemProcess/RecursivePipeException.php
@@ -1,9 +1,13 @@
<?php
+namespace SystemProcess;
-class pbsSystemProcessRecursivePipeException extends Exception
+use \Exception;
+
+class RecursivePipeException extends Exception
{
- public function __construct()
+ public function __construct()
{
parent::__construct( 'You are trying to pipe a system process to itself. Recursive piping would create an endless loop and is therefore not possible.' );
}
}
+
View
63 src/main/php/classes/systemProcess.php → src/main/php/SystemProcess/SystemProcess.php
@@ -20,6 +20,13 @@
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
*/
+namespace SystemProcess;
+
+use SystemProcess\Argument;
+use SystemProcess\Argument\EscapedArgument;
+use SystemProcess\Argument\UnescapedArgument;
+use \SystemProcess\InvalidCustomDescriptorException;
+
/**
* Management facility for any external system process.
*
@@ -36,7 +43,7 @@
* "bar":
* <code>
* <?php
- * $p = new pbsSystemProcess( 'echo' );
+ * $p = new SystemProcess( 'echo' );
* $p->argument( 'foo' )->argument( 'bar' );
* $returnCode = $p->execute();
* ?>
@@ -49,10 +56,10 @@
* effort.
* <code>
* <?php
- * $consumer = new pbsSystemProcess( 'cat' );
- * $consumer->redirect( pbsSystemProcess::STDOUT, pbsSystemProcess::STDERR );
+ * $consumer = new SystemProcess( 'cat' );
+ * $consumer->redirect( SystemProcess::STDOUT, SystemProcess::STDERR );
*
- * $provider = new pbsSystemProcess( 'echo' );
+ * $provider = new SystemProcess( 'echo' );
* $provider->nonZeroExitCodeException = true;
* $provider->argument( 'foobar' )
* ->pipe( $consumer )
@@ -77,7 +84,7 @@
* context like printf.
* <code>
* <?php
- * $p = new pbsSystemProcess( 'echo' );
+ * $p = new SystemProcess( 'echo' );
* $p->argument( 'foo' )
* ->argument( 'bar' )
*
@@ -97,7 +104,7 @@
* @author Jakob Westhoff <jakob@php.net>
* @license LGPLv3
*/
-class pbsSystemProcess
+class SystemProcess
{
/*
* Types of command parts
@@ -282,28 +289,28 @@ public function __toString()
/**
* Add an argument to the system process
*
- * Accepts pbsArgument objects, or any scalar, which is then wrapped into
- * an argument object for BC.
+ * Accepts {@link \SystemProcess\Argument} objects, or any scalar, which is
+ * then wrapped into an argument object for BC.
*
* @param mixed $argument Argument to add to the commandline
* @param bool $alreadyEscaped The given argument will not be escaped. If
* you decide to pass true here, you need to make sure the argument
* supplied is not harmful and treated as one argument. Therfore you may
* need to enclose it in single or double quotes.
- * @return pbsSystemProcess The object this method was called on (fluent
+ * @return \SystemProcess\SystemProcess The object this method was called on (fluent
* interface)
*/
public function argument( $argument, $alreadyEscaped = false )
{
- if ( !$argument instanceof pbsArgument )
+ if ( !$argument instanceof Argument )
{
if ( $alreadyEscaped )
{
- $argument = new pbsUnescapedArgument( $argument );
+ $argument = new UnescapedArgument( $argument );
}
else
{
- $argument = new pbsEscapedArgument( $argument );
+ $argument = new EscapedArgument( $argument );
}
}
@@ -314,15 +321,15 @@ public function argument( $argument, $alreadyEscaped = false )
/**
* Pipe the output of the executed command to another system process
*
- * @param pbsSystemProcess $process Process to pipe the output to
- * @return pbsSystemProcess The object this method was called on (fluent
+ * @param \SystemProcess\SystemProcess $process Process to pipe the output to
+ * @return \SystemProcess\SystemProcess The object this method was called on (fluent
* interface)
*/
- public function pipe( pbsSystemProcess $process )
+ public function pipe( SystemProcess $process )
{
if ( $process === $this )
{
- throw new pbsSystemProcessRecursivePipeException();
+ throw new RecursivePipeException();
}
$this->commandParts[] = array( self::SYSTEMPROCESS, &$process->commandParts );
return $this;
@@ -335,8 +342,8 @@ public function pipe( pbsSystemProcess $process )
* STDOUT or STDERR)
* @param mixed $target The target to redirect the given stream to. This
* may be a filename or a another stream
- * @return pbsSystemProcess The object this method was called on (fluent
- * interface)
+ * @return \SystemProcess\SystemProcess The object this method was called on
+ * (fluent interface)
*/
public function redirect( $stream, $target )
{
@@ -357,8 +364,8 @@ public function redirect( $stream, $target )
* @param array $env The environment to be used defined as associative
* array. The array key is the variable name and the value is the
* corresponding value for this variable.
- * @return pbsSystemProcess The object this method was called on (fluent
- * interface)
+ * @return \SystemProcess\SystemProcess The object this method was called on
+ * (fluent interface)
*/
public function environment( $env )
{
@@ -377,8 +384,8 @@ public function environment( $env )
* be used.
*
* @param string $cwd Working directory to be set
- * @return pbsSystemProcess The object this method was called on (fluent
- * interface)
+ * @return \SystemProcess\SystemProcess The object this method was called on
+ * (fluent interface)
*/
public function workingDirectory( $cwd )
{
@@ -405,14 +412,14 @@ public function workingDirectory( $cwd )
* reading from the pipe
* @param string filemode If the type is FILE this is the mode to open the
* file with, e.g. "a"
- * @return pbsSystemProcess The object this method was called on (fluent
- * interface)
+ * @return \SystemProcess\SystemProcess The object this method was called on
+ * (fluent interface)
*/
public function descriptor( $fd, $type, $target, $filemode = null )
{
if ( $fd < 3 )
{
- throw new pbsSystemProcessInvalidCustomDescriptorException( $fd );
+ throw new InvalidCustomDescriptorException( $fd );
}
if ( $filemode === null )
{
@@ -527,7 +534,7 @@ public function execute( $asyncronous = false )
if ( $retVal !== 0 && $this->attributes['nonZeroExitCodeException'] === true )
{
- throw new pbsSystemProcessNonZeroExitCodeException(
+ throw new NonZeroExitCodeException(
$retVal,
$this->attributes['stdoutOutput'],
$this->attributes['stderrOutput'],
@@ -548,7 +555,7 @@ public function close()
{
if ( $this->processHandle === null )
{
- throw new pbsSystemProcessNotRunningException();
+ throw new NotRunningException();
}
// Close all pipes
@@ -577,7 +584,7 @@ public function signal( $signal )
{
if ( $this->processHandle === null )
{
- throw new pbsSystemProcessNotRunningException();
+ throw new NotRunningException();
}
proc_terminate( $this->processHandle, $signal );
}
View
2  src/test/php/SystemProcessTests.php
@@ -1,6 +1,8 @@
<?php
require_once( __DIR__ . '/environment.php' );
+namespace SystemProcess;
+
class pbsSystemProcessTests extends PHPUnit_Framework_TestCase
{
protected static $win = false;

0 comments on commit 0b1727e

Please sign in to comment.
Something went wrong with that request. Please try again.