PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/pcre/ext_pcre.php

https://gitlab.com/Blueprint-Marketing/hhvm
PHP | 414 lines | 71 code | 16 blank | 327 comment | 0 complexity | cc938bf2d8639f5b21776b7a180e0a67 MD5 | raw file
  1. <?hh
  2. // @generated by docskel.php
  3. /**
  4. * Perform a regular expression search and replace.
  5. *
  6. * preg_filter() is identical to preg_replace() except it only returns the
  7. * (possibly transformed) subjects where there was a match. For details
  8. * about how this function works, read the preg_replace() documentation.
  9. *
  10. * @return mixed - preg_filter() returns an array if the subject parameter
  11. * is an array, or a string otherwise. If no matches are found or an error
  12. * occurred, an empty array is returned when subject is an array or NULL
  13. * otherwise.
  14. */
  15. <<__Native>>
  16. function preg_filter(mixed $pattern,
  17. mixed $replacement,
  18. mixed $subject,
  19. int $limit = -1,
  20. ?int &$count = null): mixed;
  21. /**
  22. * Return array entries that match the pattern
  23. *
  24. * @param string $pattern - The pattern to search for, as a string.
  25. * @param array $input - The input array.
  26. * @param int $flags - If set to PREG_GREP_INVERT, this function returns
  27. * the elements of the input array that do not match the given pattern.
  28. *
  29. * @return array - Returns an array indexed using the keys from the input
  30. * array.
  31. */
  32. <<__Native>>
  33. function preg_grep(string $pattern,
  34. array $input,
  35. int $flags = 0): mixed;
  36. /**
  37. * Returns the error code of the last PCRE regex execution
  38. *
  39. * @return int - Returns one of the following constants (explained on
  40. * their own page): PREG_NO_ERROR PREG_INTERNAL_ERROR
  41. * PREG_BACKTRACK_LIMIT_ERROR (see also pcre.backtrack_limit)
  42. * PREG_RECURSION_LIMIT_ERROR (see also pcre.recursion_limit)
  43. * PREG_BAD_UTF8_ERROR PREG_BAD_UTF8_OFFSET_ERROR (since PHP 5.3.0)
  44. */
  45. <<__Native>>
  46. function preg_last_error(): int;
  47. /**
  48. * Perform a global regular expression match
  49. *
  50. * @param string $pattern - The pattern to search for, as a string.
  51. * @param string $subject - The input string.
  52. * @param array $matches - Array of all matches in multi-dimensional
  53. * array ordered according to flags.
  54. * @param int $flags - Can be a combination of the following flags (note
  55. * that it doesn't make sense to use PREG_PATTERN_ORDER together with
  56. * PREG_SET_ORDER): PREG_PATTERN_ORDER Orders results so that
  57. * $matches[0] is an array of full pattern matches, $matches[1] is an
  58. * array of strings matched by the first parenthesized subpattern, and so
  59. * on. So, $out[0] contains array of strings that matched full
  60. * pattern, and $out[1] contains array of strings enclosed by tags.
  61. * PREG_SET_ORDER Orders results so that $matches[0] is an array of
  62. * first set of matches, $matches[1] is an array of second set of
  63. * matches, and so on. PREG_OFFSET_CAPTURE If this flag is
  64. * passed, for every occurring match the appendant string offset will
  65. * also be returned. Note that this changes the value of matches into an
  66. * array where every element is an array consisting of the matched string
  67. * at offset 0 and its string offset into subject at offset 1. If
  68. * no order flag is given, PREG_PATTERN_ORDER is assumed.
  69. * @param int $offset - Normally, the search starts from the beginning of
  70. * the subject string. The optional parameter offset can be used to
  71. * specify the alternate place from which to start the search (in bytes).
  72. * Using offset is not equivalent to passing substr($subject, $offset)
  73. * to preg_match_all() in place of the subject string, because pattern
  74. * can contain assertions such as ^, $ or (?=x). See preg_match() for
  75. * examples.
  76. *
  77. * @return int - Returns the number of full pattern matches (which might
  78. * be zero), or FALSE if an error occurred.
  79. */
  80. <<__Native>>
  81. function preg_match_all(string $pattern,
  82. string $subject,
  83. ?array &$matches = null,
  84. int $flags = 0,
  85. int $offset = 0): mixed;
  86. /**
  87. * Perform a regular expression match
  88. *
  89. * @param string $pattern - The pattern to search for, as a string.
  90. * @param string $subject - The input string.
  91. * @param array $matches - If matches is provided, then it is filled with
  92. * the results of search. $matches[0] will contain the text that matched
  93. * the full pattern, $matches[1] will have the text that matched the
  94. * first captured parenthesized subpattern, and so on.
  95. * @param int $flags - flags can be the following flag:
  96. * PREG_OFFSET_CAPTURE If this flag is passed, for every occurring
  97. * match the appendant string offset will also be returned. Note that
  98. * this changes the value of matches into an array where every element is
  99. * an array consisting of the matched string at offset 0 and its string
  100. * offset into subject at offset 1.
  101. * @param int $offset - Normally, the search starts from the beginning of
  102. * the subject string. The optional parameter offset can be used to
  103. * specify the alternate place from which to start the search (in bytes).
  104. * Using offset is not equivalent to passing substr($subject, $offset)
  105. * to preg_match() in place of the subject string, because pattern can
  106. * contain assertions such as ^, $ or (?=x). Compare: while this
  107. * example will produce
  108. *
  109. * @return int - preg_match() returns 1 if the pattern matches given
  110. * subject, 0 if it does not, or FALSE if an error occurred.
  111. */
  112. <<__Native>>
  113. function preg_match(string $pattern,
  114. string $subject,
  115. ?array &$matches = null,
  116. int $flags = 0,
  117. int $offset = 0): mixed;
  118. /**
  119. * Quote regular expression characters
  120. *
  121. * @param string $str - The input string.
  122. * @param string $delimiter - If the optional delimiter is specified, it
  123. * will also be escaped. This is useful for escaping the delimiter that
  124. * is required by the PCRE functions. The / is the most commonly used
  125. * delimiter.
  126. *
  127. * @return string - Returns the quoted (escaped) string.
  128. */
  129. <<__Native>>
  130. function preg_quote(string $str,
  131. ?string $delimiter = NULL): string;
  132. /**
  133. * Perform a regular expression search and replace using a callback
  134. *
  135. * @param mixed $pattern - The pattern to search for. It can be either a
  136. * string or an array with strings.
  137. * @param callable $callback - A callback that will be called and passed
  138. * an array of matched elements in the subject string. The callback
  139. * should return the replacement string. This is the callback signature:
  140. * stringhandler arraymatches You'll often need the callback
  141. * function for a preg_replace_callback() in just one place. In this case
  142. * you can use an anonymous function to declare the callback within the
  143. * call to preg_replace_callback(). By doing it this way you have all
  144. * information for the call in one place and do not clutter the function
  145. * namespace with a callback function's name not used anywhere else.
  146. * preg_replace_callback() and anonymous function
  147. * @param mixed $subject - The string or an array with strings to search
  148. * and replace.
  149. * @param int $limit - The maximum possible replacements for each pattern
  150. * in each subject string. Defaults to -1 (no limit).
  151. * @param int $count - If specified, this variable will be filled with
  152. * the number of replacements done.
  153. *
  154. * @return mixed - preg_replace_callback() returns an array if the
  155. * subject parameter is an array, or a string otherwise. On errors the
  156. * return value is NULL If matches are found, the new subject will be
  157. * returned, otherwise subject will be returned unchanged.
  158. */
  159. <<__Native>>
  160. function preg_replace_callback(mixed $pattern,
  161. mixed $callback,
  162. mixed $subject,
  163. int $limit = -1,
  164. ?int &$count = null): mixed;
  165. /**
  166. * Perform a regular expression search and replace
  167. *
  168. * @param mixed $pattern - The pattern to search for. It can be either a
  169. * string or an array with strings. Several PCRE modifiers are also
  170. * available, including the deprecated 'e' (PREG_REPLACE_EVAL), which is
  171. * specific to this function.
  172. * @param mixed $replacement - The string or an array with strings to
  173. * replace. If this parameter is a string and the pattern parameter is an
  174. * array, all patterns will be replaced by that string. If both pattern
  175. * and replacement parameters are arrays, each pattern will be replaced
  176. * by the replacement counterpart. If there are fewer elements in the
  177. * replacement array than in the pattern array, any extra patterns will
  178. * be replaced by an empty string. replacement may contain references
  179. * of the form \\n or (since PHP 4.0.4) $n, with the latter form being
  180. * the preferred one. Every such reference will be replaced by the text
  181. * captured by the n'th parenthesized pattern. n can be from 0 to 99, and
  182. * \\0 or $0 refers to the text matched by the whole pattern. Opening
  183. * parentheses are counted from left to right (starting from 1) to obtain
  184. * the number of the capturing subpattern. To use backslash in
  185. * replacement, it must be doubled ("\\\\" PHP string). When working
  186. * with a replacement pattern where a backreference is immediately
  187. * followed by another number (i.e.: placing a literal number immediately
  188. * after a matched pattern), you cannot use the familiar \\1 notation for
  189. * your backreference. \\11, for example, would confuse preg_replace()
  190. * since it does not know whether you want the \\1 backreference followed
  191. * by a literal 1, or the \\11 backreference followed by nothing. In this
  192. * case the solution is to use \${1}1. This creates an isolated $1
  193. * backreference, leaving the 1 as a literal. When using the deprecated
  194. * e modifier, this function escapes some characters (namely ', ", \ and
  195. * NULL) in the strings that replace the backreferences. This is done to
  196. * ensure that no syntax errors arise from backreference usage with
  197. * either single or double quotes (e.g. 'strlen(\'$1\')+strlen("$2")').
  198. * Make sure you are aware of PHP's string syntax to know exactly how the
  199. * interpreted string will look.
  200. * @param mixed $subject - The string or an array with strings to search
  201. * and replace. If subject is an array, then the search and replace is
  202. * performed on every entry of subject, and the return value is an array
  203. * as well.
  204. * @param int $limit - The maximum possible replacements for each pattern
  205. * in each subject string. Defaults to -1 (no limit).
  206. * @param int $count - If specified, this variable will be filled with
  207. * the number of replacements done.
  208. *
  209. * @return mixed - preg_replace() returns an array if the subject
  210. * parameter is an array, or a string otherwise. If matches are found,
  211. * the new subject will be returned, otherwise subject will be returned
  212. * unchanged or NULL if an error occurred.
  213. */
  214. <<__Native>>
  215. function preg_replace(mixed $pattern,
  216. mixed $replacement,
  217. mixed $subject,
  218. int $limit = -1,
  219. ?int &$count = null): mixed;
  220. /**
  221. * Split string by a regular expression
  222. *
  223. * @param string $pattern - The pattern to search for, as a string.
  224. * @param string $subject - The input string.
  225. * @param int $limit - If specified, then only substrings up to limit are
  226. * returned with the rest of the string being placed in the last
  227. * substring. A limit of -1, 0 or NULL means "no limit" and, as is
  228. * standard across PHP, you can use NULL to skip to the flags parameter.
  229. * @param int $flags - flags can be any combination of the following
  230. * flags (combined with the | bitwise operator): PREG_SPLIT_NO_EMPTY
  231. * If this flag is set, only non-empty pieces will be returned by
  232. * preg_split(). PREG_SPLIT_DELIM_CAPTURE If this flag is set,
  233. * parenthesized expression in the delimiter pattern will be captured and
  234. * returned as well. PREG_SPLIT_OFFSET_CAPTURE If this flag is set,
  235. * for every occurring match the appendant string offset will also be
  236. * returned. Note that this changes the return value in an array where
  237. * every element is an array consisting of the matched string at offset 0
  238. * and its string offset into subject at offset 1.
  239. *
  240. * @return array - Returns an array containing substrings of subject
  241. * split along boundaries matched by pattern.
  242. */
  243. <<__Native>>
  244. function preg_split(string $pattern,
  245. string $subject,
  246. int $limit = -1,
  247. int $flags = 0): mixed;
  248. /**
  249. * Replace regular expression
  250. *
  251. * @param string $pattern - A POSIX extended regular expression.
  252. * @param string $replacement - If pattern contains parenthesized
  253. * substrings, replacement may contain substrings of the form \digit,
  254. * which will be replaced by the text matching the digit'th parenthesized
  255. * substring; \0 will produce the entire contents of string. Up to nine
  256. * substrings may be used. Parentheses may be nested, in which case they
  257. * are counted by the opening parenthesis.
  258. * @param string $string - The input string.
  259. *
  260. * @return string - The modified string is returned. If no matches are
  261. * found in string, then it will be returned unchanged.
  262. */
  263. <<__Native>>
  264. function ereg_replace(string $pattern,
  265. string $replacement,
  266. string $string): string;
  267. /**
  268. * Regular expression match
  269. *
  270. * @param string $pattern - Case sensitive regular expression.
  271. * @param string $string - The input string.
  272. * @param array $regs - If matches are found for parenthesized substrings
  273. * of pattern and the function is called with the third argument regs,
  274. * the matches will be stored in the elements of the array regs.
  275. * $regs[1] will contain the substring which starts at the first left
  276. * parenthesis; $regs[2] will contain the substring starting at the
  277. * second, and so on. $regs[0] will contain a copy of the complete string
  278. * matched.
  279. *
  280. * @return int - Returns the length of the matched string if a match for
  281. * pattern was found in string, or FALSE if no matches were found or an
  282. * error occurred. If the optional parameter regs was not passed or the
  283. * length of the matched string is 0, this function returns 1.
  284. */
  285. <<__Native, __Deprecated('As of PHP 5.3.0, preg_match is suggested instead')>>
  286. function ereg(string $pattern,
  287. string $string,
  288. ?array &$regs = null): mixed;
  289. /**
  290. * Replace regular expression case insensitive
  291. *
  292. * @param string $pattern - A POSIX extended regular expression.
  293. * @param string $replacement - If pattern contains parenthesized
  294. * substrings, replacement may contain substrings of the form \digit,
  295. * which will be replaced by the text matching the digit'th parenthesized
  296. * substring; \0 will produce the entire contents of string. Up to nine
  297. * substrings may be used. Parentheses may be nested, in which case they
  298. * are counted by the opening parenthesis.
  299. * @param string $string - The input string.
  300. *
  301. * @return string - The modified string is returned. If no matches are
  302. * found in string, then it will be returned unchanged.
  303. */
  304. <<__Native>>
  305. function eregi_replace(string $pattern,
  306. string $replacement,
  307. string $string): string;
  308. /**
  309. * Case insensitive regular expression match
  310. *
  311. * @param string $pattern - Case insensitive regular expression.
  312. * @param string $string - The input string.
  313. * @param array $regs - If matches are found for parenthesized substrings
  314. * of pattern and the function is called with the third argument regs,
  315. * the matches will be stored in the elements of the array regs.
  316. * $regs[1] will contain the substring which starts at the first left
  317. * parenthesis; $regs[2] will contain the substring starting at the
  318. * second, and so on. $regs[0] will contain a copy of the complete string
  319. * matched.
  320. *
  321. * @return int - Returns the length of the matched string if a match for
  322. * pattern was found in string, or FALSE if no matches were found or an
  323. * error occurred. If the optional parameter regs was not passed or the
  324. * length of the matched string is 0, this function returns 1.
  325. */
  326. <<__Native>>
  327. function eregi(string $pattern,
  328. string $string,
  329. ?array &$regs = null): mixed;
  330. /**
  331. * Split string into array by regular expression
  332. *
  333. * @param string $pattern - Case sensitive regular expression. If you
  334. * want to split on any of the characters which are considered special by
  335. * regular expressions, you'll need to escape them first. If you think
  336. * split() (or any other regex function, for that matter) is doing
  337. * something weird, please read the file regex.7, included in the regex/
  338. * subdirectory of the PHP distribution. It's in manpage format, so
  339. * you'll want to do something along the lines of man
  340. * /usr/local/src/regex/regex.7 in order to read it.
  341. * @param string $string - The input string.
  342. * @param int $limit - If limit is set, the returned array will contain a
  343. * maximum of limit elements with the last element containing the whole
  344. * rest of string.
  345. *
  346. * @return array - Returns an array of strings, each of which is a
  347. * substring of string formed by splitting it on boundaries formed by the
  348. * case-sensitive regular expression pattern. If there are n
  349. * occurrences of pattern, the returned array will contain n+1 items. For
  350. * example, if there is no occurrence of pattern, an array with only one
  351. * element will be returned. Of course, this is also true if string is
  352. * empty. If an error occurs, split() returns FALSE.
  353. */
  354. <<__Native>>
  355. function split(string $pattern,
  356. string $string,
  357. int $limit = -1): mixed;
  358. /**
  359. * Split string into array by regular expression case insensitive
  360. *
  361. * @param string $pattern - Case insensitive regular expression. If you
  362. * want to split on any of the characters which are considered special by
  363. * regular expressions, you'll need to escape them first. If you think
  364. * spliti() (or any other regex function, for that matter) is doing
  365. * something weird, please read the file regex.7, included in the regex/
  366. * subdirectory of the PHP distribution. It's in manpage format, so
  367. * you'll want to do something along the lines of man
  368. * /usr/local/src/regex/regex.7 in order to read it.
  369. * @param string $string - The input string.
  370. * @param int $limit - If limit is set, the returned array will contain a
  371. * maximum of limit elements with the last element containing the whole
  372. * rest of string.
  373. *
  374. * @return array - Returns an array of strings, each of which is a
  375. * substring of string formed by splitting it on boundaries formed by the
  376. * case insensitive regular expression pattern. If there are n
  377. * occurrences of pattern, the returned array will contain n+1 items. For
  378. * example, if there is no occurrence of pattern, an array with only one
  379. * element will be returned. Of course, this is also true if string is
  380. * empty. If an error occurs, spliti() returns FALSE.
  381. */
  382. <<__Native>>
  383. function spliti(string $pattern,
  384. string $string,
  385. int $limit = -1): mixed;
  386. /**
  387. * Make regular expression for case insensitive match
  388. *
  389. * @param string $string - The input string.
  390. *
  391. * @return string - Returns a valid regular expression which will match
  392. * string, ignoring case. This expression is string with each alphabetic
  393. * character converted to a bracket expression; this bracket expression
  394. * contains that character's uppercase and lowercase form. Other
  395. * characters remain unchanged.
  396. */
  397. <<__Native>>
  398. function sql_regcase(string $string): string;