Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .hhconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ enable_experimental_tc_features=shape_field_check,sealed_classes
user_attributes=
disable_primitive_refinement=true
disallow_stringish_magic=true
disallow_array_literal = true
disallow_silence = true
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: required
language: generic
services: docker
env:
- HHVM_VERSION=4.13-latest
- HHVM_VERSION=4.25-latest
- HHVM_VERSION=latest
- HHVM_VERSION=nightly
install:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Hack Codegen is a library for programatically generating Hack code",
"keywords": ["code generation", "Hack"],
"require": {
"hhvm": "^4.13.0",
"hhvm": "^4.25",
"hhvm/hhvm-autoload": "^2.0",
"hhvm/hsl": "^4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/dorm/CodegenDorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private function getGetters(): Vector<CodegenMethod> {
}

private function getDatabaseRowShape(): CodegenShape {
$db_fields = array();
$db_fields = varray[];
foreach ($this->schema->getFields() as $field) {
$type = $field->getType();
if ($type === \DateTime::class) {
Expand Down
2 changes: 1 addition & 1 deletion src/CodegenClassish.hack
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ abstract class CodegenClassish implements ICodeBuilderRenderer {
$generated_from =
$this->generatedFrom ? $this->generatedFrom->render() : null;

$doc_block_parts = \array_filter(array($this->docBlock, $generated_from));
$doc_block_parts = \array_filter(varray[$this->docBlock, $generated_from]);

if ($doc_block_parts) {
$builder->addDocBlock(\implode("\n\n", $doc_block_parts));
Expand Down
2 changes: 1 addition & 1 deletion src/CodegenFile.hack
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ final class CodegenFile {
private function loadExistingFiles(): ?string {
$file_names = $this->otherFileNames;
$file_names[] = $this->fileName;
$all_content = array();
$all_content = varray[];
foreach ($file_names as $file_name) {
if (\file_exists($file_name)) {
$content = Filesystem::readFile($file_name);
Expand Down
2 changes: 1 addition & 1 deletion src/HackfmtFormatter.hack
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class HackfmtFormatter implements ICodegenFormatter {
string $code,
string $_file_name,
): string {
$output = array();
$output = varray[];
$exit_code = null;

$tempnam = \tempnam(
Expand Down
10 changes: 5 additions & 5 deletions src/PartiallyGeneratedCode.hack
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class PartiallyGeneratedCode {
string $existing_code,
?KeyedContainer<string, Traversable<string>> $rekeys = null,
): string {
$merged = array();
$merged = varray[];
$existing = $this->extractManualCode($existing_code);
$generated = $this->iterateCodeSections($this->code);
foreach ($generated as $section) {
Expand Down Expand Up @@ -110,7 +110,7 @@ final class PartiallyGeneratedCode {
* Extract the generated code and returns it as a string.
*/
public function extractGeneratedCode(): string {
$generated = array();
$generated = varray[];
foreach ($this->iterateCodeSections($this->code) as $section) {
list($id, $chunk) = $section;
if ($id === null) {
Expand Down Expand Up @@ -146,12 +146,12 @@ final class PartiallyGeneratedCode {

$seen_ids = keyset[];
$current_id = null;
$chunk = array();
$chunk = varray[];
$lines = \explode("\n", $code);
foreach ($lines as $line) {
if (\strpos($line, self::$manualEnd) !== false) {
yield tuple($current_id, \implode("\n", $chunk));
$chunk = array($line);
$chunk = varray[$line];
$current_id = null;

} else if (\preg_match($begin, $line) === 1) {
Expand All @@ -168,7 +168,7 @@ final class PartiallyGeneratedCode {

$chunk[] = $line;
yield tuple(null, \implode("\n", $chunk));
$chunk = array();
$chunk = varray[];
$current_id = \trim(\preg_replace($begin, '\\1', $line));

if (C\contains($seen_ids, $current_id)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/CodegenPropertyTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class CodegenPropertyTest extends CodegenBaseTest {
->codegenProperty('languages')
->setIsStatic()
->setValue(
array('en' => 'English', 'es' => 'Spanish', 'fr' => 'French'),
darray['en' => 'English', 'es' => 'Spanish', 'fr' => 'French'],
HackBuilderValues::export(),
)
->render();
Expand Down
20 changes: 10 additions & 10 deletions tests/HackBuilderTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ $del."extends SomeBaseClass",
->startIfBlock('$do_that')
->add('return ')
->addValue(
array(1, 2, 3),
varray[1, 2, 3],
HackBuilderValues::valueArray(HackBuilderValues::export()),
)
->closeStatement()
Expand All @@ -286,9 +286,9 @@ $del."extends SomeBaseClass",
public function testSwitchBodyWithReturnsInCaseAndDefault(): void {
// Gosh, I have no idea what names of football shots are!
$players = Vector {
array('name' => 'Ronaldo', 'favorite_shot' => 'freeKick'),
array('name' => 'Messi', 'favorite_shot' => 'slideKick'),
array('name' => 'Maradona', 'favorite_shot' => 'handOfGod'),
darray['name' => 'Ronaldo', 'favorite_shot' => 'freeKick'],
darray['name' => 'Messi', 'favorite_shot' => 'slideKick'],
darray['name' => 'Maradona', 'favorite_shot' => 'handOfGod'],
};

$body = $this
Expand All @@ -313,9 +313,9 @@ $del."extends SomeBaseClass",
public function testSwitchBodyWithBreaksInCaseAndDefault(): void {
// Gosh, I have no idea what names of football shots are!
$players = Vector {
array('name' => 'Ronaldo', 'favorite_shot' => 'freeKick'),
array('name' => 'Messi', 'favorite_shot' => 'slideKick'),
array('name' => 'Maradona', 'favorite_shot' => 'handOfGod'),
darray['name' => 'Ronaldo', 'favorite_shot' => 'freeKick'],
darray['name' => 'Messi', 'favorite_shot' => 'slideKick'],
darray['name' => 'Maradona', 'favorite_shot' => 'handOfGod'],
};

$body = $this
Expand All @@ -340,9 +340,9 @@ $del."extends SomeBaseClass",
public function testSwitchBodyWithMultipleCasesWithoutBreaks(): void {
// Gosh, I have no idea what names of football shots are!
$players = Vector {
array('name' => 'Ronaldo', 'favorite_shot' => 'freeKick'),
array('name' => 'Messi', 'favorite_shot' => 'slideKick'),
array('name' => 'Maradona', 'favorite_shot' => 'handOfGod'),
darray['name' => 'Ronaldo', 'favorite_shot' => 'freeKick'],
darray['name' => 'Messi', 'favorite_shot' => 'slideKick'],
darray['name' => 'Maradona', 'favorite_shot' => 'handOfGod'],
};

$body = $this
Expand Down