ReflectionHelper
in package
This class contains helper methods to help with common Reflection tasks.
Table of Contents
Methods
- getClassFromParameter() : string|null
- Adapted from https://github.com/Behat/Behat/pull/1313
- getClassShortName() : mixed
- Returns class name without namespace
- getDefaultValue() : string
- Infer default parameter from the reflection object and format it as PHP (code) string
- invokePrivateMethod() : mixed
- Invoke a private method of an object.
- phpEncodeArray() : string
- Recursively PHP encode an array
- phpEncodeValue() : string
- PHP encode value
- readPrivateProperty() : mixed
- Read a private property of an object.
Methods
getClassFromParameter()
Adapted from https://github.com/Behat/Behat/pull/1313
public
static getClassFromParameter(ReflectionParameter $parameter) : string|null
Parameters
- $parameter : ReflectionParameter
Return values
string|nullgetClassShortName()
Returns class name without namespace
public
static getClassShortName(mixed $object) : mixed
(does not use reflection actually)
Parameters
- $object : mixed
getDefaultValue()
Infer default parameter from the reflection object and format it as PHP (code) string
public
static getDefaultValue(ReflectionParameter $param) : string
Parameters
- $param : ReflectionParameter
Return values
stringinvokePrivateMethod()
Invoke a private method of an object.
public
static invokePrivateMethod(object $object, string $method[, array<string|int, mixed> $args = [] ][, string|null $class = null ]) : mixed
Parameters
- $object : object
- $method : string
- $args : array<string|int, mixed> = []
- $class : string|null = null
Tags
phpEncodeArray()
Recursively PHP encode an array
public
static phpEncodeArray(array<string|int, mixed> $array) : string
Parameters
- $array : array<string|int, mixed>
Return values
stringphpEncodeValue()
PHP encode value
public
static phpEncodeValue(mixed $value) : string
Parameters
- $value : mixed
Return values
stringreadPrivateProperty()
Read a private property of an object.
public
static readPrivateProperty(object $object, string $property[, string|null $class = null ]) : mixed
Parameters
- $object : object
- $property : string
- $class : string|null = null