This seems dangerous.  Like for strings!

Why not use Strutil::format(), it's safe and handles all these types?