<?php
class integer {
private $value;
public function __construct(int ...$value)
{
switch (count($value)) {
case 0:
break;
case 1:
$this->value = $value[0];
break;
default:
throw new Exception('Multiple values given.');
}
}
public function __invoke(int ...$value) : int
{
switch (count($value)) {
case 0:
break;
case 1:
$this->value = $value[0];
break;
default:
throw new Exception('Multiple values given.');
}
return $this->value;
}
public function __toString() : int {
return $this->value;
}
}
$testi = new integer();
$testi(2);
print_r($testi);
Fatal error: integer::__toString(): Return type must be string when declared in /in/6BZ2Z on line 33
Process exited with code 255.
Output for 8.0.0 - 8.0.13
Fatal error: Declaration of integer::__toString(): int must be compatible with Stringable::__toString(): string in /in/6BZ2Z on line 33
Process exited with code 255.