Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 59df7bb

Browse files
committed
conditionally generate final method
I incorrectly removed this in 941b0b1
1 parent 895fb7d commit 59df7bb

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/RouterCodegenBuilder.hack

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,27 @@ final class RouterCodegenBuilder<T as IncludeInUriMap> {
8181

8282
private function getCodegenClass(
8383
string $classname,
84-
): CodegenClass{
85-
$class = ($this->cg->codegenClass($classname)
84+
): CodegenClass {
85+
return $this->cg->codegenClass($classname)
86+
->setIsAbstract($this->createAbstract)
87+
->setIsFinal(!$this->createAbstract)
8688
->setExtends(\sprintf(
8789
"\\%s<classname<\\%s>>",
8890
BaseRouter::class,
8991
$this->responderClass,
9092
))
9193
->addMethod(
9294
$this->cg->codegenMethod('getRoutes')
95+
// method should be final only if the class is not already final
96+
->setIsFinal($this->createAbstract)
9397
->setIsOverride(true)
9498
->setReturnTypef(
9599
'ImmMap<\\%s, ImmMap<string, classname<\\%s>>>',
96100
HttpMethod::class,
97101
$this->responderClass,
98102
)
99103
->setBody($this->getUriMapBody())
100-
)
101-
);
102-
103-
$abstract = $this->createAbstract;
104-
$class->setIsAbstract($abstract);
105-
$class->setIsFinal(!$abstract);
106-
return $class;
104+
);
107105
}
108106

109107
private function getUriMapBody(): string {

0 commit comments

Comments
 (0)