Skip to content

Commit e0e9fe6

Browse files
Andrew Kennedymeta-codesync[bot]
authored andcommitted
Add TypedFormatString to typedefs in HH
Summary: The newtype `TypedFormatString` was added to `hhi` file but omitted from the corresponding `php` file for HHVM. This diff fixes that, and adds an HHVM test. Differential Revision: D90947026 fbshipit-source-id: 752a649c936e33c85ba257624a9feef1f85abe60
1 parent 232315e commit e0e9fe6

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

hphp/runtime/ext/string/ext_string.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace HH {
44
newtype FormatString<T> = string;
5+
newtype TypedFormatString<T,Targs as (mixed...)> = string;
56
}
67

78
namespace {

hphp/test/slow/printf-user.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?hh
2+
3+
function myprintf<Targs as (mixed...)>(string $test, HH\TypedFormatString<PlainSprintf,Targs> $fmt, ...Targs $args):void {
4+
printf("test = %s\n", $test);
5+
printf($fmt, ...$args);
6+
}
7+
<<__EntryPoint>>
8+
function main():void {
9+
myprintf("one", "int %d float %f\n", 32, 12.3);
10+
myprintf("two", "simple\n");
11+
myprintf("three", "string %s\n", "test");
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test = one
2+
int 32 float 12.300000
3+
test = two
4+
simple
5+
test = three
6+
string test

0 commit comments

Comments
 (0)