Reflection Reader
This reader reads native class information, specifically:
All public (for read) non-static properties
Property read type
Property write type (If the property implements a set hook)
A default value
The default argument passed to the promoted property
By default, this reader receives basic information from the NullReader reader and supplements it. If you need to supplement metadata from another reader, you should specify this explicitly using $delegate argument:
Class Properties
As was written earlier, only public and non-static properties will be read.
This behavior allows you to provide access only to those properties that can be read from the object directly by the user from PHP code, while maintaining encapsulation (not providing information about properties that are not available to the user).
For example, the following properties (marked by ✔) will be known in the result metadata:
Property Types
The logic for reading types is quite simple. For example, let's define three properties:
For property
$athe typestring(read+write) will be inferredFor property
$bthe typemixed(read+write) will be inferredFor property
$cthe typemixed(read+write) will be inferred
When using "property hooks", the types for writing and reading may differ, so when writing the example below, the types will be different:
The
stringtype will be inferred for readingThe
string|inttype will be inferred for writing
Property Default Value
The default value is inferred from the default value of the class property.
Property
$acontains default value"default"Property
$bdoes not contain default value (although it acceptsmixedtype)Property
$ccontains default valuenullPromoted property
$ddoes not contain default value (although it acceptsmixedtype)Promoted property
$edoes not contain default value (although it nullable)Property
$fcontains default value"default"(although technically the default value is not for the property, but for the constructor's argument)