LightArray: do not accept NULL in the constructor

it makes more sense to pass LightArray::ZERO or just use LightArray::fill(0) if a zeroed light array is desired.
This commit is contained in:
Dylan K. Taylor 2020-09-06 16:18:47 +01:00
parent be0cec531a
commit 5fbc842f7a

View File

@ -45,12 +45,12 @@ final class LightArray{
/** @var string */
private $data;
public function __construct(?string $payload){
if($payload !== null and ($len = strlen($payload)) !== 2048){
public function __construct(string $payload){
if(($len = strlen($payload)) !== 2048){
throw new \InvalidArgumentException("Payload size must be 2048 bytes, but got $len bytes");
}
$this->data = $payload ?? self::ZERO;
$this->data = $payload;
$this->collectGarbage();
}