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

Commit 1f27e21

Browse files
authored
Typecheck with enable_strict_string_concat_interp (#139)
* Typecheck with enable_strict_string_concat_interp Dependencies not ready yet, so CI will fail. * Make CI green for merging * Fix manual edit to codegenned file
1 parent 6d20695 commit 1f27e21

13 files changed

+19
-19
lines changed

.hhconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ disallow_array_literal = true
1313
disallow_silence = true
1414
allowed_decl_fixme_codes=2053,4045
1515
allowed_fixme_codes_strict=2011,2049,2050,2053,4027,4045,4106,4107,4108,4110,4128,4135,4188,4240,4323,4390,4401
16+
; enable_strict_string_concat_interp = true

examples/dorm/CodegenMutator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private function getSaveMethod(): CodegenMethod {
179179
HackBuilderValues::literal(),
180180
)
181181
->addLinef(
182-
'$st = \'update %s set \'.implode(\',\', $pairs).\' where %s=\'.$this->id;',
182+
'$st = \'update %s set \'.implode(\',\', $pairs).\' where %s=\'.$id;',
183183
$this->schema->getTableName(),
184184
$this->schema->getIdField(),
185185
)

examples/dorm/demo/DormUser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public function getBirthday(): ?DateTime {
5353
public function getCountryId(): ?int {
5454
/* BEGIN MANUAL SECTION CountryId */
5555
// You may manually change this section of code
56-
$value = $this->data['country_id'] ?? null;
57-
return $value;
56+
return $this->data['country_id'] ?? null;
5857
/* END MANUAL SECTION */
5958
}
6059

examples/dorm/demo/DormUserMutator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* To re-generate this file run codegen.php DormUserSchema
77
*
88
*
9-
* @partially-generated SignedSource<<cdbb99cace41afb39438c6b6a0ed401f>>
9+
* @partially-generated SignedSource<<cfcc245af5ac1dc449999b80c6e0ecef>>
1010
*/
1111

1212
final class DormUserMutator {
@@ -47,7 +47,7 @@ public function save(): int {
4747
return (int) $conn->lastInsertId();
4848
} else {
4949
$pairs = $quoted->mapWithKey(($field, $value) ==> $field.'='.$value);
50-
$st = 'update user set '.implode(',', $pairs).' where user_id='.$this->id;
50+
$st = 'update user set '.implode(',', $pairs).' where user_id='.$id;
5151
$conn->exec($st);
5252
return $id;
5353
}

src/CodegenClassConstant.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ final class CodegenClassConstant extends CodegenConstantish {
7171
->ensureNewLine()
7272
->addIf($abstract, 'abstract ')
7373
->add('const ')
74-
->addIf($type !== null, $type.' ')
74+
->addIf($type !== null, ($type ?? '').' ')
7575
->add($this->getName())
76-
->addIf($value !== null, ' = '.$value)
76+
->addIf($value !== null, ' = '.($value ?? ''))
7777
->addLine(';');
7878
}
7979
}

src/CodegenConstant.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class CodegenConstant
5757
->addDocBlock($this->getDocBlock())
5858
->ensureNewLine()
5959
->add('const ')
60-
->addIf($type !== null, $type.' ')
60+
->addIf($type !== null, ($type ?? '').' ')
6161
->add($this->getName())
6262
->add(' = '.$value)
6363
->addLine(';');

src/CodegenFile.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ final class CodegenFile {
336336
if ($doc_block !== null && !Str\ends_with($doc_block, "\n")) {
337337
$doc_block .= "\n";
338338
}
339-
$doc_block = $doc_block.$gen_from->render()."\n";
339+
$doc_block = ($doc_block ?? '').$gen_from->render()."\n";
340340
}
341341

342342
$formatter = $this->config->getFormatter();

src/CodegenFunctionish.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ abstract class CodegenFunctionish implements ICodeBuilderRenderer {
151151
$builder = (new HackBuilder($this->config))
152152
->add($keywords)
153153
->addf('%s(%s)', $this->name, Str\join($this->parameters, ', '))
154-
->addIf($this->returnType !== null, ': '.$this->returnType);
154+
->addIf($this->returnType !== null, ': '.($this->returnType ?? ''));
155155

156156
$code = $builder->getCode();
157157

@@ -183,7 +183,7 @@ abstract class CodegenFunctionish implements ICodeBuilderRenderer {
183183
->addLines($parameter_lines)
184184
->unindent()
185185
->add(')')
186-
->addIf($this->returnType !== null, ': '.$this->returnType);
186+
->addIf($this->returnType !== null, ': '.($this->returnType ?? ''));
187187

188188
return $multi_line_builder->getCode();
189189
}

src/CodegenProperty.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ final class CodegenProperty implements ICodeBuilderRenderer {
9696
->addInlineComment($this->comment)
9797
->add($this->getVisibility().' ')
9898
->addIf($this->isStatic, 'static ')
99-
->addIf($this->type !== null, $this->type.' ')
99+
->addIf($this->type !== null, ($this->type ?? '').' ')
100100
->add('$'.$this->name)
101-
->addIf($this->value !== null, ' = '.$value)
101+
->addIf($this->value !== null, ' = '.($value ?? ''))
102102
->addLine(';');
103103
}
104104

src/CodegenTypeConstant.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ final class CodegenTypeConstant
7272
->addIf($abstract, 'abstract ')
7373
->add('const type ')
7474
->add($this->getName())
75-
->addIf($constraint !== null, ' '.$constraint)
76-
->addIf($value !== null, ' = '.$value)
75+
->addIf($constraint !== null, ' '.($constraint ?? ''))
76+
->addIf($value !== null, ' = '.($value ?? ''))
7777
->addLine(';');
7878
}
7979
}

0 commit comments

Comments
 (0)