Skip to content

Commit

Permalink
minor #34265 Remove \Throwable bubbling down support deprecation laye…
Browse files Browse the repository at this point in the history
…r (fancyweb)

This PR was merged into the 5.0-dev branch.

Discussion
----------

Remove \Throwable bubbling down support deprecation layer

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Remove deprecation layer of #33065

Commits
-------

ffcfdb4 Remove \Throwable support deprecation layer
  • Loading branch information
nicolas-grekas committed Nov 8, 2019
2 parents 0628892 + ffcfdb4 commit 4cc88b1
Show file tree
Hide file tree
Showing 34 changed files with 67 additions and 113 deletions.
2 changes: 2 additions & 0 deletions UPGRADE-5.0.md
Expand Up @@ -39,6 +39,8 @@ Console
* Removed the `setVerticalBorderChar()` method in favor of the `setVerticalBorderChars()` method in `TableStyle`.
* Removed the `getVerticalBorderChar()` method in favor of the `getBorderChars()` method in `TableStyle`.
* Removed support for returning `null` from `Command::execute()`, return `0` instead
* Renamed `Application::renderException()` and `Application::doRenderException()`
to `renderThrowable()` and `doRenderThrowable()` respectively.
* The `ProcessHelper::run()` method takes the command as an array of arguments.

Before:
Expand Down
Expand Up @@ -52,10 +52,8 @@ public function addLogger(string $name, DebugStack $logger)

