PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/std/ext_std_variable.php

http://github.com/facebook/hiphop-php
PHP | 314 lines | 129 code | 50 blank | 135 comment | 0 complexity | c62c3e722b206b249e6a2bf24c37f064 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh // partial
  2. namespace {
  3. /* Finds whether the given variable is a boolean.
  4. */
  5. <<__IsFoldable, __Native, __Rx>>
  6. function is_bool(<<__MaybeMutable>> mixed $var): bool;
  7. /* Finds whether the type of the given variable is integer. To test if a
  8. * variable is a number or a numeric string (such as form input, which is
  9. * always a string), you must use is_numeric().
  10. */
  11. <<__IsFoldable, __Native, __Rx>>
  12. function is_int(<<__MaybeMutable>> mixed $var): bool;
  13. <<__IsFoldable, __Native, __Rx>>
  14. function is_integer(<<__MaybeMutable>> mixed $var): bool;
  15. <<__IsFoldable, __Native, __Rx>>
  16. function is_long(<<__MaybeMutable>> mixed $var): bool;
  17. /* Finds whether the type of the given variable is float. To test if a
  18. * variable is a number or a numeric string (such as form input, which is
  19. * always a string), you must use is_numeric().
  20. */
  21. <<__IsFoldable, __Native, __Rx>>
  22. function is_float(<<__MaybeMutable>> mixed $var): bool;
  23. <<__IsFoldable, __Native, __Rx>>
  24. function is_double(<<__MaybeMutable>> mixed $var): bool;
  25. <<__IsFoldable, __Native, __Rx>>
  26. function is_real(<<__MaybeMutable>> mixed $var): bool;
  27. /* Finds whether the given variable is numeric. Numeric strings consist of
  28. * optional sign, any number of digits, optional decimal part and optional
  29. * exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal
  30. * notation (0xFF) is allowed too but only without sign, decimal and
  31. * exponential part.
  32. */
  33. <<__IsFoldable, __Native, __Rx>>
  34. function is_numeric(<<__MaybeMutable>> mixed $var): bool;
  35. /* Finds whether the type given variable is string.
  36. */
  37. <<__IsFoldable, __Native, __Rx>>
  38. function is_string(<<__MaybeMutable>> mixed $var): bool;
  39. /* Finds whether the given variable is a scalar. Scalar variables are those
  40. * containing an integer, float, string or boolean. Types array, object and
  41. * resource are not scalar. is_scalar() does not consider resource type
  42. * values to be scalar as resources are abstract datatypes which are currently
  43. * based on integers. This implementation detail should not be relied upon, as
  44. * it may change.
  45. */
  46. <<__IsFoldable, __Native, __Rx>>
  47. function is_scalar(<<__MaybeMutable>> mixed $var): bool;
  48. /* Finds whether the given variable is an array.
  49. */
  50. <<__IsFoldable, __Native, __Rx>>
  51. function is_array(<<__MaybeMutable>> mixed $var): bool;
  52. /* Finds whether the given variable is an object.
  53. */
  54. <<__IsFoldable, __Native, __Rx>>
  55. function is_object(<<__MaybeMutable>> mixed $var): bool;
  56. /* Finds whether the given variable is a resource.
  57. */
  58. <<__IsFoldable, __Native, __Rx>>
  59. function is_resource(<<__MaybeMutable>> mixed $var): bool;
  60. /* Finds whether the given variable is NULL.
  61. */
  62. <<__IsFoldable, __Native, __Rx>>
  63. function is_null(<<__MaybeMutable>> mixed $var): bool;
  64. /* Returns the type of the PHP variable var. Warning Never use gettype() to
  65. * test for a certain type, since the returned string may be subject to change
  66. * in a future version. In addition, it is slow too, as it involves string
  67. * comparison. Instead, use the is_* functions.
  68. */
  69. <<__IsFoldable, __Native, __Rx>>
  70. function gettype(<<__MaybeMutable>> mixed $v): string;
  71. /* This function gets the type of the given resource.
  72. */
  73. <<__IsFoldable, __Native, __Rx>>
  74. function get_resource_type(<<__MaybeMutable>> resource $handle): string;
  75. <<__IsFoldable, __Native, __Rx>>
  76. function boolval(mixed $var): bool;
  77. /* Returns the integer value of var, using the specified base for the
  78. * conversion (the default is base 10). intval() should not be used on
  79. * objects, as doing so will emit an E_NOTICE level error and return 1.
  80. */
  81. <<__IsFoldable, __Native, __Rx>>
  82. function intval(mixed $var,
  83. int $base = 10): int;
  84. /* Gets the float value of var.
  85. */
  86. <<__IsFoldable, __Native, __Rx>>
  87. function floatval(mixed $var): float;
  88. <<__IsFoldable, __Native, __Rx>>
  89. function doubleval(mixed $var): float;
  90. <<__IsFoldable, __Native, __Rx>>
  91. function strval(mixed $var): string;
  92. /* print_r() displays information about a variable in a way that's readable by
  93. * humans. print_r(), var_dump() and var_export() will also show protected
  94. * and private properties of objects with PHP 5. Static class members will not
  95. * be shown. Remember that print_r() will move the array pointer to the end.
  96. * Use reset() to bring it back to beginning.
  97. */
  98. <<__Native>>
  99. function print_r(mixed $expression,
  100. bool $ret = false): mixed;
  101. <<__Native>>
  102. function var_export(mixed $expression,
  103. bool $ret = false): mixed;
  104. /* Dumps information about a variable
  105. *
  106. * This function displays structured information about one or more expressions
  107. * that includes its type and value. Arrays and objects are explored
  108. * recursively with values indented to show structure.
  109. *
  110. * @param mixed $var - Variable to dump
  111. */
  112. /* Dumps a string representation of an internal zend value to output.
  113. */
  114. <<__Native("NoFCallBuiltin")>>
  115. function var_dump(mixed $arg1, ...$argv): void;
  116. <<__Native>>
  117. function debug_zval_dump(mixed $variable): void;
  118. /* Generates a storable representation of a value This is useful for storing
  119. * or passing PHP values around without losing their type and structure. To
  120. * make the serialized string into a PHP value again, use unserialize().
  121. *
  122. * Calls to serialize are foldable because only objects can invoke user-defined
  123. * code.
  124. */
  125. <<__IsFoldable, __Native, __Rx>>
  126. function serialize(mixed $value): string;
  127. <<__Native, __Rx>>
  128. function unserialize(string $str,
  129. darray $options = darray[]): mixed;
  130. /* Imports GET/POST/Cookie variables into the global scope. It is useful if
  131. * you disabled register_globals, but would like to see some variables in the
  132. * global scope.
  133. */
  134. function import_request_variables(string $types,
  135. string $prefix = ""): bool {
  136. throw new Exception("It is bad coding practice to remove scoping of ".
  137. "variables just to achieve coding convenience, ".
  138. "esp. in a language that encourages global ".
  139. "variables. This is possible to implement ".
  140. "though, by declaring those global variables ".
  141. "beforehand and assign with scoped ones when ".
  142. "this function is called.");
  143. }
  144. /*
  145. * Parses str as if it were the query string passed via a URL and sets $arr.
  146. *
  147. * To get the current QUERY_STRING, you may use the variable
  148. * $_SERVER['QUERY_STRING']. Also, you may want to read the section on
  149. * variables from external sources.
  150. *
  151. * The magic_quotes_gpc setting affects the output of this function, as
  152. * parse_str() uses the same mechanism that PHP uses to populate the $_GET,
  153. * $_POST, etc. variables.
  154. */
  155. <<__Native>>
  156. function parse_str(string $str,
  157. <<__OutOnly("KindOfArray")>>
  158. inout mixed $arr): void;
  159. }
  160. namespace HH {
  161. /* Finds whether the given variable is a vec.
  162. */
  163. <<__Native, __IsFoldable, __Rx>>
  164. function is_vec(<<__MaybeMutable>> mixed $var): bool;
  165. /* Finds whether the given variable is a dict.
  166. */
  167. <<__Native, __IsFoldable, __Rx>>
  168. function is_dict(<<__MaybeMutable>> mixed $var): bool;
  169. /* Finds whether the given variable is a keyset.
  170. */
  171. <<__Native, __IsFoldable, __Rx>>
  172. function is_keyset(<<__MaybeMutable>> mixed $var): bool;
  173. <<__Native, __IsFoldable, __Rx>>
  174. function is_varray(<<__MaybeMutable>> mixed $var): bool;
  175. <<__Native, __IsFoldable, __Rx>>
  176. function is_darray(<<__MaybeMutable>> mixed $var): bool;
  177. <<__Native, __IsFoldable, __Rx>>
  178. function is_any_array(<<__MaybeMutable>> mixed $var): bool;
  179. <<__Native, __Rx>>
  180. function is_php_array(<<__MaybeMutable>> mixed $var): bool;
  181. /*
  182. * Check if the input is an array-like containing only integer keys running
  183. * from 0 to N-1, in that order.
  184. */
  185. <<__Native, __IsFoldable, __Rx>>
  186. function is_list_like(<<__MaybeMutable>> arraylike $var): bool;
  187. <<__Native, __IsFoldable, __Rx>>
  188. function is_meth_caller(<<__MaybeMutable>> mixed $var): bool;
  189. /*
  190. * Behaves like serialize() but takes an optional set of options.
  191. *
  192. * Options:
  193. *
  194. * warnOnHackArrays - If true, emit a Hack array compat notice if serializing a
  195. * Hack array
  196. * warnOnPHPArrays - If true, emit a Hack array compat notice if serializing a
  197. * PHP array
  198. * forcePHPArrays - If true, serialize all Hack arrays as PHP arrays
  199. * keepDVArrays - If true, use custom HHVM-specific serialization format,
  200. * which preserves varray and darray intact.
  201. */
  202. <<__Native, __IsFoldable>>
  203. function serialize_with_options(mixed $value, dict $options = dict[]): string;
  204. /*
  205. * This function returns an array of an object's properties in the same manner
  206. * as casting the object to an array.
  207. */
  208. <<__Native>>
  209. function object_prop_array(object $obj): darray;
  210. /*
  211. * Return true if the <<__LateInit>> property (with name $prop) on the given
  212. * object is initialized to a value (and therefore will not throw when
  213. * accessed). Throws InvalidArgumentException if the property does not exist
  214. * or is inaccessible in the current context.
  215. */
  216. <<__Native>>
  217. function is_late_init_prop_init(object $obj, string $prop): bool;
  218. /*
  219. * Return true if the <<__LateInit>> static property (with name $prop) on the
  220. * class given by $cls is initialized to a value (and therefore will not throw
  221. * when accessed). Throws InvalidArgumentException if $cls is not a valid
  222. * classname, if the static property does not exist, or if the static property
  223. * is inaccessible in the current context.
  224. */
  225. <<__Native>>
  226. function is_late_init_sprop_init(string $cls, string $prop): bool;
  227. /*
  228. * Return all of the keys of the globals array shared between
  229. * runtime and user code. Currently backed by $GLOBALS.
  230. */
  231. <<__Native>>
  232. function global_keys(): keyset<string>;
  233. /*
  234. * Does the key exist in the globals array shared between runtime
  235. * and code.
  236. */
  237. <<__Native>>
  238. function global_key_exists(string $key): bool;
  239. }
  240. namespace HH\Lib\_Private\Native {
  241. /*
  242. * container intrinsic for HH\traversable
  243. */
  244. <<__Native, __IsFoldable, __Rx, __AtMostRxAsArgs>>
  245. function first(
  246. <<__OnlyRxIfImpl(\HH\Rx\Traversable::class), __MaybeMutable>>
  247. mixed $iterable
  248. ): mixed;
  249. <<__Native, __IsFoldable, __Rx, __AtMostRxAsArgs>>
  250. function first_key(
  251. <<__OnlyRxIfImpl(\HH\Rx\Traversable::class), __MaybeMutable>>
  252. mixed $iterable
  253. ): mixed;
  254. <<__Native, __IsFoldable, __Rx, __AtMostRxAsArgs>>
  255. function last(
  256. <<__OnlyRxIfImpl(\HH\Rx\Traversable::class), __MaybeMutable>>
  257. mixed $iterable
  258. ): mixed;
  259. <<__Native, __IsFoldable, __Rx, __AtMostRxAsArgs>>
  260. function last_key(
  261. <<__OnlyRxIfImpl(\HH\Rx\Traversable::class), __MaybeMutable>>
  262. mixed $iterable
  263. ): mixed;
  264. }