improve union error message #28
Annotations
30 warnings
PHP 8.1 test on ubuntu-latest:
src/Arguments.php#L60
Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation":
--- Original
+++ New
@@ @@
if ($arguments instanceof ArrayAccess) {
$arguments = $this->getArrayAccessArray($arguments);
}
- if (array_is_list($arguments) && count($arguments) === count($parameters)) {
+ if (!array_is_list($arguments) && count($arguments) === count($parameters)) {
$arguments = array_combine($parameters->keys(), $arguments);
}
$this->setArguments($arguments);
|
PHP 8.1 test on ubuntu-latest:
src/Arguments.php#L61
Escaped Mutant for Mutator "UnwrapArrayCombine":
--- Original
+++ New
@@ @@
$arguments = $this->getArrayAccessArray($arguments);
}
if (array_is_list($arguments) && count($arguments) === count($parameters)) {
- $arguments = array_combine($parameters->keys(), $arguments);
+ $arguments = $arguments;
}
$this->setArguments($arguments);
if ($parameters->keys() === ['K', 'V']) {
|
PHP 8.1 test on ubuntu-latest:
src/Attributes/CallableAttr.php#L29
Escaped Mutant for Mutator "FunctionCallRemoval":
--- Original
+++ New
@@ @@
public function __construct(callable $callable)
{
$return = $callable();
- object(ParameterInterface::class)($return);
+
$this->parameter = $return;
}
public function __invoke(mixed $mixed) : mixed
|
PHP 8.1 test on ubuntu-latest:
src/FloatParameter.php#L38
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
private ?float $max = null;
public function __invoke(float $value) : float
{
- $this->assert($value);
+
return $value;
}
public function withDefault(float $value) : FloatParameterInterface
|
PHP 8.1 test on ubuntu-latest:
src/NullParameter.php#L36
Escaped Mutant for Mutator "Throw_":
--- Original
+++ New
@@ @@
if ($value === null) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type null'));
+ new TypeError((string) message('Argument value provided is not of type null'));
}
/**
* @codeCoverageIgnore
|
PHP 8.1 test on ubuntu-latest:
src/NullParameter.php#L37
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
if ($value === null) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type null'));
+ throw new TypeError(message('Argument value provided is not of type null'));
}
/**
* @codeCoverageIgnore
|
PHP 8.1 test on ubuntu-latest:
src/ObjectParameter.php#L40
Escaped Mutant for Mutator "Throw_":
--- Original
+++ New
@@ @@
if ($this->type->validate($value)) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
+ new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
}
public function setUp() : void
{
|
PHP 8.1 test on ubuntu-latest:
src/ObjectParameter.php#L41
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
if ($this->type->validate($value)) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
+ throw new TypeError(message('Argument value provided is not of type `%type%`', type: $this->className()));
}
public function setUp() : void
{
|
PHP 8.1 test on ubuntu-latest:
src/Traits/NumericParameterTrait.php#L266
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
return $argument;
}
$values = implode(',', $this->reject);
- throw new InvalidArgumentException((string) message('Argument value provided `%provided%` is on rejected list `%value%`', provided: strval($argument), value: "[{$values}]"));
+ throw new InvalidArgumentException(message('Argument value provided `%provided%` is on rejected list `%value%`', provided: strval($argument), value: "[{$values}]"));
}
if ($this->min() !== null && $argument < $this->min()) {
throw new InvalidArgumentException((string) message('Argument value provided `%provided%` is less than `%min%`', provided: strval($argument), min: strval($this->min())));
|
PHP 8.1 test on ubuntu-latest:
src/UnionParameter.php#L59
Escaped Mutant for Mutator "Concat":
--- Original
+++ New
@@ @@
PLAIN;
}
}
- $message = implode(';' . PHP_EOL, $messages);
+ $message = implode(PHP_EOL . ';', $messages);
throw new TypeError((string) message("Argument provided doesn't match union parameter. Error(s): %message%", message: $message));
}
public function withAdded(ParameterInterface ...$parameter) : static
|
PHP 8.2 test on ubuntu-latest:
src/Arguments.php#L60
Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation":
--- Original
+++ New
@@ @@
if ($arguments instanceof ArrayAccess) {
$arguments = $this->getArrayAccessArray($arguments);
}
- if (array_is_list($arguments) && count($arguments) === count($parameters)) {
+ if (!array_is_list($arguments) && count($arguments) === count($parameters)) {
$arguments = array_combine($parameters->keys(), $arguments);
}
$this->setArguments($arguments);
|
PHP 8.2 test on ubuntu-latest:
src/Arguments.php#L61
Escaped Mutant for Mutator "UnwrapArrayCombine":
--- Original
+++ New
@@ @@
$arguments = $this->getArrayAccessArray($arguments);
}
if (array_is_list($arguments) && count($arguments) === count($parameters)) {
- $arguments = array_combine($parameters->keys(), $arguments);
+ $arguments = $arguments;
}
$this->setArguments($arguments);
if ($parameters->keys() === ['K', 'V']) {
|
PHP 8.2 test on ubuntu-latest:
src/Attributes/CallableAttr.php#L29
Escaped Mutant for Mutator "FunctionCallRemoval":
--- Original
+++ New
@@ @@
public function __construct(callable $callable)
{
$return = $callable();
- object(ParameterInterface::class)($return);
+
$this->parameter = $return;
}
public function __invoke(mixed $mixed) : mixed
|
PHP 8.2 test on ubuntu-latest:
src/FloatParameter.php#L38
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
private ?float $max = null;
public function __invoke(float $value) : float
{
- $this->assert($value);
+
return $value;
}
public function withDefault(float $value) : FloatParameterInterface
|
PHP 8.2 test on ubuntu-latest:
src/NullParameter.php#L36
Escaped Mutant for Mutator "Throw_":
--- Original
+++ New
@@ @@
if ($value === null) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type null'));
+ new TypeError((string) message('Argument value provided is not of type null'));
}
/**
* @codeCoverageIgnore
|
PHP 8.2 test on ubuntu-latest:
src/NullParameter.php#L37
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
if ($value === null) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type null'));
+ throw new TypeError(message('Argument value provided is not of type null'));
}
/**
* @codeCoverageIgnore
|
PHP 8.2 test on ubuntu-latest:
src/ObjectParameter.php#L40
Escaped Mutant for Mutator "Throw_":
--- Original
+++ New
@@ @@
if ($this->type->validate($value)) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
+ new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
}
public function setUp() : void
{
|
PHP 8.2 test on ubuntu-latest:
src/ObjectParameter.php#L41
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
if ($this->type->validate($value)) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
+ throw new TypeError(message('Argument value provided is not of type `%type%`', type: $this->className()));
}
public function setUp() : void
{
|
PHP 8.2 test on ubuntu-latest:
src/Traits/NumericParameterTrait.php#L266
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
return $argument;
}
$values = implode(',', $this->reject);
- throw new InvalidArgumentException((string) message('Argument value provided `%provided%` is on rejected list `%value%`', provided: strval($argument), value: "[{$values}]"));
+ throw new InvalidArgumentException(message('Argument value provided `%provided%` is on rejected list `%value%`', provided: strval($argument), value: "[{$values}]"));
}
if ($this->min() !== null && $argument < $this->min()) {
throw new InvalidArgumentException((string) message('Argument value provided `%provided%` is less than `%min%`', provided: strval($argument), min: strval($this->min())));
|
PHP 8.2 test on ubuntu-latest:
src/UnionParameter.php#L59
Escaped Mutant for Mutator "Concat":
--- Original
+++ New
@@ @@
PLAIN;
}
}
- $message = implode(';' . PHP_EOL, $messages);
+ $message = implode(PHP_EOL . ';', $messages);
throw new TypeError((string) message("Argument provided doesn't match union parameter. Error(s): %message%", message: $message));
}
public function withAdded(ParameterInterface ...$parameter) : static
|
PHP 8.3 test on ubuntu-latest:
src/Arguments.php#L60
Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation":
--- Original
+++ New
@@ @@
if ($arguments instanceof ArrayAccess) {
$arguments = $this->getArrayAccessArray($arguments);
}
- if (array_is_list($arguments) && count($arguments) === count($parameters)) {
+ if (!array_is_list($arguments) && count($arguments) === count($parameters)) {
$arguments = array_combine($parameters->keys(), $arguments);
}
$this->setArguments($arguments);
|
PHP 8.3 test on ubuntu-latest:
src/Arguments.php#L61
Escaped Mutant for Mutator "UnwrapArrayCombine":
--- Original
+++ New
@@ @@
$arguments = $this->getArrayAccessArray($arguments);
}
if (array_is_list($arguments) && count($arguments) === count($parameters)) {
- $arguments = array_combine($parameters->keys(), $arguments);
+ $arguments = $arguments;
}
$this->setArguments($arguments);
if ($parameters->keys() === ['K', 'V']) {
|
PHP 8.3 test on ubuntu-latest:
src/Attributes/CallableAttr.php#L29
Escaped Mutant for Mutator "FunctionCallRemoval":
--- Original
+++ New
@@ @@
public function __construct(callable $callable)
{
$return = $callable();
- object(ParameterInterface::class)($return);
+
$this->parameter = $return;
}
public function __invoke(mixed $mixed) : mixed
|
PHP 8.3 test on ubuntu-latest:
src/FloatParameter.php#L38
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
private ?float $max = null;
public function __invoke(float $value) : float
{
- $this->assert($value);
+
return $value;
}
public function withDefault(float $value) : FloatParameterInterface
|
PHP 8.3 test on ubuntu-latest:
src/NullParameter.php#L36
Escaped Mutant for Mutator "Throw_":
--- Original
+++ New
@@ @@
if ($value === null) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type null'));
+ new TypeError((string) message('Argument value provided is not of type null'));
}
/**
* @codeCoverageIgnore
|
PHP 8.3 test on ubuntu-latest:
src/NullParameter.php#L37
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
if ($value === null) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type null'));
+ throw new TypeError(message('Argument value provided is not of type null'));
}
/**
* @codeCoverageIgnore
|
PHP 8.3 test on ubuntu-latest:
src/ObjectParameter.php#L40
Escaped Mutant for Mutator "Throw_":
--- Original
+++ New
@@ @@
if ($this->type->validate($value)) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
+ new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
}
public function setUp() : void
{
|
PHP 8.3 test on ubuntu-latest:
src/ObjectParameter.php#L41
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
if ($this->type->validate($value)) {
return $value;
}
- throw new TypeError((string) message('Argument value provided is not of type `%type%`', type: $this->className()));
+ throw new TypeError(message('Argument value provided is not of type `%type%`', type: $this->className()));
}
public function setUp() : void
{
|
PHP 8.3 test on ubuntu-latest:
src/Traits/NumericParameterTrait.php#L266
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
return $argument;
}
$values = implode(',', $this->reject);
- throw new InvalidArgumentException((string) message('Argument value provided `%provided%` is on rejected list `%value%`', provided: strval($argument), value: "[{$values}]"));
+ throw new InvalidArgumentException(message('Argument value provided `%provided%` is on rejected list `%value%`', provided: strval($argument), value: "[{$values}]"));
}
if ($this->min() !== null && $argument < $this->min()) {
throw new InvalidArgumentException((string) message('Argument value provided `%provided%` is less than `%min%`', provided: strval($argument), min: strval($this->min())));
|
PHP 8.3 test on ubuntu-latest:
src/UnionParameter.php#L59
Escaped Mutant for Mutator "Concat":
--- Original
+++ New
@@ @@
PLAIN;
}
}
- $message = implode(';' . PHP_EOL, $messages);
+ $message = implode(PHP_EOL . ';', $messages);
throw new TypeError((string) message("Argument provided doesn't match union parameter. Error(s): %message%", message: $message));
}
public function withAdded(ParameterInterface ...$parameter) : static
|