Support ~ types on XHP attributes that are enum {'x', 'y'}
[hiphop-php.git] / hphp / hack / src / decl / decl_enum.mli
bloba7b65cdb00c5b21a71c1b24f58e177baddb71ffb
1 (*
2 * Copyright (c) Facebook, Inc. and its affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the "hack" directory of this source tree.
7 *)
9 open Hh_prelude
10 module SN = Naming_special_names
12 type t = {
13 base: Typing_defs.decl_ty;
14 (** Underlying type of the enum, e.g. int or string.
15 For subclasses of Enum, this is the type parameter of Enum.
16 For enum classes, this is HH\MemberOf<E, I>. *)
17 type_: Typing_defs.decl_ty;
18 (** Type containing the enum name.
19 For subclasses of Enum, this is also the type parameter of Enum. *)
20 constraint_: Typing_defs.decl_ty option;
21 (** Reflects what's after the [as] keyword in the enum definition. *)
22 interface: Typing_defs.decl_ty option;
23 (** For enum classes, this is the raw interface I, as provided by the user. *)
26 (** Figures out if a class needs to be treated like an enum. *)
27 val enum_kind :
28 Typing_defs.pos_id ->
29 is_enum_class:bool ->
30 Typing_defs.enum_type option ->
31 Typing_defs.decl_ty option ->
32 get_ancestor:(string -> Typing_defs.decl_phase Typing_defs.ty option) ->
33 t option
35 (** If a class is an Enum, we give all of the constants in the class the type
36 of the Enum. We don't do this for Enum<mixed> and Enum<arraykey>, since
37 that could *lose* type information. *)
38 val rewrite_class :
39 Typing_defs.pos_id ->
40 is_enum_class:bool ->
41 Typing_defs.enum_type option ->
42 Typing_defs.decl_ty option ->
43 get_ancestor:(string -> Typing_defs.decl_phase Typing_defs.ty option) ->
44 Typing_defs.class_const SMap.t ->
45 Typing_defs.class_const SMap.t
47 (** Same as [rewrite_class], but for use when shallow_class_decl is enabled *)
48 val rewrite_class_consts :
49 t option Lazy.t ->
50 (string * Typing_defs.class_const) Sequence.t ->
51 (string * Typing_defs.class_const) Sequence.t