ReflectionValueNormalizer
class ReflectionValueNormalizer (View source)
Converts a value read from the Reflection API into something that survives serialization.
Stage 1 of the reflection pipeline serializes its extracted data so Stage 2 can rebuild it in a different container. Anything reachable from a reflected value therefore has to be representable without depending on classes that may not exist on the other side.
This used to live on {\StubTests\Framework\Parsers\Reflection\Wrappers\ReflectionMethodExtractor} as a second static, which was a poor fit:
that class is about calling getter methods on a reflection object, while this is about
normalising arbitrary values. The mismatch became obvious once property, parameter and constant
adapters needed it — ReflectionMethodExtractor::makeSerializable() on a property default reads as
though a method extractor were involved in property handling, which it is not.
PHP 5.6+ compatible (no typed properties, no return types) — Stage 1 runs on every reflected version, down to 5.6.
Methods
Recursively convert a reflected value into a serializable form.
Details
static mixed
makeSerializable(mixed $value, int $depth = 0, int $maxDepth = 3)
Recursively convert a reflected value into a serializable form.