update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -39,10 +39,10 @@ interface PipesInterface
/**
* Reads data in file handles and pipes.
*
* @param bool $blocking Whether to use blocking calls or not.
* @param bool $close Whether to close pipes if they've reached EOF.
* @param bool $blocking Whether to use blocking calls or not
* @param bool $close Whether to close pipes if they've reached EOF
*
* @return string[] An array of read data indexed by their fd.
* @return string[] An array of read data indexed by their fd
*/
public function readAndWrite($blocking, $close = false);

View File

@@ -47,15 +47,35 @@ class WindowsPipes extends AbstractPipes
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.
//
// @see https://bugs.php.net/bug.php?id=51800
$this->files = array(
Process::STDOUT => tempnam(sys_get_temp_dir(), 'out_sf_proc'),
Process::STDERR => tempnam(sys_get_temp_dir(), 'err_sf_proc'),
$pipes = array(
Process::STDOUT => Process::OUT,
Process::STDERR => Process::ERR,
);
foreach ($this->files as $offset => $file) {
if (false === $file || false === $this->fileHandles[$offset] = @fopen($file, 'rb')) {
throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
$tmpDir = sys_get_temp_dir();
$error = 'unknown reason';
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
for ($i = 0;; ++$i) {
foreach ($pipes as $pipe => $name) {
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
if (file_exists($file) && !unlink($file)) {
continue 2;
}
$h = fopen($file, 'xb');
if (!$h && false === strpos($error, 'File exists')) {
restore_error_handler();
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error));
}
if (!$h || !$this->fileHandles[$pipe] = fopen($file, 'rb')) {
continue 2;
}
if (isset($this->files[$pipe])) {
unlink($this->files[$pipe]);
}
$this->files[$pipe] = $file;
}
break;
}
restore_error_handler();
}
parent::__construct($input);

View File

@@ -593,7 +593,7 @@ class Process
* This method relies on the Unix exit code status standardization
* and might not be relevant for other operating systems.
*
* @return null|string A string representation for the exit status code, null if the Process is not terminated.
* @return null|string A string representation for the exit status code, null if the Process is not terminated
*
* @see http://tldp.org/LDP/abs/html/exitcodes.html
* @see http://en.wikipedia.org/wiki/Unix_signal
@@ -881,7 +881,7 @@ class Process
*
* @param int|float|null $timeout The timeout in seconds
*
* @return self The current Process instance.
* @return self The current Process instance
*
* @throws LogicException if the output is disabled
* @throws InvalidArgumentException if the timeout is negative
@@ -1226,7 +1226,7 @@ class Process
/**
* Updates the status of the process, reads pipes.
*
* @param bool $blocking Whether to use a blocking read call.
* @param bool $blocking Whether to use a blocking read call
*/
protected function updateStatus($blocking)
{
@@ -1312,8 +1312,8 @@ class Process
/**
* Reads pipes, executes callback.
*
* @param bool $blocking Whether to use blocking calls or not.
* @param bool $close Whether to close file handles or not.
* @param bool $blocking Whether to use blocking calls or not
* @param bool $close Whether to close file handles or not
*/
private function readPipes($blocking, $close)
{
@@ -1439,7 +1439,7 @@ class Process
/**
* Ensures the process is running or terminated, throws a LogicException if the process has a not started.
*
* @param string $functionName The function name that was called.
* @param string $functionName The function name that was called
*
* @throws LogicException If the process has not run.
*/
@@ -1453,7 +1453,7 @@ class Process
/**
* Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
*
* @param string $functionName The function name that was called.
* @param string $functionName The function name that was called
*
* @throws LogicException If the process is not yet terminated.
*/

View File

@@ -54,6 +54,9 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
public function testThatProcessDoesNotThrowWarningDuringRun()
{
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test is transient on Windows');
}
@trigger_error('Test Error', E_USER_NOTICE);
$process = $this->getProcess(self::$phpBin." -r 'sleep(3)'");
$process->run();
@@ -1162,7 +1165,8 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provideVariousIncrementals
*/
public function testIncrementalOutputDoesNotRequireAnotherCall($stream, $method) {
public function testIncrementalOutputDoesNotRequireAnotherCall($stream, $method)
{
$process = $this->getProcess(self::$phpBin.' -r '.escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\''.$stream.'\', $n, 1); $n++; usleep(1000); }'), null, null, null, null);
$process->start();
$result = '';
@@ -1177,7 +1181,8 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
$process->stop();
}
public function provideVariousIncrementals() {
public function provideVariousIncrementals()
{
return array(
array('php://stdout', 'getIncrementalOutput'),
array('php://stderr', 'getIncrementalErrorOutput'),
@@ -1206,7 +1211,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
} catch (RuntimeException $e) {
$this->assertSame('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.', $e->getMessage());
if ($enhance) {
$process->setEnhanceSigChildCompatibility(true);
$process->setEnhanceSigchildCompatibility(true);
} else {
self::$notEnhancedSigchild = true;
}