Skip to content

RunnerConfig code inconsistency #1069

@aivchen

Description

@aivchen

Value read:

/**
* Override the number of iterations to execute.
*/
public function getIterations($default = null): array
{
return $this->iterations ?: $default;
}

$default param is null be default. But return type is array.

Value write:

public function withIterations(array $iterations = null): self
{
$this->assertArrayValuesGreaterThanZero($iterations);
$new = clone $this;
$new->iterations = $iterations;
return $new;
}

$iterations param is null by default. So the new instance can have $iterations === null property.

In my opinion it must look like this:

    /**
     * Override the number of iterations to execute.
     */
    public function getIterations(array $default = []): array
    {
        return $this->iterations ?: $default;
    }

    public function withIterations(array $iterations = []): self
    {
        $this->assertArrayValuesGreaterThanZero($iterations);

        $new = clone $this;
        $new->iterations = $iterations;

        return $new;
    }

but it breaks B/C (or we can consider this solution as a bugfix:)))

What's the best way to solve the problem (if it's a problem at all) in your opinion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions