Skip to content

Commit e718944

Browse files
Andrew Kennedyfacebook-github-bot
Andrew Kennedy
authored andcommitted
Expose bound of Regex\Pattern in hhi file
Summary: Internally, the Hack type checker exposes the `string` bound of `Pattern`, so this should also be reflected in the hhi definition. Reviewed By: mheiber Differential Revision: D71187685 fbshipit-source-id: d63f49b58f2e619011fe47cb8b4eee1a0fb035f9
1 parent 1858e72 commit e718944

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

hphp/hack/hhi/hsl/ext_regex.hhi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace HH\Lib\Regex {
3838
* positional arguments. This can then be used with various Regex\ functions,
3939
* the results of which represent a Match.
4040
*/
41-
newtype Pattern<+T as Match> = string;
41+
newtype Pattern<+T as Match> as string = string;
4242
}
4343

4444
namespace HH\Lib\_Private\_Regex {

hphp/hsl/src/regex/regex.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function replace(
109109
$offset = _Private\validate_offset($offset, Str\length($haystack));
110110

111111
if ($offset === 0) {
112-
list ($result, $error) =
112+
list($result, $error) =
113113
_Private\_Regex\replace($haystack, $pattern, $replacement);
114114
if ($error is nonnull) {
115115
throw new namespace\Exception($pattern, $error);
@@ -119,12 +119,12 @@ function replace(
119119

120120
$haystack1 = Str\slice($haystack, 0, $offset);
121121
$haystack2 = Str\slice($haystack, $offset);
122-
list ($result, $error) =
122+
list($result, $error) =
123123
_Private\_Regex\replace($haystack2, $pattern, $replacement);
124124
if ($error is nonnull) {
125125
throw new namespace\Exception($pattern, $error);
126126
}
127-
return $haystack1 . ($result as nonnull);
127+
return $haystack1.($result as nonnull);
128128
}
129129

130130
/**
@@ -192,11 +192,7 @@ function split(
192192
if ($limit === null) {
193193
$limit = \INF;
194194
}
195-
invariant(
196-
$limit > 1,
197-
'Expected limit greater than 1, got %d.',
198-
$limit,
199-
);
195+
invariant($limit > 1, 'Expected limit greater than 1, got %d.', $limit);
200196
$haystack_length = Str\length($haystack);
201197
$result = vec[];
202198
$offset = 0;
@@ -233,5 +229,5 @@ function split(
233229
* @guide /hack/built-in-types/string
234230
*/
235231
function to_string(Pattern<Match> $pattern)[]: string {
236-
return $pattern as string;
232+
return $pattern;
237233
}

0 commit comments

Comments
 (0)