Download the PHP package gmazzap/andrew without Composer
On this page you can find all versions of the php package gmazzap/andrew. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gmazzap/andrew
More information about gmazzap/andrew
Files in gmazzap/andrew
Package andrew
Short Description Proxy objects to access (dynamic and static) private properties and methods.
License MIT
Homepage https://github.com/Giuseppe-Mazzapica/Andrew
Informations about the package andrew
Andrew
Proxy objects to access (dynamic and static) private properties and methods.
What
Andrew allow to access (read & write) private properties and methods of any objects.
It provides 2 "proxy" objects, one for dynamic properties and methods, the other for static properties and method.
Proxy
Let's assume following class
With Andrew is possible to:
The Subject
class example has public getter and isser for its private variable, that we added for
test purposes, bu Andrew proxy is, of course, more useful when classes does not provide that
possibility.
Static Proxy
Let's assume following class
With Andrew is possible to:
Note that StaticProxy
has not unsetter, because PHP does not allow to unset static variables.
If you try to unset anything on a StaticProxy
object, Andrew will throw an Exception.
Exceptions
There are several exceptions thrown by Andrew. All of them are in the namespace Andrew\Exception
.
They are:
ArgumentException
thrown when an invalid type of argument is used. E.g. when a method expects a string and receives a number or anything else.ClassException
thrown when a method expects a class but receives a string that is not a valid class name.PropertyException
when trying to access a non-existent variable, or either when trying to access a static variable usingProxy
or a non-static property usingStaticProxy
.MethodException
when trying to access a non-existent method, or either when trying to access a static method usingProxy
or a non-static method usingStaticProxy
.RuntimeException
when trying to unset a static variable
Installation
Install via Composer, package name is "gmazzap/andrew"
and it is available on Packagist.
Should I use this in production?
No. But may be quite useful in unit tests.
Requirements
Andrew has no dependencies. Requires PHP 5.6+, works with PHP 7 and 7.1.
License
MIT