ValueFormatter
in package
Value formatter class
Turns a real PHP value into its PHP literal source form. Shared by PropertyGenerator, ConstantGenerator, and FunctionTrait's argument-default formatting so all three format values the same way instead of each carrying its own (previously divergent) copy of this logic.
Tags
Table of Contents
Methods
- format() : string
- Format a value as PHP literal source (no trailing semicolon)
- formatArray() : string
- Format an array value as PHP bracket-literal source
- formatArrayCompact() : string
- Format a non-empty array value as a single-line PHP bracket-literal source
Methods
format()
Format a value as PHP literal source (no trailing semicolon)
public
static format(mixed $value[, string|null $type = null ][, string $indent = '' ][, bool $compact = false ]) : string
Parameters
- $value : mixed
- $type : string|null = null
- $indent : string = ''
- $compact : bool = false
-
render an array value on a single line instead of the default multi-line bracket-literal form -- used for attribute arguments, which always render inline (even a top-level
#[...]is conventionally one physical line) and would otherwise force a multi-line array literal into the middle of a parameter list
Return values
stringformatArray()
Format an array value as PHP bracket-literal source
protected
static formatArray(array<string|int, mixed> $value, string $indent) : string
Parameters
- $value : array<string|int, mixed>
- $indent : string
Return values
stringformatArrayCompact()
Format a non-empty array value as a single-line PHP bracket-literal source
protected
static formatArrayCompact(array<string|int, mixed> $value) : string
Parameters
- $value : array<string|int, mixed>