Skip to content

Commit 8bb41c5

Browse files
committed
fix: remove unnecessary Composer instantiation
Doing this appears to have cleared up some proc_open() errors I was seeing when requiring this package in other libraries and running any composer commands.
1 parent d510b0d commit 8bb41c5

File tree

2 files changed

+15
-48
lines changed

2 files changed

+15
-48
lines changed

CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2121
### Security
2222

2323

24+
## [1.0.3] - 2020-08-26
25+
26+
### Fixed
27+
28+
* remove unnecessary Composer instantiation
29+
30+
This appears to fix `proc_open()` errors seen after requiring the
31+
package and running any `composer` command.
32+
33+
2434
## [1.0.2] - 2020-08-25
2535

2636
### Fixed
@@ -42,7 +52,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4252
* create a REPL plugin for Composer
4353

4454

45-
[Unreleased]: https://github.com/ramsey/composer-repl/compare/1.0.2...HEAD
55+
[Unreleased]: https://github.com/ramsey/composer-repl/compare/1.0.3...HEAD
56+
[1.0.3]: https://github.com/ramsey/composer-repl/compare/1.0.2...1.0.3
4657
[1.0.2]: https://github.com/ramsey/composer-repl/compare/1.0.1...1.0.2
4758
[1.0.1]: https://github.com/ramsey/composer-repl/compare/1.0.0...1.0.1
4859
[1.0.0]: https://github.com/ramsey/composer-repl/commits/1.0.0

src/Composer/ReplPlugin.php

+3-47
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@
2525
use Composer\Command\BaseCommand;
2626
use Composer\Composer;
2727
use Composer\Factory;
28-
use Composer\IO\ConsoleIO;
2928
use Composer\IO\IOInterface;
3029
use Composer\Plugin\Capability\CommandProvider;
3130
use Composer\Plugin\Capable;
3231
use Composer\Plugin\PluginInterface;
3332
use Ramsey\Dev\Repl\Process\ProcessFactory;
34-
use Symfony\Component\Console\Helper\DescriptorHelper;
35-
use Symfony\Component\Console\Helper\FormatterHelper;
36-
use Symfony\Component\Console\Helper\HelperSet;
37-
use Symfony\Component\Console\Helper\ProcessHelper;
38-
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
39-
use Symfony\Component\Console\Input\StringInput;
40-
use Symfony\Component\Console\Output\ConsoleOutput;
4133

4234
use function realpath;
4335

@@ -48,34 +40,13 @@ class ReplPlugin implements Capable, CommandProvider, PluginInterface
4840
{
4941
private ProcessFactory $processFactory;
5042
private string $repoRoot;
51-
private Composer $composer;
5243

53-
/**
54-
* @var mixed[]
55-
*/
56-
private array $capabilityArgs = [];
57-
58-
/**
59-
* Composer\Plugin\PluginManager::getPluginCapability() passes an array to
60-
* the constructor of the capability class, which is this class. We don't
61-
* use this argument, but it's provided here to avoid errors.
62-
*
63-
* @link https://github.com/composer/composer/blob/a5e608fb73f8eeff8f3acc6fb938c15e5310efcb/src/Composer/Plugin/PluginManager.php#L473-L474
64-
*
65-
* @param mixed[] $args
66-
*/
67-
public function __construct(
68-
array $args = [],
69-
?Composer $composer = null,
70-
?IOInterface $io = null,
71-
?ProcessFactory $processFactory = null
72-
) {
44+
public function __construct()
45+
{
7346
$composerFile = (string) Factory::getComposerFile();
7447

75-
$this->capabilityArgs = $args;
7648
$this->repoRoot = (string) realpath(dirname($composerFile));
77-
$this->processFactory = $processFactory ?? new ProcessFactory();
78-
$this->composer = $composer ?? Factory::create($io ?? $this->buildIO(), $composerFile);
49+
$this->processFactory = new ProcessFactory();
7950
}
8051

8152
/**
@@ -109,19 +80,4 @@ public function deactivate(Composer $composer, IOInterface $io): void
10980
public function uninstall(Composer $composer, IOInterface $io): void
11081
{
11182
}
112-
113-
private function buildIO(): ConsoleIO
114-
{
115-
$input = new StringInput('');
116-
$output = new ConsoleOutput();
117-
118-
$helperSet = new HelperSet([
119-
new DescriptorHelper(),
120-
new FormatterHelper(),
121-
new ProcessHelper(),
122-
new SymfonyQuestionHelper(),
123-
]);
124-
125-
return new ConsoleIO($input, $output, $helperSet);
126-
}
12783
}

0 commit comments

Comments
 (0)