public function add($element) { if (!$this->isCorrectType($element)) { throw new IllegalArgumentException("Tried to add element of type " . TypeUtil::getType($element) . " to list of type " . $this->type); } $this->elements[$element] = $element; }
private function isCorrectValueType($value) { if ($this->valueType === "?") { return true; } return $this->valueType === TypeUtil::getType($value); }
protected function isCorrectType($element) { if ($this->type === "?") { return true; } return $this->type === TypeUtil::getType($element); }