10
10
namespace Facebook\AutoloadMap ;
11
11
12
12
use Facebook\AutoloadMap\_Private\TypeAssert ;
13
+ use namespace HH\Lib\{C , Vec} ;
13
14
14
15
/* * Create an autoload map from a directory using `ext_factparse`. */
15
16
final class FactParseScanner implements Builder {
16
17
const type TFacts = darray < string , shape (
17
18
' types' => varray < shape (
18
19
' name' => string ,
20
+ ' kindOf' => string ,
19
21
)> ,
20
22
' constants' => varray < string > ,
21
23
' functions' => varray < string > ,
@@ -38,11 +40,12 @@ final class FactParseScanner implements Builder {
38
40
);
39
41
40
42
try {
43
+ $types = TypeAssert \is_array_of_shapes_with_name_field_and_kind (
44
+ $facts [' types' ] ?? vec [],
45
+ ' FactParse types' ,
46
+ );
41
47
$out [$file ] = shape (
42
- ' types' => TypeAssert \is_array_of_shapes_with_name_field (
43
- $facts [' types' ] ?? vec [],
44
- ' FactParse types' ,
45
- ),
48
+ ' types' => $types ,
46
49
' constants' => TypeAssert \is_array_of_strings (
47
50
$facts [' constants' ] ?? vec [],
48
51
' FactParse constants' ,
@@ -56,6 +59,14 @@ final class FactParseScanner implements Builder {
56
59
' FactParse typeAliases' ,
57
60
),
58
61
);
62
+
63
+ // On hhvm >4.160, typeAliases may not be present,
64
+ // we can extract type aliases from `types` where `kindOf` === `typeAlias`.
65
+ if (! C \contains_key ($facts , ' typeAliases' )) {
66
+ $out [$file ][' typeAliases' ] =
67
+ Vec \filter ($types , $shape ==> $shape [' kindOf' ] === ' typeAlias' )
68
+ |> Vec \map ($$, $shape ==> $shape [' name' ]);
69
+ }
59
70
} catch (\ Exception $e ) {
60
71
$error_level = \error_reporting (0 );
61
72
$file_is_empty = \filesize ($file ) === 0 ;
0 commit comments