ResponseType (string)
ResponseType (string)
Enumerates canonical controller response categories.
enum ResponseType: stringUsed to normalize controller/action return types and request Accept header values into framework response handling modes.
Cases
HTML
case HTML = 'html'JSON
case JSON = 'json'XML
case XML = 'xml'TEXT
case TEXT = 'text'BINARY
case BINARY = 'binary'HAZAAR
case HAZAAR = 'hazaar'Methods
getControllerResponseTypeName
Resolves a response category from a controller action return type hint.
public getControllerResponseTypeName(\ReflectionType $reflectionType): selfReturns: self
Mirrors the auto-wrapping rules in Hazaar\Controller::runAction: a return type doesn't have to be an actual Response subclass to have a known, declared intent. array, bool, \ArrayObject, \stdClass, and any \JsonSerializable implementation (e.g. Hazaar\Auth\TokenPair) are auto-wrapped into a JSON response at runtime, and scalar string/int/float returns are auto-wrapped into plain text — those two functions must be kept in sync, since this one drives what the error controller assumes the route's response type is.
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionType | ReflectionType | reflected return type from a controller action |
lookup
Resolves a response category from an Accept header value.
public lookup(string $acceptHeader): selfReturns: self
Parses the header as a comma-separated list of media types with optional q weights per RFC 7231 §5.3.2 (e.g. application/json, text/plain;q=0.9, *\/*;q=0.8), and returns the highest-weighted media type that maps to a known response category. Ties keep header order since PHP's sort functions are stable. A bare wildcard (*\/*) never matches a category on its own, so it falls through to the HTML default like an unrecognised type would.
Parameters
| Parameter | Type | Description |
|---|---|---|
$acceptHeader | string | raw Accept header value |
matchMediaType
private matchMediaType(string $mediaType): ?selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$mediaType | string |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000