refactor: PHP 8 features

This commit is contained in:
Nuno Maduro
2021-10-24 18:29:59 +01:00
parent e8c2fe6e35
commit 2b687a7269
43 changed files with 283 additions and 635 deletions

View File

@ -29,31 +29,30 @@ final class Coverage implements AddsOutput, HandlesArguments
/**
* Whether should show the coverage or not.
*
* @var bool
*/
public $coverage = false;
public bool $coverage = false;
/**
* The minimum coverage.
*
* @var float
*/
public $coverageMin = 0.0;
public float $coverageMin = 0.0;
/**
* @var OutputInterface
* Creates a new Plugin instance.
*/
private $output;
public function __construct(OutputInterface $output)
public function __construct(private OutputInterface $output)
{
$this->output = $output;
// ..
}
/**
* @param array<int, string> $originals
*
* @return array<int, string>
*/
public function handleArguments(array $originals): array
{
$arguments = array_merge([''], array_values(array_filter($originals, function ($original): bool {
$arguments = [...[''], ...array_values(array_filter($originals, function ($original): bool {
foreach ([self::COVERAGE_OPTION, self::MIN_OPTION] as $option) {
if ($original === sprintf('--%s', $option) || Str::startsWith($original, sprintf('--%s=', $option))) {
return true;
@ -61,7 +60,7 @@ final class Coverage implements AddsOutput, HandlesArguments
}
return false;
})));
}))];
$originals = array_flip($originals);
foreach ($arguments as $argument) {
@ -75,9 +74,9 @@ final class Coverage implements AddsOutput, HandlesArguments
$input = new ArgvInput($arguments, new InputDefinition($inputs));
if ((bool) $input->getOption(self::COVERAGE_OPTION)) {
$this->coverage = true;
$originals[] = '--coverage-php';
$originals[] = \Pest\Support\Coverage::getPath();
$this->coverage = true;
$originals[] = '--coverage-php';
$originals[] = \Pest\Support\Coverage::getPath();
}
if ($input->getOption(self::MIN_OPTION) !== null) {