Skip to content

ValueRenderer

Renders a default value the way it would be written in source.

var_export() is not usable here. It renders an object default as \Foo::__set_state(array(...)), which is not what the parameter says, and it prints floats at serialize_precision, so the same code produces different pages on two machines with different ini settings.

final class ValueRenderer

SourceDocblock/ValueRenderer.php
MethodDescription
forParameter(ReflectionParameter $parameter): ?stringThe default of a parameter, or null when it has none.
render(mixed $value): stringRenders any value that can appear as a default or a constant.

public function forParameter(ReflectionParameter $parameter): ?string

The default of a parameter, or null when it has none.

A constant default is shown by name rather than by value, since the name is what the caller would write. getDefaultValueConstantName() prefixes a global constant with the declaring file’s namespace — SEEK_SET comes back as Quiote\Http\Sse\SEEK_SET — so a prefixed name that does not actually exist is reduced to its last segment.

ParameterTypeDescription
$parameterReflectionParameter

Returns ?``string

public function render(mixed $value): string

Renders any value that can appear as a default or a constant.

ParameterTypeDescription
$valuemixed

Returns string