Placeholders final class
Minn\Runtime\Placeholders · public/minn/src/Minn/Runtime/Placeholders.php · 71 lines
The printf placeholders plugin code hands wpdb::prepare, filled the way the reference fills them: a bare %s is escaped and quoted; a numbered (%1$s), padded (%5s) or precise (%.2f) one is formatted and escaped but never quoted, so a plugin can name a table with it; %d and %f cast; %i backticks an identifier; %% is a literal. Numbered placeholders address the argument list directly while unnumbered ones count from the first on their own, as vsprintf does. A placeholder with no argument behind it empties the whole query, as the reference does.
Constants and properties
| private | SPEC = '/%(?:(\\d+)\\$)?([-+ 0]*)(\\d*)(?:\\.(\\d+))?([sdfFi%])/' |
Public
| static | fill(string $query, array $args, callable $escape): ?string# | Fills a query's placeholders from the arguments; null when one has no argument.
| ||||||
| static | prepare(string $query, array $args, callable $escape): array# | fill() with what wpdb::prepare reports alongside: how many placeholders the query has (%% not among them) and the type of each argument it could not use (an array or an object fills as '').
@return array{query: ?string, placeholders: int, unsupported: list<string>} |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.