Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] Added Application::reset() #32418

Merged
merged 1 commit into from Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Expand Up @@ -55,6 +55,16 @@ public function getKernel()
return $this->kernel;
}

/**
* {@inheritdoc}
*/
public function reset()
lyrixx marked this conversation as resolved.
Show resolved Hide resolved
{
if ($this->kernel->getContainer()->has('services_resetter')) {
$this->kernel->getContainer()->get('services_resetter')->reset();
}
}

/**
* Runs the current application.
*
Expand Down
10 changes: 9 additions & 1 deletion src/Symfony/Component/Console/Application.php
Expand Up @@ -45,6 +45,7 @@
use Symfony\Component\ErrorCatcher\Exception\FatalThrowableError;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Symfony\Contracts\Service\ResetInterface;

/**
* An Application is the container for a collection of commands.
Expand All @@ -61,7 +62,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Application
class Application implements ResetInterface
{
private $commands = [];
private $wantHelps = false;
Expand Down Expand Up @@ -276,6 +277,13 @@ public function doRun(InputInterface $input, OutputInterface $output)
return $exitCode;
}

/**
* {@inheritdoc}
*/
public function reset()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of an empty reset method? why not implement reset only in the frameworkbundle application?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command::getApplication() returns this very class according to the phpdoc.
With this, phpstan is happy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, please, please, stop with the phpstan mania. We don't care if phpstan is happy or not. This is just a tool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I did it to make @nicolas-grekas happy (see previouses comment) he is not a tools 😅😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason @Tobion is that this method is now part of the semantics of the API exposed by the base Application class. It's a template method (from the template design pattern).

Copy link
Member

@Tobion Tobion Jul 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

template pattern does not apply here. template pattern methods must either be abstract (to force subclasses to implement them) or function as helper method hooks (with can have an empty body). neither is the case here. it's just an empty method providing no functionality. but it's not that important to me.

{
}

public function setHelperSet(HelperSet $helperSet)
{
$this->helperSet = $helperSet;
Expand Down
7 changes: 4 additions & 3 deletions src/Symfony/Component/Console/CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

* added `Question::setTrimmable` default to true to allow the answer to be trimmed
* added method `preventRedrawFasterThan()` and `forceRedrawSlowerThan()` on `ProgressBar`
* `Application` implements `ResetInterface`

4.3.0
-----
Expand Down Expand Up @@ -38,7 +39,7 @@ CHANGELOG

* `OutputFormatter` throws an exception when unknown options are used
* removed `QuestionHelper::setInputStream()/getInputStream()`
* removed `Application::getTerminalWidth()/getTerminalHeight()` and
* removed `Application::getTerminalWidth()/getTerminalHeight()` and
`Application::setTerminalDimensions()/getTerminalDimensions()`
* removed `ConsoleExceptionEvent`
* removed `ConsoleEvents::EXCEPTION`
Expand All @@ -64,7 +65,7 @@ CHANGELOG
with value optional explicitly passed empty
* added console.error event to catch exceptions thrown by other listeners
* deprecated console.exception event in favor of console.error
* added ability to handle `CommandNotFoundException` through the
* added ability to handle `CommandNotFoundException` through the
`console.error` event
* deprecated default validation in `SymfonyQuestionHelper::ask`

Expand All @@ -80,7 +81,7 @@ CHANGELOG
-----

* added truncate method to FormatterHelper
* added setColumnWidth(s) method to Table
* added setColumnWidth(s) method to Table

2.8.3
-----
Expand Down