This repository was archived by the owner on Aug 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,16 @@ public function setManualAttrsID(?string $id = null): this {
3939 return $this ;
4040 }
4141
42+ private bool $allowSubtyping = false ;
43+ public function allowsSubtyping (): bool {
44+ return $this -> allowSubtyping ;
45+ }
46+
47+ public function setAllowsSubtyping (bool $value ): this {
48+ $this -> allowSubtyping = $value ;
49+ return $this ;
50+ }
51+
4252 public function appendToBuilder (HackBuilder $builder ): HackBuilder {
4353 $builder -> addLine(' shape(' )-> indent();
4454
@@ -61,6 +71,10 @@ public function appendToBuilder(HackBuilder $builder): HackBuilder {
6171 -> endManualSection();
6272 }
6373
74+ if ($this -> allowsSubtyping()) {
75+ $builder -> ensureNewLine()-> addLine(' ...' );
76+ }
77+
6478 return $builder -> unindent()-> add(' )' );
6579 }
6680}
Original file line number Diff line number Diff line change 11@generated
2+ !@#$%codegentest:testImplicitSubtyping
3+ shape(
4+ ?'x' => int,
5+ ?'y' => int,
6+ 'url' => string,
7+ ...
8+ )
29!@#$%codegentest:testMultipleNestedShapes
310shape(
411 'test' => shape(
Original file line number Diff line number Diff line change @@ -36,6 +36,20 @@ public function testShapeOptionalFields(): void {
3636 expect_with_context (static :: class , $shape -> render())-> toBeUnchanged();
3737 }
3838
39+ public function testImplicitSubtyping (): void {
40+ $shape = $this
41+ -> getCodegenFactory()
42+ -> codegenShape(
43+ (new CodegenShapeMember (' x' , ' int' ))-> setIsOptional(),
44+ (new CodegenShapeMember (' y' , ' int' ))-> setIsOptional(),
45+ new CodegenShapeMember (' url' , ' string' ),
46+ )
47+ -> setAllowsSubtyping(true );
48+
49+ expect_with_context (static :: class , $shape -> render())-> toBeUnchanged();
50+
51+ }
52+
3953 public function testNestedShape (): void {
4054 $nested = $this
4155 -> getCodegenFactory()
You can’t perform that action at this time.
0 commit comments