Skip to content

bottledcode/literal-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Literal String Polyfill

This is a draft of the LiteralString type to provide backwards compatability to older versions of PHP.

Usage

Create a LiteralString:

$string = LiteralString::from('SELECT * FROM users WHERE name = %s');

function query(LiteralString $query, array $variables) { /* code */ }

Literal strings retain much of their stringiness, even in strict mode:

assert(LiteralString::from("a value") === LiteralString::from("a value")); // note the triple equals
assert(LiteralString::from("a value") !== LiteralString::from("a different value"));
assert(LiteralString::from("A") < LiteralString::from("B"));
assert(LiteralString::from("A") . LiteralString::from("B") === "AB"); // note that it is no longer a literal string

About

Polyfill for literal string

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages