PlainSprintf

This type has some magic behavior: whenever it appears as a function parameter (in a function with varargs), the argument must be a static string, and will be parsed for % formatting specifiers (which will determine the type of the varargs)

T is treated as a state machine. After the first %, each character causes the corresponding method in T to be looked up. For example, '%b' will "call" the method

function format_b(int $s) : string;

and consume an 'int' from the argument list.

Hex escapes are used for non-alphabetic characters. The '%%' pseudo-specifier consumes nothing and appears as

function format_0x25() : string;

Modifiers and multi-char entries can be encoded by return a new formatter instead of a string:

function format_upcase_l() : ListFormatter;
function format_0x2a(int $s) : PaddingFormatter;

Note that you could use an actual instance of T to do the formatting. We don't; T is only here to provide the types.

For another example on how to implement your own format string interface, see \HH\Lib\Str\SprintfFormat in the HSL.

Interface Synopsis

interface PlainSprintf {...}

Public Methods