Skip to content

Commit

Permalink
Deprecated AbstractCommand (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Nov 19, 2017
1 parent 924c005 commit a5ddbfd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extensions:

```
The extension will look for all commands extending from [`Contributte\Console\Command\AbstractCommand`](https://github.com/contributte/console/blob/master/src/Command/AbstractCommand.php) and automatically add them to the console application.
The extension will look for all commands extending from [`Symfony\Component\Console\Command\Command`](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Command/Command.php) and automatically add them to the console application.
That's all. You don't have to be worried about anything else.

## Configuration
Expand Down Expand Up @@ -87,11 +87,11 @@ From this point, all commands are instanced only if needed. Don't forget, that l
namespace App\Console;
use Contributte\Console\Command\AbstractCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class FooCommand extends AbstractCommand
final class FooCommand extends Command
{
/**
Expand Down
9 changes: 9 additions & 0 deletions src/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@
abstract class AbstractCommand extends Command
{

/**
* @param string|null $name
*/
public function __construct($name = NULL)
{
parent::__construct($name);
trigger_error(sprintf('Extending %s is deprecated, extend %s directly.', self::class, Command::class), E_USER_DEPRECATED);
}

}
2 changes: 1 addition & 1 deletion tests/cases/Command/Command.HelperSet.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Test: Command\AbstractCommand.HelperSet
* Test: Command\Command.HelperSet
*/

use Contributte\Console\DI\ConsoleExtension;
Expand Down
12 changes: 6 additions & 6 deletions tests/cases/DI/ConsoleExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/

use Contributte\Console\Application;
use Contributte\Console\Command\AbstractCommand;
use Contributte\Console\DI\ConsoleExtension;
use Nette\DI\Compiler;
use Nette\DI\Container;
use Nette\DI\ContainerLoader;
use Symfony\Component\Console\Command\Command;
use Tester\Assert;
use Tester\FileMock;
use Tests\Fixtures\FooCommand;
Expand All @@ -26,7 +26,7 @@ test(function () {
/** @var Container $container */
$container = new $class;

Assert::count(0, $container->findByType(AbstractCommand::class));
Assert::count(0, $container->findByType(Command::class));
});

// 1 command of type FooCommand
Expand All @@ -47,8 +47,8 @@ test(function () {

Assert::type(Application::class, $container->getByType(Application::class));
Assert::true($container->isCreated('foo'));
Assert::count(1, $container->findByType(AbstractCommand::class));
Assert::type(FooCommand::class, $container->getByType(AbstractCommand::class));
Assert::count(1, $container->findByType(Command::class));
Assert::type(FooCommand::class, $container->getByType(Command::class));
});

// 1 command of type FooCommand lazy-loading
Expand All @@ -69,6 +69,6 @@ test(function () {

Assert::type(Application::class, $container->getByType(Application::class));
Assert::false($container->isCreated('foo'));
Assert::count(1, $container->findByType(AbstractCommand::class));
Assert::type(FooCommand::class, $container->getByType(AbstractCommand::class));
Assert::count(1, $container->findByType(Command::class));
Assert::type(FooCommand::class, $container->getByType(Command::class));
});
4 changes: 2 additions & 2 deletions tests/fixtures/FooCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Tests\Fixtures;

use Contributte\Console\Command\AbstractCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* @author Milan Felix Sulc <[email protected]>
*/
final class FooCommand extends AbstractCommand
final class FooCommand extends Command
{

/** @var string */
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/HelperSetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Tests\Fixtures;

use Contributte\Console\Command\AbstractCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* @author Milan Felix Sulc <[email protected]>
*/
final class HelperSetCommand extends AbstractCommand
final class HelperSetCommand extends Command
{

/**
Expand Down

0 comments on commit a5ddbfd

Please sign in to comment.