Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.1'

* 2.1:
  [Yaml] fixed default value
  Added Yaml\Dumper::setIndentation() method to allow a custom indentation level of nested nodes.
  added a way to enable/disable object support when parsing/dumping
  added a way to enable/disable PHP support when parsing a YAML input via Yaml::parse()
  fixed CS
  [Process] Fix docblocks, remove `return` from `PhpProcess#start()` as parent returns nothing, cleaned up `ExecutableFinder`
  fixes a bug when output/error output contains a % character
  [Console] fixed input bug when the value of an option is empty (closes #6649, closes #6689)
  [Profiler] [Redis] Fix sort of profiler rows.
  Fix version_compare() calls for PHP 5.5.
  Removed underscores from test method names to be consistent with other components.
  [Process] In edge cases `getcwd()` can return `false`, then `proc_open()` should get `null` to use default value (the working dir of the current PHP process)
  Fix version_compare() calls for PHP 5.5.
  Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5.
  removed the .gitattributes files (closes #6605, reverts #5674)
  [HttpKernel] Clarify misleading comment in ExceptionListener

Conflicts:
	src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig
	src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php
	src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
	src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php
	src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
	src/Symfony/Component/Process/Process.php
  • Loading branch information...
commit dace2b9abb058b8d40452f8ab4532db8e4d273db 2 parents cad4674 + 86ac6b3
@fabpot fabpot authored
View
2  .gitattributes
@@ -1,2 +0,0 @@
-/Tests export-ignore
-phpunit.xml.dist export-ignore
View
6 Exception/ProcessFailedException.php
@@ -30,8 +30,10 @@ public function __construct(Process $process)
parent::__construct(
sprintf(
- 'The command "%s" failed.'."\n\nOutput:\n================\n".$process->getOutput()."\n\nError Output:\n================\n".$process->getErrorOutput(),
- $process->getCommandLine()
+ 'The command "%s" failed.'."\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
+ $process->getCommandLine(),
+ $process->getOutput(),
+ $process->getErrorOutput()
)
);
View
21 ExecutableFinder.php
@@ -19,22 +19,23 @@
*/
class ExecutableFinder
{
- private static $isWindows;
-
private $suffixes = array('.exe', '.bat', '.cmd', '.com');
- public function __construct()
- {
- if (null === self::$isWindows) {
- self::$isWindows = 0 === stripos(PHP_OS, 'win');
- }
- }
-
+ /**
+ * Replaces default suffixes of executable.
+ *
+ * @param array $suffixes
+ */
public function setSuffixes(array $suffixes)
{
$this->suffixes = $suffixes;
}
+ /**
+ * Adds new possible suffix to check for executable.
+ *
+ * @param string $suffix
+ */
public function addSuffix($suffix)
{
$this->suffixes[] = $suffix;
@@ -78,7 +79,7 @@ public function find($name, $default = null, array $extraDirs = array())
}
foreach ($suffixes as $suffix) {
foreach ($dirs as $dir) {
- if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (self::$isWindows || is_executable($file))) {
+ if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (defined('PHP_WINDOWS_VERSION_BUILD') || is_executable($file))) {
return $file;
}
}
View
2  PhpProcess.php
@@ -68,6 +68,6 @@ public function start($callback = null)
$this->setCommandLine($php);
}
- return parent::start($callback);
+ parent::start($callback);
}
}
View
40 Process.php
@@ -130,7 +130,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
}
$this->commandline = $commandline;
- $this->cwd = null === $cwd ? getcwd() : $cwd;
+ $this->cwd = $cwd;
if (null !== $env) {
$this->env = array();
foreach ($env as $key => $value) {
@@ -176,8 +176,8 @@ public function __clone()
* The STDOUT and STDERR are also available after the process is finished
* via the getOutput() and getErrorOutput() methods.
*
- * @param callable $callback A PHP callback to run whenever there is some
- * output available on STDOUT or STDERR
+ * @param callback|null $callback A PHP callback to run whenever there is some
+ * output available on STDOUT or STDERR
*
* @return integer The exit status code
*
@@ -207,8 +207,8 @@ public function run($callback = null)
* with true as a second parameter then the callback will get all data occurred
* in (and since) the start call.
*
- * @param callable $callback A PHP callback to run whenever there is some
- * output available on STDOUT or STDERR
+ * @param callback|null $callback A PHP callback to run whenever there is some
+ * output available on STDOUT or STDERR
*
* @throws RuntimeException When process can't be launch or is stopped
* @throws RuntimeException When process is already running
@@ -364,11 +364,12 @@ public function restart($callback = null)
* from the output in real-time while writing the standard input to the process.
* It allows to have feedback from the independent process during execution.
*
- * @param callable $callback A valid PHP callback
+ * @param callback|null $callback A valid PHP callback
*
- * @return int The exitcode of the process
+ * @return integer The exitcode of the process
*
- * @throws RuntimeException
+ * @throws \RuntimeException When process timed out
+ * @throws \RuntimeException When process stopped after receiving signal
*/
public function wait($callback = null)
{
@@ -538,8 +539,6 @@ public function getExitCode()
*
* @return string A string representation for the exit status code
*
- * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
- *
* @see http://tldp.org/LDP/abs/html/exitcodes.html
* @see http://en.wikipedia.org/wiki/Unix_signal
*/
@@ -555,8 +554,6 @@ public function getExitCodeText()
*
* @return Boolean true if the process ended successfully, false otherwise
*
- * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
- *
* @api
*/
public function isSuccessful()
@@ -695,7 +692,7 @@ public function getStatus()
/**
* Stops the process.
*
- * @param integer $timeout The timeout in seconds
+ * @param integer|float $timeout The timeout in seconds
*
* @return integer The exit-code of the process
*
@@ -823,6 +820,13 @@ public function setTimeout($timeout)
*/
public function getWorkingDirectory()
{
+ // This is for BC only
+ if (null === $this->cwd) {
+ // getcwd() will return false if any one of the parent directories does not have
+ // the readable or search mode set, even if the current directory does
+ return getcwd() ?: null;
+ }
+
return $this->cwd;
}
@@ -972,9 +976,9 @@ public function setEnhanceSigchildCompatibility($enhance)
* The callbacks adds all occurred output to the specific buffer and calls
* the user callback (if present) with the received output.
*
- * @param callable $callback The user defined PHP callback
+ * @param callback|null $callback The user defined PHP callback
*
- * @return mixed A PHP callable
+ * @return callback A PHP callable
*/
protected function buildCallback($callback)
{
@@ -1014,6 +1018,9 @@ protected function updateStatus()
}
}
+ /**
+ * Updates the current error output of the process (STDERR).
+ */
protected function updateErrorOutput()
{
if (isset($this->pipes[self::STDERR]) && is_resource($this->pipes[self::STDERR])) {
@@ -1021,6 +1028,9 @@ protected function updateErrorOutput()
}
}
+ /**
+ * Updates the current output of the process (STDOUT).
+ */
protected function updateOutput()
{
if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) {
View
14 Tests/AbstractProcessTest.php
@@ -18,8 +18,6 @@
*/
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
{
- abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
-
/**
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
*/
@@ -367,4 +365,16 @@ public function methodProvider()
return $defaults;
}
+
+ /**
+ * @param string $commandline
+ * @param null $cwd
+ * @param array $env
+ * @param null $stdin
+ * @param integer $timeout
+ * @param array $options
+ *
+ * @return Process
+ */
+ abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
}
View
2  Tests/PhpExecutableFinderTest.php
@@ -21,7 +21,7 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
/**
* tests find() with the env var PHP_PATH
*/
- public function testFindWithPHP_PATH()
+ public function testFindWithPhpPath()
{
if (defined('PHP_BINARY')) {
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');
View
20 Tests/SigchildDisabledProcessTest.php
@@ -13,15 +13,6 @@
class SigchildDisabledProcessTest extends AbstractProcessTest
{
-
- protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
- {
- $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
- $process->setEnhanceSigchildCompatibility(false);
-
- return $process;
- }
-
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
@@ -96,4 +87,15 @@ public function testIsNotSuccessful()
{
parent::testIsNotSuccessful();
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
+ {
+ $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
+ $process->setEnhanceSigchildCompatibility(false);
+
+ return $process;
+ }
}
View
19 Tests/SigchildEnabledProcessTest.php
@@ -13,15 +13,6 @@
class SigchildEnabledProcessTest extends AbstractProcessTest
{
-
- protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
- {
- $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
- $process->setEnhanceSigchildCompatibility(true);
-
- return $process;
- }
-
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
@@ -62,4 +53,14 @@ public function testExitCodeText()
$this->assertInternalType('string', $process->getExitCodeText());
}
+ /**
+ * {@inheritdoc}
+ */
+ protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
+ {
+ $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
+ $process->setEnhanceSigchildCompatibility(true);
+
+ return $process;
+ }
}
View
27 Tests/SimpleProcessTest.php
@@ -15,20 +15,14 @@
class SimpleProcessTest extends AbstractProcessTest
{
+ private $enabledSigchild = false;
- protected function skipIfPHPSigchild()
+ public function setUp()
{
ob_start();
phpinfo(INFO_GENERAL);
- if (false !== strpos(ob_get_clean(), '--enable-sigchild')) {
- $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
- }
- }
-
- protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
- {
- return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
+ $this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
}
public function testGetExitCode()
@@ -84,4 +78,19 @@ public function testIsNotSuccessful()
$this->skipIfPHPSigchild();
parent::testIsNotSuccessful();
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
+ {
+ return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
+ }
+
+ private function skipIfPHPSigchild()
+ {
+ if ($this->enabledSigchild) {
+ $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.