/** * Sets default value of argument and marks it as "has default value" * * @param mixed $defaultValue * @throws \BadMethodCallException when argument is nullable * @return self */ public function setDefaultValue($defaultValue) { if ($this->isNullable) { throw new \BadMethodCallException('Cannot set default value for argument since it\'s nullable'); } $this->hasDefaultValue = true; if ($this->type->isTargetType($defaultValue)) { $defaultValue = $this->type->create($defaultValue); } $this->defaultValue = $defaultValue; return $this; }
/** * {@inheritDoc} */ public function isTargetType($value) { if (!$this->isValidData($value)) { return false; } foreach ($value as $entry) { if (!$this->type->isTargetType($entry)) { return false; } } return true; }