Move var_dump() to HNI, kill off variable.idl.json
[hiphop-php.git] / hphp / runtime / ext / std / ext_std_variable.php
blob89298f52c34862202c9ea9da51d8d4f50bd17e0e
1 <?hh
3 namespace {
4 /* Finds whether the given variable is a boolean.
5 */
6 <<__Native>>
7 function is_bool(mixed $var): bool;
9 /* Finds whether the type of the given variable is integer. To test if a
10 * variable is a number or a numeric string (such as form input, which is
11 * always a string), you must use is_numeric().
13 <<__Native>>
14 function is_int(mixed $var): bool;
16 <<__Native>>
17 function is_integer(mixed $var): bool;
19 <<__Native>>
20 function is_long(mixed $var): bool;
22 /* Finds whether the type of the given variable is float. To test if a
23 * variable is a number or a numeric string (such as form input, which is
24 * always a string), you must use is_numeric().
26 <<__Native>>
27 function is_float(mixed $var): bool;
29 <<__Native>>
30 function is_double(mixed $var): bool;
32 <<__Native>>
33 function is_real(mixed $var): bool;
35 /* Finds whether the given variable is numeric. Numeric strings consist of
36 * optional sign, any number of digits, optional decimal part and optional
37 * exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal
38 * notation (0xFF) is allowed too but only without sign, decimal and
39 * exponential part.
41 <<__Native>>
42 function is_numeric(mixed $var): bool;
44 /* Finds whether the type given variable is string.
46 <<__Native>>
47 function is_string(mixed $var): bool;
49 /* Finds whether the given variable is a scalar. Scalar variables are those
50 * containing an integer, float, string or boolean. Types array, object and
51 * resource are not scalar. is_scalar() does not consider resource type
52 * values to be scalar as resources are abstract datatypes which are currently
53 * based on integers. This implementation detail should not be relied upon, as
54 * it may change.
56 <<__Native>>
57 function is_scalar(mixed $var): bool;
59 /* Finds whether the given variable is an array.
61 <<__Native>>
62 function is_array(mixed $var): bool;
64 /* Finds whether the given variable is an object.
66 <<__Native>>
67 function is_object(mixed $var): bool;
69 /* Finds whether the given variable is a resource.
71 <<__Native>>
72 function is_resource(mixed $var): bool;
74 /* Finds whether the given variable is NULL.
76 <<__Native>>
77 function is_null(mixed $var): bool;
79 /* Returns the type of the PHP variable var. Warning Never use gettype() to
80 * test for a certain type, since the returned string may be subject to change
81 * in a future version. In addition, it is slow too, as it involves string
82 * comparison. Instead, use the is_* functions.
84 <<__Native>>
85 function gettype(mixed $v): string;
87 /* This function gets the type of the given resource.
89 <<__Native>>
90 function get_resource_type(resource $handle): string;
92 <<__Native>>
93 function boolval(mixed $var): bool;
95 /* Returns the integer value of var, using the specified base for the
96 * conversion (the default is base 10). intval() should not be used on
97 * objects, as doing so will emit an E_NOTICE level error and return 1.
99 <<__Native>>
100 function intval(mixed $var,
101 int $base = 10): int;
103 /* Gets the float value of var.
105 <<__Native>>
106 function floatval(mixed $var): float;
108 <<__Native>>
109 function doubleval(mixed $var): float;
111 <<__Native>>
112 function strval(mixed $var): string;
114 /* Set the type of variable var to type.
116 <<__Native>>
117 function settype(mixed &$var,
118 string $type): bool;
120 /* print_r() displays information about a variable in a way that's readable by
121 * humans. print_r(), var_dump() and var_export() will also show protected
122 * and private properties of objects with PHP 5. Static class members will not
123 * be shown. Remember that print_r() will move the array pointer to the end.
124 * Use reset() to bring it back to beginning.
126 <<__Native>>
127 function print_r(mixed $expression,
128 bool $ret = false): mixed;
130 <<__Native>>
131 function var_export(mixed $expression,
132 bool $ret = false): mixed;
134 /* Dumps information about a variable
136 * This function displays structured information about one or more expressions
137 * that includes its type and value. Arrays and objects are explored
138 * recursively with values indented to show structure.
140 * @param mixed $var - Variable to dump
142 /* Dumps a string representation of an internal zend value to output.
144 <<__Native>>
145 function var_dump(mixed $arg1, ...$argv): void;
147 <<__Native>>
148 function debug_zval_dump(mixed $variable): void;
150 /* Generates a storable representation of a value This is useful for storing
151 * or passing PHP values around without losing their type and structure. To
152 * make the serialized string into a PHP value again, use unserialize().
154 <<__Native>>
155 function serialize(mixed $value): string;
157 <<__Native>>
158 function unserialize(string $str,
159 array $class_whitelist = []): mixed;
161 /* This function returns a multidimensional array containing a list of all
162 * defined variables, be they environment, server or user-defined
163 * variables, within the scope in which get_defined_vars() is called.
165 <<__Native>>
166 function get_defined_vars(): array;
168 /* Imports GET/POST/Cookie variables into the global scope. It is useful if
169 * you disabled register_globals, but would like to see some variables in the
170 * global scope. If you're interested in importing other variables into the
171 * global scope, such as $_SERVER, consider using extract().
173 function import_request_variables(string $types,
174 string $prefix = ""): bool {
175 throw new Exception("It is bad coding practice to remove scoping of ".
176 "variables just to achieve coding convenience, ".
177 "esp. in a language that encourages global ".
178 "variables. This is possible to implement ".
179 "though, by declaring those global variables ".
180 "beforehand and assign with scoped ones when ".
181 "this function is called.");
184 /* Import variables from an array into the current symbol table. Checks each
185 * key to see whether it has a valid variable name. It also checks for
186 * collisions with existing variables in the symbol table.
188 <<__Native>>
189 function extract(mixed &$var_array,
190 int $extract_type = EXTR_OVERWRITE,
191 string $prefix = ""): int;
194 * Parses str as if it were the query string passed via a URL and sets
195 * variables in the current scope.
197 * To get the current QUERY_STRING, you may use the variable
198 * $_SERVER['QUERY_STRING']. Also, you may want to read the section on
199 * variables from external sources.
201 * The magic_quotes_gpc setting affects the output of this function, as
202 * parse_str() uses the same mechanism that PHP uses to populate the $_GET,
203 * $_POST, etc. variables.
205 <<__Native>>
206 function parse_str(string $str, mixed &$arr = null): void;
211 * Several of the above functions can affect the variable environment of the
212 * their caller. In order to allow the JIT to make more aggressive
213 * optimizations, we have an option that disables dynamic calls to these
214 * functions---to make that work, non-dynamic calls are rewritten to call these
215 * __SystemLib versions, which are still allowed to modify the caller variable
216 * environment when the option is enabled.
218 namespace __SystemLib {
219 <<__Native>>
220 function extract(mixed &$var_array,
221 int $extract_type = EXTR_OVERWRITE,
222 string $prefix = ""): int;
224 <<__Native>>
225 function get_defined_vars(): array;
227 <<__Native>>
228 function parse_str(string $str, mixed &$arr = null): void;