MMO\core\strings
MMO\core\strings · 50 symbols · generated 5 Oct 2026
asciiNumber
strings.php:1663Render a number as large, multi-line ASCII-art digits (ASCII_NUMBERS), for banner-style CLI output (e.g. an HTTP error page/response -- Application::createErrorResponse()).
- Namespace
MMO\core\strings
| $num | int | the number to print |
| $leadingZeros = 0 | int | pad $num with this many leading zeros before rendering |
| returns | string | a multi-line string |
Call graph
Used by (1)
baseConvert
strings.php:141Convert a number from one base/alphabet to another. A base given as an int uses the first N characters of 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ (so e.g. 16 = hex); a base given as a string uses that string as its own alphabet, position = digit value.
- Namespace
MMO\core\strings
| $number | string | int | the number to convert, written in the $from base/alphabet |
| $to | string | int | the target base (int) or alphabet (string) |
| $from = 10 | string | int | the source base (int) or alphabet (string). Default 10 (decimal). |
| returns | string | the number represented using the alphabet in $to |
camelCaseIdentifier
strings.php:69Convert text to camelCase, treating $separators as word breaks.
- Namespace
MMO\core\strings
Call graph
Uses (1)
csvColumnIndex
strings.php:1151Reverse of csvColumnName(): convert a spreadsheet-style column name back to its 0-based index.
- Namespace
MMO\core\strings
csvColumnName
strings.php:1137Convert a 0-based column index into a spreadsheet-style column name (A, B, ..., Z, AA, AB, ...).
- Namespace
MMO\core\strings
Call graph
Used by (1)
csvDecode
strings.php:1016Decode CSV text into an array of rows.
- Namespace
MMO\core\strings
| $csv | string | the csv text |
| $keys = true | array | bool | the keys to use for each column. - true: use the first line as keys - false: no keys (each row is a plain 0-indexed list) - array: the keys to use directly (every line, including the first, is then data) |
| $separator = ';' | string | the separator between fields (one single-byte character only) |
| $enclosure = '"' | string | the field enclosure character (one single-byte character only) |
| $escape = '\\' | string | the escape character (at most one single-byte character). An empty string ("") disables the proprietary escape mechanism. |
| $lineSep = MMO\core\strings\PHP_EOL | null | string | the line separator. If null, the whole $csv is parsed as a single line/row. |
| returns | array | a list of rows |
Call graph
Uses (1)
Used by (2)
csvEncode
strings.php:1062Encode a list of records as CSV text, guessing the headers automatically from the data by default.
- Namespace
MMO\core\strings
| $data | array | a list of maps (key => value). Every record should have the same keys. |
| $headers = null | array | false | null | if an array, a map of (key => title) to use as the header row and column order; if null, headers are auto-determined from $data's own keys; if false, no header row is written at all |
| $sep = ';' | string | the column separator |
| $eol = ' ' | string | the line separator |
| $renderer = null | null | callable | a function to convert any value: function(mixed $value, int $line, int $column): mixed |
| returns | string |
Call graph
Used by (1)
csvRawEncode
strings.php:1109Encode a list of lines as CSV text, without any header handling: each line is either an array of column values (joined with $sep) or an already-formatted raw string (used as-is).
- Namespace
MMO\core\strings
| $lines | array | a list of lines (each an array of values, or a raw string line) |
| $sep = ';' | string | the column separator |
| $eol = ' ' | string | the line separator |
| $renderer = null | null | callable | function($value, $line, $column). Only called for array (non-raw-string) lines. |
| returns | string |
describe
strings.php:535Describe any value as a compact, technical/debug string representation (unlike render(), which aims for a human-facing display string): an object uses debugName() if available, else a Class{prop:val,...} dump of its public properties; an array becomes (count){k:v,...} (object-shaped) or (count)[v,...] (list-shaped); true/false/null become 'TRUE'/'FALSE'/'NULL'; nesting stops at $depth, showing (n)[..]/ Class{..} instead of recursing further.
- Namespace
MMO\core\strings
| $val | mixed | |
| $quoteString = false | bool | if true, a string value is quoted and has its own quotes/backslashes/newlines escaped |
| $depth = MMO\core\strings\MMO_DUMP_LEVEL | int | how many levels of nested array/object to describe before collapsing to a placeholder |
| returns | string |
Call graph
Uses (3)
Used by (17)
- aCoercer::__invoke
- aModule::log
- tLogEmitter::log
- MCPController::describeParameters
- standardTraces
- Log::getTraceAsString
- HtmlPrinter::renderMaxLevel
- TextPrinter::__invoke
- TextPrinter::exportTraces
- TextPrinter::renderMaxLevel
- Validator::describeAssert
- Validator::toError
- Curl::log
- Route::log
- describe
- render
- renderTemplate
didYouMean
strings.php:1771The hint an error message adds after an unknown name: the closest known names, so a typo tells its reader (a developer, or an AI agent) what was meant instead of only what was wrong.
- Namespace
MMO\core\strings
| $value | string | the unknown name |
| $choices | iterable | the names that exist |
| $max = 3 | int | how many suggestions at most |
| returns | string | did you mean [a] or [b]?, with its leading space; '' when nothing is close |
dotIdentifier
strings.php:85Turn arbitrary text into a lowercase, dot-separated identifier (a common convention for i18n/config keys).
- Namespace
MMO\core\strings
Call graph
Uses (1)
findMatching
strings.php:313Find the matching closing delimiter for the first opening delimiter found at/after $offset, correctly handling nesting ({a{b}c}), escaped characters, and quoted sub-sequences (ignored entirely, by default both "..." and '...') that might otherwise contain a stray unmatched delimiter.
- Namespace
MMO\core\strings
| $text | string | |
| $open | string | the opening text to look for |
| $close | string | the closing text to look for |
| $offset = 0 | int | the offset to start searching from |
| $ignoreIn = [['"', '"'], ['\'', '\'']] | array | a list of [start, end] delimiter pairs whose contents are skipped over entirely |
| $escapeChar = '\\' | string | the char that escapes (skips) the next character |
| returns | array | false | [start, end] (the opening delimiter's offset, and the offset just AFTER the closing delimiter), or false if no complete, properly matched pair was found |
Call graph
Uses (1)
Used by (2)
findOffset
strings.php:226Get the character offset for a specific line/column position in a text.
- Namespace
MMO\core\strings
| $text | string | |
| $line | int | the line number (starting from 1) |
| $col = 1 | int | the column number (starting from 1) |
| $eol = MMO\core\strings\PHP_EOL | string | end of line delimiter |
| returns | int | false | the offset, or false if $line is beyond the text's last line |
formatFraction
strings.php:190Format a float as an integer part plus its best rational approximation (a fraction), e.g. for display as a mixed number. Approximates via brute-force search over denominators up to $maxDenominator.
- Namespace
MMO\core\strings
| $value | float | |
| $maxDenominator = 9 | int | the maximum denominator to try (9 for tenths, 99 for hundredths, etc.) |
| $delimiter = ' + ' | string | joins the integer part and the fraction |
| returns | string |
getAccents
strings.php:1484The accent-folding table stripAccents()/textRegex() are built on: maps every accented Latin character to its plain-letter equivalent (e.g. 'é' -> 'e').
- Namespace
MMO\core\strings
| ...$chars | ||
| returns | array |
Call graph
Used by (2)
getPlaceholders
strings.php:856Get every placeholder in a template, without rendering/matching anything (a thin wrapper over loopTemplate()).
- Namespace
MMO\core\strings
| $tpl | string | |
| returns | array | [path => ['type' => ?string, 'required' => bool, 'offset' => int, 'size' => int]] |
Call graph
Uses (1)
hash3
strings.php:1376Same as hash3Int(), but base-32-encoded (via PHP's own \base_convert(), NOT this file's own baseConvert()) into a short, compact string.
- Namespace
MMO\core\strings
Call graph
Uses (1)
hash3Int
strings.php:1364Compute the MurmurHash3 (32-bit) hash of a string, as an int. A fast, non-cryptographic hash -- good for hash tables/bucketing/deduplication, NOT for security purposes.
- Namespace
MMO\core\strings
Call graph
Uses (1)
Used by (1)
hash3Unpack
strings.php:1319Don't use this function directly unless you know what you are doing.
- Namespace
MMO\core\strings
| $key | array | an unpack version of a string |
| $seed = 0 | int | Positive integer only |
| returns | int | 32-bit positive integer hash |
Call graph
Used by (1)
hex
strings.php:420Convert a string to its hexadecimal representation, one hex number per byte.
- Namespace
MMO\core\strings
| $str | string | |
| $length = 2 | int | the minimum digit-width of each byte's hex number (zero-padded) |
| returns | string |
htmlTable
strings.php:1449Render a list of records (csvEncode()'s $data shape) as a plain HTML <table>, guessing the header row from the data's own keys (in the order first seen).
- Namespace
MMO\core\strings
| $data | array | a list of maps (key => value). Every record should have the same keys. |
| $title = '' | string | used as the table's <caption> |
| returns | string |
indent
strings.php:594Indent every line of a text.
- Namespace
MMO\core\strings
| $text | string | |
| $indent = 2 | string | int | the indentation text, or a number of spaces (0 leaves $text untouched) |
| $indentFirstLine = true | bool | if false, the first line is left unindented |
| $delimiter = MMO\core\strings\PHP_EOL | string | the line separator |
| returns | string |
isAlphaNum
strings.php:96Test if a string is only made of letters, digits, or the given extra allowed characters.
- Namespace
MMO\core\strings
Call graph
Used by (1)
isEscaped
strings.php:293Test if the character at $pos is escaped: preceded by an ODD number of consecutive $escapeChar (an even number means those escape characters escape each other in pairs, leaving $pos itself unescaped).
- Namespace
MMO\core\strings
Call graph
Used by (3)
isPlaceholder
strings.php:838Tells if $text is, as a WHOLE, a single placeholder ({...}) -- e.g. to detect a query/header value that should be captured wholesale rather than matched as a literal template with embedded placeholders.
- Namespace
MMO\core\strings
Call graph
Used by (1)
isRegex
strings.php:108Test if a string is a syntactically valid PCRE regular expression (delimiters and all).
- Namespace
MMO\core\strings
Call graph
Used by (1)
jsonDecode
strings.php:884Decode a JSON string, optionally tolerating non-standard syntax and templating in {var} values first.
- Namespace
MMO\core\strings
| $json | string | |
| $asArray = true | bool | if true, a JSON object decodes to a plain PHP array instead of stdClass |
| $vars = null | null | array | if given, the raw JSON text is first passed through printf() with these vars (so you can write {var} placeholders directly in the JSON source) |
| $cleanUp = true | bool | if true, tolerate trailing commas and // or *\/ comments, wherever they are -- but never inside a string (neither is standard JSON, and PHP's own json_decode() doesn't support them) |
| returns | mixed | |
| throws | if the (post-cleanup) text isn't valid JSON |
jsonEncode
strings.php:916Encode a value as JSON, with a sanity check that guards against a common \json_encode() footgun: silently returning the string 'null' for a value it couldn't actually encode (e.g. a resource, or a NAN/INF float) even though the value wasn't itself null.
- Namespace
MMO\core\strings
| $data | mixed | |
| $flags = 0 | int | json_encode() |
| $depth = 512 | int | |
| returns | string | |
| throws | when data cannot be encoded | |
| throws | when the result is 'null' but the data is not null |
Call graph
Used by (17)
- ImportSocket::run
- MCPController::mcpResourcesRead
- MCPController::toolDescribeClass
- MCPController::toolDescribeFunction
- MCPController::toolDocumentationIndex
- MCPController::toolGetEntitySchema
- MCPController::toolListEntities
- MCPController::toolListFunctions
- MCPController::toolListPackages
- MCPController::toolListRoutes
- MCPController::toolSearchDocumentation
- MCPController::toolValidateSchema
- JSVariable::render
- PackageManifest::save
- JsonPrinter::Encode
- Curl::exec
- Websocket::write
jsonUnicodeDecode
strings.php:970Reverse of jsonUnicodeEncode(): decode a sequence of JSON unicode escapes (backslash, u, then 4 hex digits, repeated) back to a UTF-8 string.
- Namespace
MMO\core\strings
| $text | string | a sequence of such 6-character escape groups, no other characters |
| returns | string | |
| throws | on a malformed or incomplete escape, or an unpaired surrogate |
jsonUnicodeEncode
strings.php:929Encode a UTF-8 string as a sequence of JSON \uXXXX unicode escapes (surrogate pairs for anything outside the Basic Multilingual Plane).
- Namespace
MMO\core\strings
length
strings.php:19Count the number of characters (not bytes) in a UTF-8 string, without needing the mbstring extension.
- Namespace
MMO\core\strings
lines
strings.php:381Split text into lines by $separator, like \explode(), EXCEPT a $separator that falls inside a quoted ($enclosure-delimited) section does not split -- so a CSV-style multi-line quoted field stays on one "line".
- Namespace
MMO\core\strings
| $text | string | |
| $separator = MMO\core\strings\PHP_EOL | string | line separator |
| $enclosure = '"' | string | quotation character |
| $escapeChar = '\\' | string | escape character for a literal $enclosure inside a quoted section |
| returns | array |
loopTemplate
strings.php:652- Namespace
MMO\core\strings- See
renderTemplate()/matchTemplate()for any of those forms (a route mask like{:integer}, a query capturing{...}, etc. -- they'd just never match/render). Fixed to also accept:,},., and*.
matchTemplate
strings.php:785Match $text against a loopTemplate()-style template, extracting each placeholder's captured (and, if typed, coerced+validated) value into &$matches. Internally builds one single regex out of the template's literal parts (quoted) and each placeholder's type-schema regex (Schema::toRegex(), or .+ for an untyped placeholder).
- Namespace
MMO\core\strings
| $tpl | string | the template |
| $text | string | the text to match |
| $matches = null | null | array | |
| $schemas = null | null | array | a map of type name => iSchema used to coerce/validate/build the regex for each placeholder's :type. Defaults to \MMO\core\schemas\Schema::GlobalTypes(). |
| returns | bool |
Call graph
Used by (3)
normalize
strings.php:57Normalize text for loose/accent-insensitive equality comparison: safeIdentifier() then lowercase.
- Namespace
MMO\core\strings
Call graph
Uses (1)
Used by (1)
parseDocComment
strings.php:1251Quickly parse a PHP doc comment (* ... *\/) into its tags. This is the parser commentInformation() (and, through it, the schema-from-doc-comment machinery) is built on.
- Namespace
MMO\core\strings
Call graph
phpStripWhitespace
strings.php:1190Compact a PHP source string's whitespace (collapse runs of spaces/tabs, strip leading indentation) while preserving line numbers -- unlike stripWhitespace(), this is PHP-token-aware (via \token_get_all()), so it never touches whitespace inside a string/comment token, only real inter-token whitespace and T_WHITESPACE.
- Namespace
MMO\core\strings
position
strings.php:252The reverse of findOffset(): get the line/column for a given character offset in a text.
- Namespace
MMO\core\strings
| $text | string | |
| $offset | int | the offset in text |
| $pos = null | null | array | a previously-computed position (from an earlier, smaller offset in the same $text) to resume scanning from instead of the start -- a performance optimization for repeated calls |
| $eol = MMO\core\strings\PHP_EOL | string | end of line delimiter |
| returns | array | ['line' => int, 'column' => int, 'offset' => int] |
printf
strings.php:454Interpolate context values into {key} placeholders in $format. This is the framework's own message formatter (used throughout for log messages, exceptions, etc. -- tLogEmitter), NOT PHP's own \printf()/\sprintf() (no %s-style specifiers here).
- Namespace
MMO\core\strings
| $format | string | every {xxx} placeholder is replaced by $context['xxx'] |
| $context = [] | array | [key => value] to substitute in |
| $fn = 'MMO\\core\\strings\\render' | the function used to convert each value to a string (render()). false to use the raw value as-is. | |
| returns | string |
printfd
strings.php:474Same as printf(), but converts values via describe() instead of render() -- useful for debug messages where you want a value's raw/technical representation rather than its "nice" rendered form.
- Namespace
MMO\core\strings
| $format | string | every {xxx} placeholder is replaced by $context['xxx'] |
| $context = [] | array | [key => value] to substitute in |
| returns | string |
regex
strings.php:122Turn a plain pattern into a valid delimited regular expression, if it isn't one already (a string that already looks like <delim>...<delim><flags> is passed through unchanged, plus $flags appended).
- Namespace
MMO\core\strings
render
strings.php:493- Namespace
MMO\core\strings
| $value | mixed | |
| $opts = [] | array | options to render. Available keys (in order of use): 'printer': callable(mixed $value, array $opts), used to render each item of an iterable 'separator': string used to \implode() a rendered iterable's items |
| returns | string |
Call graph
Used by (3)
renderTemplate
strings.php:734Fill in a loopTemplate()-style template's placeholders with values from $data (by default rendered through render(); pass $printer to customize).
- Namespace
MMO\core\strings
| $tpl | string | the template |
| $data | ArrayAccess | array | the data to inject |
| $printer = null | null | callable | a Printer function(mixed $value, array $options = [], ?string $type = null) options: - required: {bool} if parameter is required - offset: {int} the offset in the template of the parameter - path: {string} the current path/key of the parameter - size: {int} the size of the current placeholder |
| $opts = [] | array | options passed to the printer |
| $allowPartial = false | bool | if true, a placeholder whose value is missing is left as literal {...} text instead of being rendered/throwing |
| $throw = true | bool | if true, throw when a REQUIRED placeholder's value is missing (ignored if $allowPartial) |
| returns | string | |
| throws | when a required value is missing, $allowPartial is false, and $throw is true |
Call graph
safeIdentifier
strings.php:45Turn arbitrary text into a safe identifier: strip accents (stripAccents()), trim, and replace every character that isn't a letter/digit/underscore (or in $authorizedChar) with $replace.
- Namespace
MMO\core\strings
| $id | string | |
| $replace = '_' | string | the text to use to replace invalid chars |
| $authorizedChar = '' | string | extra characters (as a regex character-class fragment) to also allow through unchanged |
| returns | string |
Call graph
Uses (1)
Used by (3)
scoreWord
strings.php:1405Fuzzy-match score of $w1 against $w2 (e.g. for ranking search results): how much of $w1 is found in $w2, as consecutive runs, weighted by how early those runs start and how long they are.
- Namespace
MMO\core\strings
| $w1 | string | the (typically shorter, e.g. a search query) word to look for |
| $w2 | string | the word to search within |
| returns | float | 1.0 for a perfect match (case/accent-insensitive), down towards 0.0 the less $w1 is found in $w2 |
Call graph
Uses (1)
stripAccents
strings.php:1601Replace every accented Latin character in $value with its plain-letter equivalent (getAccents()).
- Namespace
MMO\core\strings
Call graph
Uses (1)
Used by (2)
stripWhitespace
strings.php:1171Collapse runs of horizontal whitespace to a single space, strip leading indentation on every line, and remove blank lines -- a generic text-compacting helper (NOT PHP-token-aware; phpStripWhitespace() for that, which additionally understands comments/strings and can't corrupt them).
- Namespace
MMO\core\strings
textRegex
strings.php:1616Build a case/accent-insensitive regex that matches $value literally, but where every letter also matches any of its accented forms (e.g. 'e' in the pattern also matches 'é', 'è', 'ê', ...).
- Namespace
MMO\core\strings
| $value | string | |
| $delimiter = '/' | null | string | if null, won't add the modifier and delimeter (warning you need to use u modifier for utf-8 to work) |
| $lowercase = true | bool | if true, use i modifier and set the value to lowercase |
| returns | string |
Call graph
Uses (1)
Used by (1)
utf8Split
strings.php:1642Split a UTF-8 string into an array of its characters (not bytes -- a multi-byte character stays whole).
- Namespace
MMO\core\strings
| $text | string | MUST be a valid UTF-8 encoded string |
| returns | array | |
| throws | if $text isn't valid UTF-8 (only checked when the mbstring extension is available) |
UTF8ToHtml
strings.php:435Convert every 4-byte UTF-8 character (i.e. outside the Basic Multilingual Plane -- emoji, some rare CJK, ...) in $text to a numeric HTML entity, leaving everything else untouched.
- Namespace
MMO\core\strings
| $text | ||
| returns | string |