HumHub Documentation (unofficial)

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|null

getClassShortName()

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
string

invokePrivateMethod()

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
throws
ReflectionException

phpEncodeArray()

Recursively PHP encode an array

public static phpEncodeArray(array<string|int, mixed> $array) : string
Parameters
$array : array<string|int, mixed>
Return values
string

phpEncodeValue()

PHP encode value

public static phpEncodeValue(mixed $value) : string
Parameters
$value : mixed
Return values
string

readPrivateProperty()

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
Tags
throws
ReflectionException
Loading…
On this page

Search results