内核更新

This commit is contained in:
2016-12-28 10:41:09 +08:00
parent c89254e12a
commit ffab826db0
65 changed files with 1194 additions and 610 deletions

View File

@@ -15,10 +15,9 @@ use think\Process;
class Builder
{
private $arguments;
private $cwd;
private $env = null;
private $env = null;
private $input;
private $timeout = 60;
private $options = [];
@@ -155,7 +154,7 @@ class Builder
return $this;
}
$timeout = (float)$timeout;
$timeout = (float) $timeout;
if ($timeout < 0) {
throw new \InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
@@ -231,4 +230,4 @@ class Builder
return $process;
}
}
}

View File

@@ -60,7 +60,7 @@ class Utils
return $input;
}
if (is_scalar($input)) {
return (string)$input;
return (string) $input;
}
throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
}
@@ -72,4 +72,4 @@ class Utils
return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
namespace think\process\exception;
use think\Process;
class Failed extends \RuntimeException
{
private $process;
public function __construct(Process $process)
{
if ($process->isSuccessful()) {
throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.');
}
$error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText());
if (!$process->isOutputDisabled()) {
$error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput());
}
parent::__construct($error);
$this->process = $process;
}
public function getProcess()
{
return $this->process;
}
}

View File

@@ -58,4 +58,4 @@ class Timeout extends \RuntimeException
throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
}
}
}
}

View File

@@ -53,7 +53,6 @@ abstract class Pipes
*/
abstract public function areOpen();
/**
* {@inheritdoc}
*/
@@ -91,4 +90,4 @@ abstract class Pipes
$this->blocked = false;
}
}
}

View File

@@ -25,14 +25,14 @@ class Unix extends Pipes
public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
{
$this->ttyMode = (bool)$ttyMode;
$this->ptyMode = (bool)$ptyMode;
$this->disableOutput = (bool)$disableOutput;
$this->ttyMode = (bool) $ttyMode;
$this->ptyMode = (bool) $ptyMode;
$this->disableOutput = (bool) $disableOutput;
if (is_resource($input)) {
$this->input = $input;
} else {
$this->inputBuffer = (string)$input;
$this->inputBuffer = (string) $input;
}
}
@@ -134,12 +134,12 @@ class Unix extends Pipes
$type = (false !== $found = array_search($pipe, $this->pipes)) ? $found : 'input';
$data = '';
while ('' !== $dataread = (string)fread($pipe, self::CHUNK_SIZE)) {
while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) {
$data .= $dataread;
}
if ('' !== $data) {
if ($type === 'input') {
if ('input' === $type) {
$this->inputBuffer .= $data;
} else {
$read[$type] = $data;
@@ -147,7 +147,7 @@ class Unix extends Pipes
}
if (false === $data || (true === $close && feof($pipe) && '' === $data)) {
if ($type === 'input') {
if ('input' === $type) {
$this->input = null;
} else {
fclose($this->pipes[$type]);
@@ -160,7 +160,7 @@ class Unix extends Pipes
while (strlen($this->inputBuffer)) {
$written = fwrite($w[0], $this->inputBuffer, 2 << 18); // write 512k
if ($written > 0) {
$this->inputBuffer = (string)substr($this->inputBuffer, $written);
$this->inputBuffer = (string) substr($this->inputBuffer, $written);
} else {
break;
}
@@ -180,7 +180,7 @@ class Unix extends Pipes
*/
public function areOpen()
{
return (bool)$this->pipes;
return (bool) $this->pipes;
}
/**
@@ -193,4 +193,4 @@ class Unix extends Pipes
{
return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
}
}
}

View File

@@ -30,7 +30,7 @@ class Windows extends Pipes
public function __construct($disableOutput, $input)
{
$this->disableOutput = (bool)$disableOutput;
$this->disableOutput = (bool) $disableOutput;
if (!$this->disableOutput) {
@@ -128,7 +128,7 @@ class Windows extends Pipes
*/
public function areOpen()
{
return (bool)$this->pipes && (bool)$this->fileHandles;
return (bool) $this->pipes && (bool) $this->fileHandles;
}
/**
@@ -213,7 +213,7 @@ class Windows extends Pipes
while (strlen($this->inputBuffer)) {
$written = fwrite($w[0], $this->inputBuffer, 2 << 18);
if ($written > 0) {
$this->inputBuffer = (string)substr($this->inputBuffer, $written);
$this->inputBuffer = (string) substr($this->inputBuffer, $written);
} else {
break;
}
@@ -225,4 +225,4 @@ class Windows extends Pipes
unset($this->pipes[0]);
}
}
}
}