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?
Value read:
phpbench/lib/Benchmark/RunnerConfig.php
Lines 142 to 148 in 0989c35
$defaultparam is null be default. But return type is array.Value write:
phpbench/lib/Benchmark/RunnerConfig.php
Lines 286 to 294 in 0989c35
$iterationsparam is null by default. So the new instance can have$iterations === nullproperty.In my opinion it must look like this:
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?