Skip to content

Commit

Permalink
remove additional method in favour of variable parameters in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
maglnet committed Oct 11, 2018
1 parent 326308f commit 266391f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/ComposerRequireChecker/Cli/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln("The following unknown symbols were found:");
$table = new Table($output);
$table->setHeaders(['unknown symbol', 'guessed dependency']);
$guesser = new DependencyGuesser();
$guesser->addGuesser(new GuessFromComposerAutoloader($composerJson));
$guesser = new DependencyGuesser(new GuessFromComposerAutoloader($composerJson));
foreach ($unknownSymbols as $unknownSymbol) {
$guessedDependencies = [];
foreach ($guesser($unknownSymbol) as $guessedDependency) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ class DependencyGuesser
*/
private $guessers = [];

public function __construct()
public function __construct(GuesserInterface ...$guessers)
{
$this->guessers[] = new GuessFromLoadedExtensions();
}

public function addGuesser(GuesserInterface $guesser): void
{
$this->guessers[] = $guesser;
foreach ($guessers as $guesser) {
$this->guessers[] = $guesser;
}
}

public function __invoke($symbolName): \Generator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ComposerRequireCheckerTest\DependencyGuesser;


use ComposerRequireChecker\DependencyGuesser\DependencyGuesser;
use ComposerRequireChecker\DependencyGuesser\GuessFromComposerAutoloader;
use PhpParser\ParserFactory;
use PHPUnit\Framework\TestCase;
Expand All @@ -11,15 +12,14 @@ class GuessFromComposerAutoloaderTest extends TestCase
{

/**
* @var GuessFromComposerAutoloader
* @var DependencyGuesser
*/
private $guesser;

public function setUp()
{
parent::setUp();
$dir = dirname(__DIR__, 3);
$this->guesser = new GuessFromComposerAutoloader($dir . '/composer.json');
$this->guesser = new DependencyGuesser(new GuessFromComposerAutoloader($dir . '/composer.json'));
}

public function testClassWillBeFound()
Expand Down

0 comments on commit 266391f

Please sign in to comment.