Deanonymize Class

../_images/deanonymize-class.png

Anonymize class are classes without a name. That way, it provides directly an object, but doesn’t litter the namespace with an extra class name.

Later, if the code needs a second object of the same ‘class’, it has to go through the same code.

Or, it is possible to get access to the ‘hidden’ definition of the class within PHP, by simply creating a class alias to this class. Then, it can be used anywhere else.

The sane alternative might be to simply give a name to the class, or make a direct clone of the object.

And as usual, if that class is not under the code’s own control (say, external lib), it might be useful though hackish.

See Also

PHP Features