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

Commit 402f33a

Browse files
committed
Use definition-finder 2.7
1 parent 2cb8427 commit 402f33a

9 files changed

+69
-69
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"facebook/hack-router": "^0.18",
99
"facebook/hack-http-request-response-interfaces": "^0.2",
1010
"facebook/hack-codegen": "^4.1.0",
11-
"facebook/definition-finder": "^2.0",
11+
"facebook/definition-finder": "^2.7",
1212
"hhvm/type-assert": "^3.0"
1313
},
1414
"require-dev": {
15-
"hhvm/hhast": "^4.0",
15+
"hhvm/hhast": "^4.6",
1616
"hhvm/hhvm-autoload": "^2.0",
1717
"hhvm/hacktest": "^1.1",
1818
"facebook/fbexpect": "^2.1",

src/uriparameters/spec/EnumParameterCodegenSpec.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class EnumParameterCodegenSpec extends UriParameterCodegenSpec {
2121
$param->getName(),
2222
\get_class($param),
2323
);
24-
return $param;
24+
return /* HH_FIXME[4110] unsafe generic */ $param;
2525
}
2626

2727
private static function getType(

tests/ControllerFactsTest.hack

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,81 +52,81 @@ final class ControllerFactsTest extends \Facebook\HackTest\HackTest {
5252
);
5353
}
5454

