Parsoid
A bidirectional parser between wikitext and HTML5
|
This class contains sundry helpers unrelated to core Parsoid. More...
Static Public Member Functions | |
static | iterable_to_array (iterable $iterable) |
Convert an iterable to an array. | |
static | jsonEncode ( $o) |
json_encode wrapper function | |
static | stripPrefix ( $subject, $prefix) |
If a string starts with a given prefix, remove the prefix. | |
static | stripSuffix ( $subject, $suffix) |
If a string ends with a given suffix, remove the suffix. | |
This class contains sundry helpers unrelated to core Parsoid.
|
static |
Convert an iterable to an array.
This function is similar to but not the same as the built-in iterator_to_array, because arrays are iterable but not Traversable!
This function is also present in the wmde/iterable-functions library, but it's short enough that we don't need to pull in an entire new dependency here.
@phan-template T
iterable<T> | $iterable |
|
static |
json_encode wrapper function
mixed | $o |
|
static |
If a string starts with a given prefix, remove the prefix.
Otherwise, return the original string. Like preg_replace( "/^$prefix/", '', $subject ) except about 1.14x faster in the replacement case and 2x faster in the no-op case.
Note: adding type declarations to the parameters adds an overhead of 3%. The benchmark above was without type declarations.
string | $subject | |
string | $prefix |
|
static |
If a string ends with a given suffix, remove the suffix.
Otherwise, return the original string. Like preg_replace( "/$suffix$/", '', $subject ) except faster.
string | $subject | |
string | $suffix |