hiphop-php /hphp/runtime/ext/fb/ext_fb.php

Language PHP Lines 240
MD5 Hash 116358fc9ae7b35b22ba95a7c552b63c
Repository git://github.com/facebook/hiphop-php.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?hh
// generated by idl-to-hni.php

/* Serialize data into a compact format that can be unserialized by
 * fb_unserialize().
 * @param mixed $thing - What to serialize. Note that objects are not
 * supported.
 * @return mixed - Serialized data.
 */
<<__HipHopSpecific, __Native>>
function fb_serialize(mixed $thing): mixed;

/* Unserialize previously fb_serialize()-ed data.
 * @param mixed $thing - What to unserialize.
 * @param mixed $success - Whether it was successful or not.
 * @return mixed - Unserialized data.
 */
<<__HipHopSpecific, __Native>>
function fb_unserialize(mixed $thing,
                        mixed &$success): mixed;

/* Serialize data into a compact format that can be unserialized by
 * fb_compact_unserialize(). In general produces smaller output compared to
 * fb_serialize(). Largest savings are on arrays with sequential (or almost
 * sequential) indexes, i.e. simple arrays like array($a, $b, $c). NOTE:
 * unlike serialize(), does not preserve internal references, i.e. array(&$a,
 * &$a) will become array($a, $a).
 * @param mixed $thing - What to serialize. Note that objects are not
 * supported.
 * @return mixed - Serialized data.
 */
<<__HipHopSpecific, __Native>>
function fb_compact_serialize(mixed $thing): mixed;

/* Unserialize a previously fb_compact_serialize()-ed data.
 * @param mixed $thing - What to unserialize.
 * @param mixed $success - Whether it was successful or not.
 * @param mixed $errcode - One of those FB_UNSERIALIZE_ constants to describe
 * what the decoding error was, if it failed.
 * @return mixed - Unserialized data.
 */
<<__HipHopSpecific, __Native>>
function fb_compact_unserialize(mixed $thing,
                                mixed &$success,
                                mixed &$errcode = null): mixed;

/* Invokes a user handler upon calling a function or a class method. If this
 * handler returns FALSE, code will continue with original function.
 * Otherwise, it will return what handler tells. The handler function looks
 * like "intercept_handler($name, $obj, $params, $data, &$done)", where $name
 * is original function's fully-qualified name ('Class::method'), $obj is $this
 * for an instance method call or null for static method call or function calls,
 * and $params are original call's parameters. $data is what's passed to
 * fb_intercept() and set $done to false to indicate function should continue its
 * execution with old function as if interception did not happen. By default $done
 * is true so it will return handler's return immediately without executing old
 * function's code. Note that built-in functions are not interceptable.
 * @param string $name - The function or class method name to intercept. Use
 * "class::method" for method name. If empty, all functions will be
 * intercepted by the specified handler and registered individual handlers
 * will be replaced. To make sure individual handlers not affected by such a
 * call, call fb_intercept() with individual names afterwards.
 * @param mixed $handler - Callback to handle the interception. Use null,
 * false or empty string to unregister a previously registered handler. If
 * name is empty, all previously registered handlers, including those that are
 * set by individual function names, will be removed.
 * @param mixed $data - Extra data to pass to the handler when intercepting
 * @return bool - TRUE if successful, FALSE otherwise
 */
<<__HipHopSpecific, __Native>>
function fb_intercept(string $name,
                      mixed $handler,
                      mixed $data = null): bool;

/* Rename a function, so that a function can be called with the new name.
 * When writing unit tests, one may want to stub out a function. To do so,
 * call fb_rename_function('func_to_stub_out', 'somename') then
 * fb_rename_function('new_func_to_replace_with', 'func_to_stub_out'). This
 * way, when calling func_to_stub_out(), it will actually execute
 * new_func_to_replace_with().
 * @param string $orig_func_name - Which function to rename.
 * @param string $new_func_name - What is the new name.
 * @return bool - TRUE if successful, FALSE otherwise.
 */
<<__HipHopSpecific, __Native("NoFCallBuiltin")>>
function fb_rename_function(string $orig_func_name,
                            string $new_func_name): bool;

/* Sanitize a string to make sure it's legal UTF-8 by stripping off any
 * characters that are not properly encoded.
 * @param mixed $input - What string to sanitize.
 * @return bool - Sanitized string.
 */
<<__HipHopSpecific, __Native>>
function fb_utf8ize(mixed &$input): bool;

/* Count the number of UTF-8 code points in string or byte count if it's not
 * valid UTF-8.
 * @param string $input - The string.
 * @return int - Returns the count of code points if valid UTF-8 else byte
 * count.
 */
<<__HipHopSpecific, __Native>>
function fb_utf8_strlen_deprecated(string $input): int;

/* Count the number of UTF-8 code points in string, substituting U+FFFD for
 * invalid sequences.
 * @param string $input - The string.
 * @return int - Returns the number of code points interpreting string as
 * UTF-8.
 */
<<__HipHopSpecific, __Native>>
function fb_utf8_strlen(string $input): int;