55-
public function testMappableDirectly(): void {
55+
public async function testMappableDirectly(): Awaitable<void> {
5656
$code =
5757
"<?hh\n".
5858
"final class MyController\n".
5959
"implements Facebook\HackRouter\IncludeInUriMap {}";
60-
$scanned = FileParser::fromData($code, __FUNCTION__);
60+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
6161
$class = $scanned->getClass('MyController');
6262
$facts = $this->getFacts($scanned);
6363
expect($this->isMappable($facts, $class))->toBeTrue();
6464
}
6565

66-
public function testMappableDirectlyFromNamespace(): void {
66+
public async function testMappableDirectlyFromNamespace(): Awaitable<void> {
6767
$code =
6868
"<?hh\n".
6969
"namespace MySite;\n".
7070
"final class MyController\n".
7171
"implements \Facebook\HackRouter\IncludeInUriMap {}";
72-
$scanned = FileParser::fromData($code, __FUNCTION__);
72+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
7373
$class = $scanned->getClass('MySite\MyController');
7474
$facts = $this->getFacts($scanned);
7575
expect($this->isMappable($facts, $class))->toBeTrue();
7676
}
7777

78-
public function testMappableDirectlyWithPrecedingBackSlash(): void {
78+
public async function testMappableDirectlyWithPrecedingBackSlash(): Awaitable<void> {
7979
$code =
8080
"<?hh\n".
8181
"final class MyController\n".
8282
"implements \Facebook\HackRouter\IncludeInUriMap {}";
83-
$scanned = FileParser::fromData($code, __FUNCTION__);
83+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
8484
$class = $scanned->getClass('MyController');
8585
$facts = $this->getFacts($scanned);
8686
expect($this->isMappable($facts, $class))->toBeTrue();
8787
}
8888

89-
public function testMappableDirectlyWithUsedInterface(): void {
89+
public async function testMappableDirectlyWithUsedInterface(): Awaitable<void> {
9090
$code =
9191
"<?hh\n".
9292
"use \Facebook\HackRouter\IncludeInUriMap;\n".
9393
"final class MyController implements IncludeInUriMap {}";
94-
$scanned = FileParser::fromData($code, __FUNCTION__);
94+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
9595
$class = $scanned->getClass('MyController');
9696
$facts = $this->getFacts($scanned);
9797
expect($this->isMappable($facts, $class))->toBeTrue();
9898
}
9999

100-
public function testAbstractIsNotMappable(): void {
100+
public async function testAbstractIsNotMappable(): Awaitable<void> {
101101
$code =
102102
"<?hh\n".
103103
"abstract class MyController\n".
104104
"implements Facebook\HackRouter\IncludeInUriMap {}";
105-
$scanned = FileParser::fromData($code, __FUNCTION__);
105+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
106106
$class = $scanned->getClass('MyController');
107107
$facts = $this->getFacts($scanned);
108108
expect($this->isMappable($facts, $class))->toBeFalse();
109109
}
110110

111-
public function testNoNonFinalNonAbstract(): void {
112-
expect(() ==> {
111+
public async function testNoNonFinalNonAbstract(): Awaitable<void> {
112+
expect(async () ==> {
113113
$code = "<?hh\n".
114114
"class MyController\n".
115115
"implements Facebook\HackRouter\IncludeInUriMap {}";
116-
$scanned = FileParser::fromData($code, __FUNCTION__);
116+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
117117
$class = $scanned->getClass('MyController');
118118
$facts = $this->getFacts($scanned);
119119
$_throws = $this->isMappable($facts, $class);
120120
})->toThrow(InvariantException::class);
121121
}
122122

123-
public function testMappableByParentClass(): void {
123+
public async function testMappableByParentClass(): Awaitable<void> {
124124
$code =
125125
"<?hh\n".
126126
"abstract class BaseController\n".
127127
"implements Facebook\HackRouter\IncludeInUriMap {}\n".
128128
"final class MyController extends BaseController {}";
129-
$scanned = FileParser::fromData($code, __FUNCTION__);
129+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
130130
$base = $scanned->getClass('BaseController');
131131
$final = $scanned->getClass('MyController');
132132

@@ -135,14 +135,14 @@ final class ControllerFactsTest extends \Facebook\HackTest\HackTest {
135135
expect($this->isMappable($facts, $base))->toBeFalse();
136136
}
137137

138-
public function testMappableByParentClassInNamespace(): void {
138+
public async function testMappableByParentClassInNamespace(): Awaitable<void> {
139139
$code =
140140
"<?hh\n".
141141
"namespace Foo\Bar;\n".
142142
"abstract class BaseController\n".
143143
"implements \Facebook\HackRouter\IncludeInUriMap {}\n".
144144
"final class MyController extends BaseController {}";
145-
$scanned = FileParser::fromData($code, __FUNCTION__);
145+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
146146
$base = $scanned->getClass('Foo\\Bar\\BaseController');
147147
$final = $scanned->getClass('Foo\\Bar\\MyController');
148148

@@ -151,42 +151,42 @@ final class ControllerFactsTest extends \Facebook\HackTest\HackTest {
151151
expect($this->isMappable($facts, $base))->toBeFalse();
152152
}
153153

154-
public function testMappableByDerivedInterface(): void {
154+
public async function testMappableByDerivedInterface(): Awaitable<void> {
155155
$code =
156156
"<?hh\n".
157157
"interface IController\n".
158158
"extends Facebook\HackRouter\IncludeInUriMap {}\n".
159159
"final class MyController implements IController {}";
160-
$scanned = FileParser::fromData($code, __FUNCTION__);
160+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
161161
$class = $scanned->getClass('MyController');
162162

163163
$facts = $this->getFacts($scanned);
164164
expect($this->isMappable($facts, $class))->toBeTrue();
165165
}
166166

167-
public function testMappableByTrait(): void {
167+
public async function testMappableByTrait(): Awaitable<void> {
168168
$code =
169169
"<?hh\n".
170170
"trait TController\n".
171171
"implements Facebook\HackRouter\IncludeInUriMap {}\n".
172172
"final class MyController {\n".
173173
" use TController;\n".
174174
"}";
175-
$scanned = FileParser::fromData($code, __FUNCTION__);
175+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
176176
$class = $scanned->getClass('MyController');
177177

178178
$facts = $this->getFacts($scanned);
179179
expect($this->isMappable($facts, $class))->toBeTrue();
180180
}
181181

182-
public function testGetController(): void {
182+
public async function testGetController(): Awaitable<void> {
183183
$code =
184184
"<?hh\n".
185185
"final class MyController implements\n".
186186
"\Facebook\HackRouter\IncludeInUriMap,\n".
187187
"\Facebook\HackRouter\SupportsGetRequests {\n".
188188
"}";
189-
$scanned = FileParser::fromData($code, __FUNCTION__);
189+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
190190
$class = $scanned->getClass('MyController');
191191

192192
$facts = $this->getFacts($scanned);
@@ -195,14 +195,14 @@ final class ControllerFactsTest extends \Facebook\HackTest\HackTest {
195195
);
196196
}
197197

198-
public function testPostController(): void {
198+
public async function testPostController(): Awaitable<void> {
199199
$code =
200200
"<?hh\n".
201201
"final class MyController implements\n".
202202
"\Facebook\HackRouter\IncludeInUriMap,\n".
203203
"\Facebook\HackRouter\SupportsPostRequests {\n".
204204
"}";
205-
$scanned = FileParser::fromData($code, __FUNCTION__);
205+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
206206
$class = $scanned->getClass('MyController');
207207

208208
$facts = $this->getFacts($scanned);
@@ -211,28 +211,28 @@ final class ControllerFactsTest extends \Facebook\HackTest\HackTest {
211211
);
212212
}
213213

214-
public function testGetAndPostController(): void {
215-
expect(() ==> {
214+
public async function testGetAndPostController(): Awaitable<void> {
215+
expect(async () ==> {
216216
$code = "<?hh\n".
217217
"final class MyController implements\n".
218218
"\Facebook\HackRouter\IncludeInUriMap,\n".
219219
"\Facebook\HackRouter\SupportsGetRequests,\n".
220220
"\Facebook\HackRouter\SupportsPostRequests {\n".
221221
"}";
222-
$scanned = FileParser::fromData($code, __FUNCTION__);
222+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
223223
$class = $scanned->getClass('MyController');
224224
$facts = $this->getFacts($scanned);
225225
$_throws = $this->getMethods($facts, $class);
226226
})->toThrow(InvariantException::class);
227227
}
228228

229-
public function testControllerWithNoSupportedMethods(): void {
230-
expect(() ==> {
229+
public async function testControllerWithNoSupportedMethods(): Awaitable<void> {
230+
expect(async () ==> {
231231
$code = "<?hh\n".
232232
"final class MyController implements\n".
233233
"\Facebook\HackRouter\IncludeInUriMap {\n".
234234
"}";
235-
$scanned = FileParser::fromData($code, __FUNCTION__);
235+
$scanned = await FileParser::fromDataAsync($code, __FUNCTION__);
236236
$class = $scanned->getClass('MyController');
237237
$facts = $this->getFacts($scanned);
238238
$_throws = $this->getMethods($facts, $class);

tests/RequestParametersCodegenBuilderTest.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class RequestParametersCodegenBuilderTest extends BaseCodegenTestCase {
4343
);
4444
}
4545

46-
protected function rebuild(): void {
46+
protected async function rebuildAsync(): Awaitable<void> {
4747
$this->getBuilder()->renderToFile(
4848
self::CODEGEN_PATH,
4949
shape(

tests/RouterCLILookupCodegenBuilderTest.hack

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class RouterCLILookupCodegenBuilderTest extends BaseCodegenTestCase {
2323
const string CODEGEN_NS =
2424
"Facebook\\HackRouter\\CodeGen\\Tests\\Generated";
2525

26-
protected function rebuild(): void {
26+
protected async function rebuildAsync(): Awaitable<void> {
2727
(new RouterCLILookupCodegenBuilder(
2828
$this->getCodegenConfig(),
2929
))->renderToFile(
@@ -34,8 +34,8 @@ final class RouterCLILookupCodegenBuilderTest extends BaseCodegenTestCase {
3434
);
3535
}
3636

37-
public function testCanLookupExampleController(): void {
38-
$this->rebuild();
37+
public async function testCanLookupExampleController(): Awaitable<void> {
38+
await $this->rebuildAsync();
3939

4040
$path = GetRequestExampleController::getPath(shape(
4141
'MyString' => 'foo',
@@ -63,8 +63,8 @@ final class RouterCLILookupCodegenBuilderTest extends BaseCodegenTestCase {
6363
expect($output)->toMatchRegExp('/^GET:.+GetRequestExampleController$/m');
6464
}
6565

66-
public function testCantLookupInvalidPath(): void {
67-
$this->rebuild();
66+
public async function testCantLookupInvalidPath(): Awaitable<void> {
67+
await $this->rebuildAsync();
6868

6969
$exit_code = 0;
7070
$output = [];

tests/RouterCodegenBuilderTest.hack

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ final class RouterCodegenBuilderTest extends BaseCodegenTestCase {
2929
const string CODEGEN_NS =
3030
"Facebook\\HackRouter\\CodeGen\\Tests\\Generated";
3131

32-
private function getBuilder(
33-
): RouterCodegenBuilder<GetRequestExampleController> {
34-
$parser = FileParser::fromFile(
32+
private async function getBuilderAsync(
33+
): Awaitable<RouterCodegenBuilder<GetRequestExampleController>> {
34+
$parser = await FileParser::fromFileAsync(
3535
__DIR__.'/examples/GetRequestExampleController.hack',
3636
);
3737
$uri_map_builder = new UriMapBuilder(new ControllerFacts(
@@ -46,8 +46,8 @@ final class RouterCodegenBuilderTest extends BaseCodegenTestCase {
4646
return $router_builder;
4747
}
4848

49-
protected function rebuild(): void {
50-
$builder = $this->getBuilder();
49+
protected async function rebuildAsync(): Awaitable<void> {
50+
$builder = await $this->getBuilderAsync();
5151
$builder->renderToFile(
5252
self::CODEGEN_PATH,
5353
self::CODEGEN_NS,
@@ -69,56 +69,56 @@ final class RouterCodegenBuilderTest extends BaseCodegenTestCase {
6969
return $class->render();
7070
}
7171

72-
public function testMapOnlyContainsUsedMethods(): void {
73-
$code = $this->renderToString($this->getBuilder());
72+
public async function testMapOnlyContainsUsedMethods(): Awaitable<void> {
73+
$code = $this->renderToString(await $this->getBuilderAsync());
7474
expect($code)->toContain('HttpMethod::GET');
7575
expect($code)->toNotContain('HttpMethod::POST');
7676
}
7777

78-
public function testDefaultGeneratedFrom(): void {
79-
$code = $this->renderToString($this->getBuilder());
78+
public async function testDefaultGeneratedFrom(): Awaitable<void> {
79+
$code = $this->renderToString(await $this->getBuilderAsync());
8080
expect($code)->toContain('To re-generate this file run');
8181
expect($code)->toContain('vendor/hhvm/hacktest/bin/hacktest');
8282
}
8383

84-
public function testOverriddenGeneratedFrom(): void {
84+
public async function testOverriddenGeneratedFrom(): Awaitable<void> {
8585
$code = $this->renderToString(
86-
$this->getBuilder()->setGeneratedFrom(
86+
(await $this->getBuilderAsync())->setGeneratedFrom(
8787
$this->getCodegenFactory()->codegenGeneratedFromClass(self::class),
8888
),
8989
);
9090
expect($code)->toContain('Generated from '.RouterCodegenBuilder::class);
9191
}
9292

93-
public function testCreatesFinalByDefault(): void {
94-
$code = $this->renderToString($this->getBuilder());
95-
$parser = FileParser::fromData($code);
93+
public async function testCreatesFinalByDefault(): Awaitable<void> {
94+
$code = $this->renderToString(await $this->getBuilderAsync());
95+
$parser = await FileParser::fromDataAsync($code);
9696
$class = $parser->getClass(MySiteRouter::class);
9797
expect($class->isFinal())->toBeTrue('should be final');
9898
expect($class->isAbstract())->toBeFalse('should not be abstract');
9999
}
100100

101-
public function testCanCreateAbstract(): void {
101+
public async function testCanCreateAbstract(): Awaitable<void> {
102102
$code = $this->renderToString(
103-
$this->getBuilder()->setCreateAbstractClass(true),
103+
(await $this->getBuilderAsync())->setCreateAbstractClass(true),
104104
);
105-
$parser = FileParser::fromData($code);
105+
$parser = await FileParser::fromDataAsync($code);
106106
$class = $parser->getClass(MySiteRouter::class);
107107
expect($class->isAbstract())->toBeTrue('should be abstract');
108108
expect($class->isFinal())->toBeFalse('should not be final');
109109
}
110110

111-
public function testIsStrict(): void {
111+
public async function testIsStrict(): Awaitable<void> {
112112
expect(
113113
Str\starts_with(
114-
$this->renderToString($this->getBuilder()),
114+
$this->renderToString(await $this->getBuilderAsync()),
115115
"<?hh // strict\n",
116116
),
117117
)->toBeTrue();
118118
}
119119

120-
public function testSuccessfullyMaps(): void {
121-
$this->rebuild();
120+
public async function testSuccessfullyMaps(): Awaitable<void> {
121+
await $this->rebuildAsync();
122122
/* HH_IGNORE_ERROR[1002] intentionally using require_once outside of
123123
* top-level */
124124
require_once(self::CODEGEN_PATH);

tests/TestTypechecksTestTrait.hack

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use function Facebook\FBExpect\expect;
1313
trait TestTypechecksTestTrait {
1414
require extends \Facebook\HackTest\HackTest;
1515

16-
abstract protected function rebuild(): void;
16+
abstract protected function rebuildAsync(): Awaitable<void>;
1717

18-
final public function testTypechecks(): void {
19-
$this->rebuild();
18+
final public async function testTypechecks(): Awaitable<void> {
19+
await $this->rebuildAsync();
2020
$exit_code = 0;
2121
$out_array = [];
2222
\exec(

tests/UriBuilderCodegenBuilderTest.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class UriBuilderCodegenBuilderTest extends BaseCodegenTestCase {
3131
);
3232
}
3333

34-
protected function rebuild(): void {
34+
protected async function rebuildAsync(): Awaitable<void> {
3535
$this->getBuilder()->renderToFile(
3636
self::CODEGEN_PATH,
3737
shape(

0 commit comments

Comments
 (0)