Skip to content

Commit b8cb022

Browse files
authored
Merge pull request hhvm#157 from fredemmott/setcontexts
Add CodegenFunctionish::setContexts
2 parents 91c7326 + bc54871 commit b8cb022

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/CodegenFunctionish.hack

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ abstract class CodegenFunctionish implements ICodeBuilderRenderer {
8585
return $this;
8686
}
8787

88+
/** Set or remove the contexts.
89+
*
90+
* - if passed `null`, the function or method will not contain a contexts
91+
* declaration, e.g. `function foo(): void {}`; this is equivalent to
92+
* `function foo()[defaults]: void {}`
93+
* - if passed the empty set (e.g. `keyset[]`), the function will have an
94+
* empty contexts declaration, e.g. `function foo()[]: void {}`. This is
95+
* considered to be an approximation of declaration pure functions.
96+
*/
97+
public function setContexts(
98+
?Container<string> $contexts,
99+
): this {
100+
$this->contexts = ($contexts is null) ? null : keyset($contexts);
101+
return $this;
102+
}
103+
88104
public function setReturnType(string $type): this {
89105
return $this->setReturnTypef('%s', $type);
90106
}

0 commit comments

Comments
 (0)