/* Cuts a portion of str specified by the start and length parameters.
 * @param string $str - The original string.
 * @param int $start - If start is non-negative, fb_utf8_substr() cuts the
 * portion out of str beginning at start'th character, counting from zero.  If
 * start is negative, fb_utf8_substr() cuts out the portion beginning at the
 * position, start characters away from the end of str.
 * @param int $length - If length is given and is positive, the return value
 * will contain at most length characters of the portion that begins at start
 * (depending on the length of string).  If negative length is passed,
 * fb_utf8_substr() cuts the portion out of str from the start'th character up
 * to the character that is length characters away from the end of the string.
 * In case start is also negative, the start position is calculated beforehand
 * according to the rule explained above.
 * @return string - Returns the portion of str specified by the start and
 * length parameters.  If str is shorter than start characters long, the empty
 * string will be returned.
 */
<<__HipHopSpecific, __Native>>
function fb_utf8_substr(string $str,
                        int $start,
                        int $length = PHP_INT_MAX): string;

/* Returns code coverage data collected so far. Turn on code coverage by
 * Eval.RecordCodeCoverage or by using fb_enable_code_coverage and call this
 * function periodically to get results. Eval.CodeCoverageOutputFile allows
 * you to specify an output file to store results at end of a script run from
 * command line. Use this function in server mode to collect results instead.
 * @param bool $flush - Whether to clear data after this function call.
 * @return mixed
 */
<<__HipHopSpecific, __Native>>
function fb_get_code_coverage(bool $flush): mixed;

/* Enables code coverage. The coverage information is cleared.
 */
<<__HipHopSpecific, __Native("NoFCallBuiltin")>>
function fb_enable_code_coverage(): void;

/* Disables and returns code coverage. The coverage information is cleared.
 */
<<__HipHopSpecific, __Native("NoFCallBuiltin")>>
function fb_disable_code_coverage(): mixed;

/* Toggles the compression status of HipHop output, if headers have already
 * been sent this may be ignored.
 * @param bool $new_value - The new value for the compression state.
 * @return bool - The old value.
 */
<<__HipHopSpecific, __Native>>
function fb_output_compression(bool $new_value): bool;

/* Set a callback function that is called when php tries to exit.
 * @param mixed $function - The callback to invoke. An exception object will
 * be passed to the function
 */
<<__HipHopSpecific, __Native>>
function fb_set_exit_callback(mixed $function): void;

/* Get stats on flushing the last data chunk from server.
 * @return int - Total number of bytes flushed since last flush
 */
<<__HipHopSpecific, __Native>>
function fb_get_last_flush_size(): int;

/* Gathers the statistics of the file named by filename, like lstat(), except
 * uses cached information from an internal inotify-based mechanism that may
 * not be updated during the duration of a request.
 * @param string $filename - Path to a file or a symbolic link.
 * @return mixed - Same format as the normal php lstat() function.
 */
<<__Native>>
function fb_lazy_lstat(string $filename): mixed;

/* Returns a canonicalized version of the input path that contains no symbolic
 * links, like realpath(), except uses cached information from an internal
 * inotify-based mechanism that may not be updated during the duration of a
 * request.
 * @param string $filename - Fake path to the file.
 * @return string - Real path of the file.
 */
<<__Native>>
function fb_lazy_realpath(string $filename): mixed;

/* This function invokes $function with the arguments specified in its
 * parameter list. It returns an array of two elements, the first being a
 * boolean specifying whether or not the function was invoked, the latter
 * being the return value, or null if it was not invoked. The function may be
 * any PHP callable, either a string function name, an array of object
 * instance and method, or array of classname and static class method.
 * @param mixed $function - The callback to invoke.
 * @return array - Two elements, 0 is a bool whether function was invoked, 1
 * is the return value if invoked.
 */
<<__HipHopSpecific, __Native>>
function fb_call_user_func_safe(mixed $function,
                                ...$argv): array;

/* This function invokes $function with the arguments specified in its
 * parameter list. If the function is not defined, $default_rval is returned.
 * Note that the default return value comes BEFORE the arguments to the
 * function.
 * @param mixed $function - The callback to invoke.
 * @param mixed $def - Value returned when function does not exist.
 * @return mixed - The result of the function call if defined, otherwise
 * default.
 */
<<__HipHopSpecific, __Native>>
function fb_call_user_func_safe_return(mixed $function,
                                       mixed $def,
                                       ...$argv): mixed;

/* This function invokes $function with the arguments specified in its
 * parameter list. It returns an array of two elements, the first being a
 * boolean specifying whether or not the function was invoked, the latter
 * being the return value, or null if it was not invoked. The function may be
 * any PHP callable, either a string function name, an array of object
 * instance and method, or array of classname and static class method.
 * @param mixed $function - The callback to invoke.
 * @param array $params - The function parameters to invoke with.
 * @return array - Two elements, 0 is a bool whether function was invoked, 1
 * is the return value if invoked.
 */
<<__HipHopSpecific, __Native>>
function fb_call_user_func_array_safe(mixed $function,
                                      array $params): array;
Back to Top