Code quality improvements

This commit is contained in:
Nuno Maduro
2022-09-16 11:27:17 +01:00
parent e9564febaf
commit 45011ebd14
42 changed files with 266 additions and 278 deletions

View File

@ -40,7 +40,7 @@ final class Coverage implements AddsOutput, HandlesArguments
/**
* Creates a new Plugin instance.
*/
public function __construct(private OutputInterface $output)
public function __construct(private readonly OutputInterface $output)
{
// ..
}
@ -52,7 +52,10 @@ final class Coverage implements AddsOutput, HandlesArguments
{
$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))) {
if ($original === sprintf('--%s', $option)) {
return true;
}
if (Str::startsWith($original, sprintf('--%s=', $option))) {
return true;
}
}

View File

@ -32,8 +32,8 @@ final class Init implements HandlesArguments
* Creates a new Plugin instance.
*/
public function __construct(
private TestSuite $testSuite,
private OutputInterface $output
private readonly TestSuite $testSuite,
private readonly OutputInterface $output
) {
// ..
}
@ -43,10 +43,12 @@ final class Init implements HandlesArguments
*/
public function handleArguments(array $arguments): array
{
if (! array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) {
if (! array_key_exists(1, $arguments)) {
return $arguments;
}
if ($arguments[1] !== self::INIT_OPTION) {
return $arguments;
}
unset($arguments[1]);
$this->init();

View File

@ -24,7 +24,7 @@ final class Memory implements AddsOutput, HandlesArguments
* Creates a new Plugin instance.
*/
public function __construct(
private OutputInterface $output
private readonly OutputInterface $output
) {
// ..
}
@ -47,7 +47,7 @@ final class Memory implements AddsOutput, HandlesArguments
if ($this->enabled) {
$this->output->writeln(sprintf(
' <fg=gray;options=bold>Memory:</> <fg=default>%s MB</>',
round(memory_get_usage(true) / pow(1000, 2), 3)
round(memory_get_usage(true) / 1000 ** 2, 3)
));
}

View File

@ -19,7 +19,7 @@ final class Version implements HandlesArguments
* Creates a new Plugin instance.
*/
public function __construct(
private OutputInterface $output
private readonly OutputInterface $output
) {
// ..
}