private function handleSetter(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
{
$methodBody = '';
$docblock = new DocBlockGenerator();
$docblock->setShortDescription("Sets a new " . $prop->getName());
if ($prop->getDoc()) {
$docblock->setLongDescription($prop->getDoc());
}
$patramTag = new ParamTag($prop->getName());
$docblock->setTag($patramTag);
$return = new ReturnTag("self");
$docblock->setTag($return);
$type = $prop->getType();
$method = new MethodGenerator("set" . Inflector::classify($prop->getName()));
$parameter = new ParameterGenerator($prop->getName(), "mixed");
if ($type && $type instanceof PHPClassOf) {
$patramTag->setTypes($this->getPhpType($type->getArg()->getType()) . "[]");
$parameter->setType("array");
if ($p = $this->isOneType($type->getArg()->getType())) {
if ($t = $p->getType()) {
$patramTag->setTypes($this->getPhpType($t));
}
}
} elseif ($type) {
if ($this->isNativeType($type)) {
$patramTag->setTypes($this->getPhpType($type));
} elseif ($p = $this->isOneType($type)) {
if (($t = $p->getType()) && !$this->isNativeType($t)) {
$patramTag->setTypes($this->getPhpType($t));
$parameter->setType($this->getPhpType($t));
} elseif ($t && !$this->isNativeType($t)) {
$patramTag->setTypes($this->getPhpType($t));
$parameter->setType($this->getPhpType($t));
} elseif ($t) {
$patramTag->setTypes($this->getPhpType($t));
}
} else {
$patramTag->setTypes($this->getPhpType($type));
$parameter->setType($this->getPhpType($type));
}
}
$methodBody .= "\$this->" . $prop->getName() . " = \$" . $prop->getName() . ";" . PHP_EOL;
$methodBody .= "return \$this;";
$method->setBody($methodBody);
$method->setDocBlock($docblock);
$method->setParameter($parameter);
$generator->addMethodFromGenerator($method);
}