/** * Create set method. * * @param $name * @param Type $type * * @return Stmt\ClassMethod */ protected function createSetter($name, Type $type) { return new Stmt\ClassMethod($this->getNaming()->getPrefixedMethodName('set', $name), ['type' => Stmt\Class_::MODIFIER_PUBLIC, 'params' => [new Param($this->getNaming()->getPropertyName($name), new Expr\ConstFetch(new Name('null')), $type->getTypeHint())], 'stmts' => [new Expr\Assign(new Expr\PropertyFetch(new Expr\Variable('this'), $this->getNaming()->getPropertyName($name)), new Expr\Variable($this->getNaming()->getPropertyName($name))), new Stmt\Return_(new Expr\Variable('this'))]], ['comments' => [$this->createSetterDoc($name, $type)]]); }