1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SLLH\ComposerVersionsCheck; |
4
|
|
|
|
5
|
|
|
use Composer\Command\DependsCommand; |
6
|
|
|
use Composer\Composer; |
7
|
|
|
use Composer\DependencyResolver\Pool; |
8
|
|
|
use Composer\IO\ConsoleIO; |
9
|
|
|
use Composer\Package\PackageInterface; |
10
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
11
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
12
|
|
|
use Symfony\Component\Console\Input\StringInput; |
13
|
|
|
use Symfony\Component\Console\Output\BufferedOutput; |
14
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Depends command wrapper class to get needed output. |
18
|
|
|
* |
19
|
|
|
* @author Sullivan Senechal <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
final class DependsCommandWrapper |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var OutputInterface |
25
|
|
|
*/ |
26
|
|
|
private $output; |
27
|
|
|
|
28
|
|
|
private $composer; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var DependsCommand |
32
|
|
|
*/ |
33
|
|
|
private $dependsCommand; |
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param Composer $composer |
37
|
|
|
* @param bool $decoratedOutput |
38
|
|
|
*/ |
39
|
|
|
public function __construct(Composer $composer, $decoratedOutput = false) |
40
|
|
|
{ |
41
|
|
|
// TODO: Pass the repository instead |
42
|
|
|
$this->composer = $composer; |
43
|
|
|
|
44
|
|
|
//$this->dependsCommand = new DependsCommand(); |
|
|
|
|
45
|
|
|
//$this->dependsCommand->setComposer($composer); |
|
|
|
|
46
|
|
|
|
47
|
|
|
$this->output = new BufferedOutput(); |
48
|
|
|
$this->output->setDecorated($decoratedOutput); |
49
|
|
|
|
50
|
|
|
//$this->dependsCommand->setIO(new ConsoleIO(new StringInput('depends'), $this->output, new HelperSet())); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param PackageInterface $package |
55
|
|
|
* |
56
|
|
|
* @return string[] The output, array of lines. |
57
|
|
|
*/ |
58
|
|
|
public function dependsOutput(PackageInterface $package) |
59
|
|
|
{ |
60
|
|
|
$pool = new Pool(); |
61
|
|
|
$pool->addRepository($this->composer->getRepositoryManager()->getLocalRepository()); |
62
|
|
|
|
63
|
|
|
$output = array(); |
64
|
|
|
$packages = $pool->whatProvides($package->getName()); |
65
|
|
|
foreach ($packages as $dependent) { |
66
|
|
|
array_push($output, sprintf(' Required by %s (%s)', $dependent->getName(), '?')); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $output; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.