Index

PrintOptions

MMO\core\printers · 1 symbol · generated 30 Sep 2026

class

PrintOptions

PrintOptions.php:23

A printer's options as named arguments: new PrintOptions(escape: true) stands for ['escape' => true].

final readonly class MMO\core\printers\PrintOptions implements MMO\core\interfaces\iOptions
Namespace
MMO\core\printers
Implements
iOptions
A misspelled option is an error (`new PrintOptions(escpae: true)`: "Unknown named parameter $escpae"), where a misspelled array key is silently ignored -- `['escpae' => true]` prints the string unescaped. Accepted wherever a printer or a document takes its options from the outside: `TextPrinter::Print()` (so `HtmlPrinter::Print()`...), `JsonPrinter::Encode()`/`EncodeFile()`, `CsvPrinter::Encode()`, `XlsxPrinter::ExportLines()`, `\MMO\idump()`, a document's constructor and its `renderValue()`. What takes an array only (`iRenderable::render()`, a printer's `__invoke()`) takes `->toArray()`. An option left null is not set: the printer's default applies. Each printer reads the options it knows and ignores the others.
$document->renderValue($_VARS['name'], new PrintOptions(escape: true)); // user input, HTML-escapedTextPrinter::Print($order, new PrintOptions(indent: 2, maxLevel: 3));CsvPrinter::Encode($rows, new PrintOptions(headers: ['Name', 'Age'], separator: ','));

Constants1

KEYS

the key an option is read under, when it is not the property's name

const KEYS = […5 items]

Properties16

basepath

readonly
readonly ?string $basepath
Type
null | string

decimalSeparator

readonly
readonly ?string $decimalSeparator
Type
null | string

dump

readonly
readonly ?bool $dump
Type
null | bool

escape

readonly
readonly ?bool $escape
Type
null | bool

fields

readonly
readonly ?array $fields
Type
null | array

headers

readonly
readonly ?array $headers
Type
null | array

ignoreTraces

readonly
readonly ?bool $ignoreTraces
Type
null | bool

indent

readonly
readonly string|int|null $indent
Type
string | int | null

lang

readonly
readonly ?string $lang
Type
null | string

maxLevel

readonly
readonly ?int $maxLevel
Type
null | int

precision

readonly
readonly ?int $precision
Type
null | int

separator

readonly
readonly ?string $separator
Type
null | string

store

readonly
readonly ?bool $store
Type
null | bool

thousandSeparator

readonly
readonly ?string $thousandSeparator
Type
null | string

tracesFilter

readonly
readonly ?array $tracesFilter
Type
null | array

Methods2

toArray()

PrintOptions.php:80
function toArray(): array
returnsarraymixed> the options that are set, under the keys the printers read
(new PrintOptions(escape: true, maxLevel: 2))->toArray(); // ['escape' => true, 'max-level' => 2]

__construct($escape, $dump, $maxLevel, $indent, $separator, $precision, $decimalSeparator, $thousandSeparator, $lang, $basepath, $ignoreTraces, $tracesFilter, $fields, $store, $headers, $eol)

PrintOptions.php:57
function __construct( ?bool $escape = null, ?bool $dump = null, ?int $maxLevel = null, string|int|null $indent = null, ?string $separator = null, ?int $precision = null, ?string $decimalSeparator = null, ?string $thousandSeparator = null, ?string $lang = null, ?string $basepath = null, ?bool $ignoreTraces = null, ?array $tracesFilter = null, ?array $fields = null, ?bool $store = null, ?array $headers = null, ?string $eol = null )
$escape = nullnull | boolHtmlPrinter: HTML-escape strings. Print untrusted text (user input) with it: without it, HtmlPrinter prints a string as markup.
$dump = nullnull | boolthe debug rendering of \MMO\dump(): types, sizes, protected and private properties -- an entity's hidden one (a password's hash) by its name only, [hidden].
$maxLevel = nullnull | inthow many levels of nested values are printed; deeper ones are only described.
$indent = nullstring | int | nullthe indent of nested lines: a number of spaces, or the string itself.
$separator = nullnull | stringbetween the items of a list (TextPrinter, default ','), or the cells of a row (CsvPrinter, default ';').
$precision = nullnull | intthe number of decimals of a number.
$decimalSeparator = nullnull | stringused with $precision (TextPrinter default ',', CsvPrinter '.').
$thousandSeparator = nullnull | stringused with $precision (TextPrinter default ' ', CsvPrinter '').
$lang = nullnull | stringthe language of dates: fr_FR, en_US... (default: LANGUAGE).
$basepath = nullnull | stringfilenames are printed relative to it (default: the application's base path).
$ignoreTraces = nullnull | boolprint a log without its backtrace.
$tracesFilter = nullnull | arraythe calls left out of a log's backtrace (Class->method).
$fields = nullnull | arrayJsonPrinter, TextPrinter (HtmlPrinter...), XlsxPrinter, CsvPrinter: the entity fields exported (default: all). A hidden one is left out, even named.
$store = nullnull | boolJsonPrinter: an entity as its repository stores it, the entities it holds as links (its hidden properties included: never for a response).
$headers = nullnull | arrayCsvPrinter, XlsxPrinter: the titles of the header row, in column order (or field => title).
$eol = nullnull | stringCsvPrinter: the line ending (default "\r\n").