Invasive
in package
The "Invasive" helper makes it a bit easier to write unit-tests which touch upon private or protected members.
Table of Contents
Methods
- call() : mixed
- Call a private/protected method.
- get() : mixed
- Get the content of a private/protected method.
- set() : mixed
- Get the content of a private/protected method.
- parseRef() : array<string|int, mixed>
Methods
call()
Call a private/protected method.
public
static call(array<string|int, mixed> $callable[, array<string|int, mixed> $args = [] ]) : mixed
This is only intended for unit-testing.
Parameters
- $callable : array<string|int, mixed>
-
Ex: [$myObject, 'myPrivateMethod'] Ex: ['MyClass', 'myPrivateStaticMethod']
- $args : array<string|int, mixed> = []
-
Ordered list of arguments.
get()
Get the content of a private/protected method.
public
static get(array<string|int, mixed> $ref) : mixed
This is only intended for unit-testing.
Parameters
- $ref : array<string|int, mixed>
-
A reference to class+property. Ex: [$myObject, 'myPrivateField'] Ex: ['MyClass', 'myPrivateStaticField']
set()
Get the content of a private/protected method.
public
static set(array<string|int, mixed> $ref, mixed $value) : mixed
This is only intended for unit-testing.
Parameters
- $ref : array<string|int, mixed>
-
A reference to class+property. Ex: [$myObject, 'myPrivateField'] Ex: ['MyClass', 'myPrivateStaticField']
- $value : mixed
parseRef()
private
static parseRef(array<string|int, mixed> $callable) : array<string|int, mixed>
Parameters
- $callable : array<string|int, mixed>
-
Ex: [$myObject, 'myPrivateMember'] Ex: ['MyClass', 'myPrivateStaticMember']
Return values
array<string|int, mixed> —Ordered array of [string $class, object? $object, string $memberName].