summaryrefslogtreecommitdiff
path: root/vendor/symfony/console/Event
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2017-12-15 11:24:35 -0800
committerFrédéric Guillot <fred@kanboard.net>2017-12-15 11:55:42 -0800
commita93b8e10f5954be0853eec693c13e84c4bd9e6f2 (patch)
treeeda5de9494b819235616e8623bb3393e9cc373af /vendor/symfony/console/Event
parent2c72a283f2d51034f85f4e2ca8b194d304a3c433 (diff)
Kanboard requires at least PHP 5.6 now
Diffstat (limited to 'vendor/symfony/console/Event')
-rw-r--r--vendor/symfony/console/Event/ConsoleCommandEvent.php2
-rw-r--r--vendor/symfony/console/Event/ConsoleErrorEvent.php83
-rw-r--r--vendor/symfony/console/Event/ConsoleEvent.php4
-rw-r--r--vendor/symfony/console/Event/ConsoleExceptionEvent.php4
4 files changed, 89 insertions, 4 deletions
diff --git a/vendor/symfony/console/Event/ConsoleCommandEvent.php b/vendor/symfony/console/Event/ConsoleCommandEvent.php
index 92adf1ef..2f517c1d 100644
--- a/vendor/symfony/console/Event/ConsoleCommandEvent.php
+++ b/vendor/symfony/console/Event/ConsoleCommandEvent.php
@@ -25,8 +25,6 @@ class ConsoleCommandEvent extends ConsoleEvent
/**
* Indicates if the command should be run or skipped.
- *
- * @var bool
*/
private $commandShouldRun = true;
diff --git a/vendor/symfony/console/Event/ConsoleErrorEvent.php b/vendor/symfony/console/Event/ConsoleErrorEvent.php
new file mode 100644
index 00000000..0d05b9da
--- /dev/null
+++ b/vendor/symfony/console/Event/ConsoleErrorEvent.php
@@ -0,0 +1,83 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Event;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Exception\InvalidArgumentException;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Allows to handle throwables thrown while running a command.
+ *
+ * @author Wouter de Jong <wouter@wouterj.nl>
+ */
+final class ConsoleErrorEvent extends ConsoleEvent
+{
+ private $error;
+ private $exitCode;
+
+ public function __construct(InputInterface $input, OutputInterface $output, $error, Command $command = null)
+ {
+ parent::__construct($command, $input, $output);
+
+ $this->setError($error);
+ }
+
+ /**
+ * Returns the thrown error/exception.
+ *
+ * @return \Throwable
+ */
+ public function getError()
+ {
+ return $this->error;
+ }
+
+ /**
+ * Replaces the thrown error/exception.
+ *
+ * @param \Throwable $error
+ */
+ public function setError($error)
+ {
+ if (!$error instanceof \Throwable && !$error instanceof \Exception) {
+ throw new InvalidArgumentException(sprintf('The error passed to ConsoleErrorEvent must be an instance of \Throwable or \Exception, "%s" was passed instead.', is_object($error) ? get_class($error) : gettype($error)));
+ }
+
+ $this->error = $error;
+ }
+
+ /**
+ * Sets the exit code.
+ *
+ * @param int $exitCode The command exit code
+ */
+ public function setExitCode($exitCode)
+ {
+ $this->exitCode = (int) $exitCode;
+
+ $r = new \ReflectionProperty($this->error, 'code');
+ $r->setAccessible(true);
+ $r->setValue($this->error, $this->exitCode);
+ }
+
+ /**
+ * Gets the exit code.
+ *
+ * @return int The command exit code
+ */
+ public function getExitCode()
+ {
+ return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
+ }
+}
diff --git a/vendor/symfony/console/Event/ConsoleEvent.php b/vendor/symfony/console/Event/ConsoleEvent.php
index ab620c46..5440da21 100644
--- a/vendor/symfony/console/Event/ConsoleEvent.php
+++ b/vendor/symfony/console/Event/ConsoleEvent.php
@@ -28,7 +28,7 @@ class ConsoleEvent extends Event
private $input;
private $output;
- public function __construct(Command $command, InputInterface $input, OutputInterface $output)
+ public function __construct(Command $command = null, InputInterface $input, OutputInterface $output)
{
$this->command = $command;
$this->input = $input;
@@ -38,7 +38,7 @@ class ConsoleEvent extends Event
/**
* Gets the command that is executed.
*
- * @return Command A Command instance
+ * @return Command|null A Command instance
*/
public function getCommand()
{
diff --git a/vendor/symfony/console/Event/ConsoleExceptionEvent.php b/vendor/symfony/console/Event/ConsoleExceptionEvent.php
index 603b7eed..a31797fa 100644
--- a/vendor/symfony/console/Event/ConsoleExceptionEvent.php
+++ b/vendor/symfony/console/Event/ConsoleExceptionEvent.php
@@ -11,6 +11,8 @@
namespace Symfony\Component\Console\Event;
+@trigger_error(sprintf('The "%s" class is deprecated since version 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED);
+
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -19,6 +21,8 @@ use Symfony\Component\Console\Output\OutputInterface;
* Allows to handle exception thrown in a command.
*
* @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @deprecated since version 3.3, to be removed in 4.0. Use ConsoleErrorEvent instead.
*/
class ConsoleExceptionEvent extends ConsoleEvent
{