in src/CodegenClass.hack [114:151]
public function addConstructorWrapperFunc(
?Container<string> $params = null,
): this {
// Check if parameters are specified explicitly
$param_full = null;
if ($params) {
$param_full = $params;
} else if ($this->constructor) {
$param_full = $this->constructor->getParameters();
}
if ($param_full !== null) {
// Extract variable names from parameters
$param_names = vec[];
$re = re"/\\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/";
foreach ($param_full as $str) {
foreach (Regex\every_match($str, $re) as $match) {
$param_names[] = $match[0];
}
}
$params_str = Str\join( $param_names, ', ');
$body = 'return new '.$this->getName().'('.$params_str.');';
$this->wrapperFunc = (
new CodegenFunction($this->config, $this->getName())
)
->addParameters($param_full)
->setReturnType($this->getName())
->setBody($body);
} else {
$this->wrapperFunc = (
new CodegenFunction($this->config, $this->getName())
)
->setReturnType($this->getName())
->setBody('return new '.$this->getName().'();');
}
return $this;
}