/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$queries = [];
foreach ($this->loggers as $name => $logger) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
Expand Up @@ -26,7 +26,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class TwigDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -43,7 +43,7 @@ public function __construct(Profile $profile, Environment $twig = null)
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bridge/Twig/composer.json
Expand Up @@ -51,6 +51,7 @@
"symfony/console": "<4.4",
"symfony/form": "<5.0",
"symfony/http-foundation": "<4.4",
"symfony/http-kernel": "<4.4",
"symfony/translation": "<5.0",
"symfony/workflow": "<4.4"
},
Expand Down
Expand Up @@ -20,7 +20,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class RouterDataCollector extends BaseRouterDataCollector
{
Expand Down
Expand Up @@ -33,7 +33,7 @@
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class SecurityDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -59,7 +59,7 @@ public function __construct(TokenStorageInterface $tokenStorage = null, RoleHier
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if (null === $this->tokenStorage) {
$this->data = [
Expand Down
Expand Up @@ -22,7 +22,7 @@
* @author Aaron Scherer <aequasi@gmail.com>
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*
* @final since Symfony 4.4
* @final
*/
class CacheDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -39,7 +39,7 @@ public function addInstance(string $name, TraceableAdapter $instance)
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []];
$this->data = ['instances' => $empty, 'total' => $empty];
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Cache/composer.json
Expand Up @@ -41,6 +41,7 @@
"conflict": {
"doctrine/dbal": "<2.5",
"symfony/dependency-injection": "<4.4",
"symfony/http-kernel": "<4.4",
"symfony/var-dumper": "<4.4"
},
"autoload": {
Expand Down
61 changes: 0 additions & 61 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -42,7 +42,6 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\ErrorHandler\ErrorHandler;
use Symfony\Component\ErrorHandler\Exception\ErrorException;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Service\ResetInterface;

Expand Down Expand Up @@ -758,79 +757,19 @@ public static function getAbbreviations(array $names)
return $abbrevs;
}

/**
* Renders a caught exception.
*
* @deprecated since Symfony 4.4, use "renderThrowable()" instead
*/
public function renderException(\Exception $e, OutputInterface $output)
{
@trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);

$output->writeln('', OutputInterface::VERBOSITY_QUIET);

$this->doRenderException($e, $output);

$this->finishRenderThrowableOrException($output);
}

public function renderThrowable(\Throwable $e, OutputInterface $output): void
{
if (__CLASS__ !== \get_class($this) && __CLASS__ === (new \ReflectionMethod($this, 'renderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'renderException'))->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);

if (!$e instanceof \Exception) {
$e = class_exists(ErrorException::class) ? new ErrorException($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
}

$this->renderException($e, $output);

return;
}

$output->writeln('', OutputInterface::VERBOSITY_QUIET);

$this->doRenderThrowable($e, $output);

$this->finishRenderThrowableOrException($output);
}

private function finishRenderThrowableOrException(OutputInterface $output): void
{
if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
}
}

/**
* @deprecated since Symfony 4.4, use "doRenderThrowable()" instead
*/
protected function doRenderException(\Exception $e, OutputInterface $output)
{
@trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);

$this->doActuallyRenderThrowable($e, $output);
}

protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
{
if (__CLASS__ !== \get_class($this) && __CLASS__ === (new \ReflectionMethod($this, 'doRenderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'doRenderException'))->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);

if (!$e instanceof \Exception) {
$e = class_exists(ErrorException::class) ? new ErrorException($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
}

$this->doRenderException($e, $output);

return;
}

$this->doActuallyRenderThrowable($e, $output);
}

private function doActuallyRenderThrowable(\Throwable $e, OutputInterface $output): void
{
do {
$message = trim($e->getMessage());
Expand Down
6 changes: 4 additions & 2 deletions src/Symfony/Component/Console/CHANGELOG.md
Expand Up @@ -12,8 +12,10 @@ CHANGELOG
* removed `TableStyle::getVerticalBorderChar()` method in favor of `TableStyle::getBorderChars()`
* removed support for returning `null` from `Command::execute()`, return `0` instead
* `ProcessHelper::run()` accepts only `array|Symfony\Component\Process\Process` for its `command` argument
* `Application::setDispatcher` accepts only `Symfony\Contracts\EventDispatcher\EventDispatcherInterface`
for its `dispatcher` argument
* `Application::setDispatcher` accepts only `Symfony\Contracts\EventDispatcher\EventDispatcherInterface`
for its `dispatcher` argument
* renamed `Application::renderException()` and `Application::doRenderException()`
to `renderThrowable()` and `doRenderThrowable()` respectively.

4.4.0
-----
Expand Down
Expand Up @@ -81,7 +81,7 @@ public function __construct(FormDataExtractorInterface $dataExtractor)
/**
* Does nothing. The data is collected during the form event listeners.
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
}

Expand Down
Expand Up @@ -34,7 +34,7 @@ public function registerClient(string $name, TraceableHttpClient $client)
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->initData();

Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpClient/composer.json
Expand Up @@ -36,6 +36,9 @@
"symfony/service-contracts": "^1.0|^2",
"symfony/var-dumper": "^4.4|^5.0"
},
"conflict": {
"symfony/http-kernel": "<4.4"
},
"autoload": {
"psr-4": { "Symfony\\Component\\HttpClient\\": "" },
"exclude-from-classmap": [
Expand Down
Expand Up @@ -19,11 +19,11 @@
*
* @author Bart van den Burg <bart@burgov.nl>
*
* @final since Symfony 4.4
* @final
*/
class AjaxDataCollector extends DataCollector
{
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
// all collecting is done client side
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -46,7 +46,7 @@ public function setKernel(KernelInterface $kernel = null)
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->data = [
'token' => $response->headers->get('X-Debug-Token'),
Expand Down
Expand Up @@ -24,10 +24,8 @@ interface DataCollectorInterface extends ResetInterface
{
/**
* Collects data for the given Request and Response.
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/);
public function collect(Request $request, Response $response, \Throwable $exception = null);

/**
* Returns the name of the collector.
Expand Down
Expand Up @@ -98,7 +98,7 @@ public function dump(Data $data)
}
}

public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if (!$this->dataCount) {
$this->data = [];
Expand Down
Expand Up @@ -23,7 +23,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class EventDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -40,7 +40,7 @@ public function __construct(EventDispatcherInterface $dispatcher = null, Request
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
$this->data = [
Expand Down
Expand Up @@ -20,14 +20,14 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class ExceptionDataCollector extends DataCollector
{
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if (null !== $exception) {
$this->data = [
Expand Down
Expand Up @@ -22,7 +22,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -44,7 +44,7 @@ public function __construct($logger = null, string $containerPathPrefix = null,
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
}
Expand Down
Expand Up @@ -19,7 +19,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class MemoryDataCollector extends DataCollector implements LateDataCollectorInterface
{
Expand All @@ -31,7 +31,7 @@ public function __construct()
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->updateMemoryUsage();
}
Expand Down
Expand Up @@ -23,7 +23,7 @@
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class RequestDataCollector extends DataCollector implements EventSubscriberInterface, LateDataCollectorInterface
{
Expand All @@ -37,7 +37,7 @@ public function __construct()
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
// attributes are serialized and as they can be anything, they need to be converted to strings.
$attributes = [];
Expand Down
Expand Up @@ -34,9 +34,9 @@ public function __construct()
/**
* {@inheritdoc}
*
* @final since Symfony 4.4
* @final
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if ($response instanceof RedirectResponse) {
$this->data['redirect'] = true;
Expand Down

0 comments on commit 4cc88b1

Please sign in to comment.