MMO\core\schemas
MMO\core\schemas · 7 symbols · generated 5 Oct 2026
arrayKeysType
schemas.php:201The JSON-Schema type of a phpstan array (array<K, V>) according to the type of its keys: integers make a list (array), strings a map (object), anything else (array-key, int|string, mixed) either.
- Namespace
MMO\core\schemas
| $keys | string | the keys' type, e.g. int, string, non-empty-string, 'a'|'b' |
| returns | array | ['array'], ['object'] or ['array', 'object'] |
Call graph
Used by (1)
commentInformation
schemas.php:627Extract schema keywords/metadata from a PHP doc comment (as returned by \ReflectionProperty::getDocComment() and similar), so a class's own docblocks can double as its JSON-Schema definition (Schema::FromClass).
- Namespace
MMO\core\schemas
| $doc | string | false | a raw doc comment string (or false, e.g. when a property has none) |
| $namespace = '' | string | passed to parseType() to resolve class names in @type/@var |
| returns | array | a JSON-Schema-shaped array of whatever keywords were found |
parseType
schemas.php:259Parse this framework's compact type-description mini-language (used in doc comments, commentInformation(), and anywhere a schema is written by hand as a short string) into a JSON-Schema-shaped array.
- Namespace
MMO\core\schemas
| $type | string | the type description to parse |
| $namespace = '' | null | string | the namespace to resolve an unqualified class name against. null disallows classes entirely. |
| $inObject = false | bool | internal: true while recursing into an object's {...} body |
| $lenient = false | bool | true to read a doc comment's type, written for phpstan rather than for this framework: a name without a leading \ that is neither a type nor a class of $namespace (a class imported with use, non-empty-string, a template's T...) matches anything instead of being an error, and an array shape (array{id: int}) is any array. A \Qualified\Name that does not exist is still an error. |
| returns | array | a JSON-Schema-shaped array (Schema) |
| throws | on malformed input (unterminated quote/array/object, unknown type, misplaced separator, ...) |
typeLength
schemas.php:164The length of the type a text starts with, read the way phpstan reads a doc tag: in list<string> the genres, the type is list<string>. Brackets (<>, [], {}, ()) and quoted texts are skipped whole; outside them, the type ends at a space -- unless the space is next to a | (string | null) -- or at a character no type has (,, :, $...).
- Namespace
MMO\core\schemas
| $text | string | |
| $offset = 0 | int | where the type starts |
| returns | int | the type's length: 0 when the text does not start with one, or when a bracket is never closed |
Call graph
Used by (2)
typeOf
schemas.php:59Get the JSON-Schema primitive type name of a PHP value (as used in a schema's type array).
- Namespace
MMO\core\schemas
| $value | mixed | |
| $allowEmptyArray = true | bool | if $value is an empty array, array is returned if this is true; else object (there is no way to tell an empty JSON list from an empty JSON object in PHP) |
| $allowInteger = true | bool | if false, an int/float value is always number, never integer |
| $numberAsBool = false | bool | if true, an int/float value that is exactly 0 or 1 is reported as boolean |
| returns | string | one of the TYPES constant's values ('instance' for any PHP object) |
| throws | for a value type JSON-Schema has no equivalent for (e.g. a resource) |
Call graph
Used by (1)
typeOfText
schemas.php:91Guess the JSON-Schema type of a raw text value (e.g. a query-string/CLI argument, always a string at that point), the way a JSON parser would interpret it if it could: [...]/{...}-looking text is array/object, 'null'/'true'/'false' (any case) are their own types, a numeric string is integer or number, otherwise string.
- Namespace
MMO\core\schemas
| $value | string | |
| $allowedTypes = null | null | array | if given, constrains/steers the guess to these types (TYPES) -- e.g. a numeric string is reported as 'string' instead of 'integer' if 'integer' isn't in $allowedTypes but 'string' is; an empty string is 'null' if 'string' isn't allowed but 'null' is. |
| returns | null | string | one of TYPES's values, or null if nothing in $allowedTypes could plausibly match |
validateFormat
schemas.php:536Validate a string against a JSON-Schema format keyword value.
- Namespace
MMO\core\schemas
| $value | string | |
| $format | string | one of: date, time, datetime, date-utc, datetime-u, color, style, phone, uri, uriref/uri-reference, email, ip-address/ipv4, ipv6, host-name/hostname |
| returns | bool |