Skip to content

Commit

Permalink
Fix PHPStan complaining by using isset() + phpunit const $_ENV[''] = …
Browse files Browse the repository at this point in the history
…'true' is actually returned as '1'
  • Loading branch information
belgattitude committed Mar 19, 2019
1 parent 6cc566d commit fc47e28
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/PHPUnitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ public static function main(bool $exit = true) : int
protected function handleArguments(array $argv) : void
{
parent::handleArguments($argv);
if ($_ENV['REGISTER_NO_LEAKS'] ?? '' !== 'true') {
if (! $this->isAutoConfigureEnabled()) {
return;
}

$this->arguments['listeners'] = array_merge(
[new CollectTestExecutionMemoryFootprints()],
$this->arguments['listeners'] ?? []
Expand All @@ -32,9 +31,14 @@ protected function handleArguments(array $argv) : void
protected function createRunner() : TestRunner
{
$testRunner = new TestRunner($this->arguments['loader']);
if ($_ENV['REGISTER_NO_LEAKS'] ?? '' === true) {
if ($this->isAutoConfigureEnabled()) {
$testRunner->addExtension(new CollectTestExecutionMemoryFootprints());
}
return $testRunner;
}

protected function isAutoConfigureEnabled() : bool
{
return isset($_ENV['REGISTER_NO_LEAKS']) && $_ENV['REGISTER_NO_LEAKS'] === '1';
}
}

0 comments on commit fc47e28

Please sign in to comment.