PHP Classes

Super Proxy: Create object to access private members

Recommend this page to a friend!
  Info   View files View files (1)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 51%Total: 476 All time: 5,974 This week: 660Up
Version License PHP version Categories
super-proxy 1.0GNU General Publi...5.2PHP 5, Language, Testing
Description 

Author

This class can be used to create object of a class in order to access private and protected variables and functions of another class.

It uses reflection to create a copy of the declaration of a given class and changes it to turn private and protected variables and functions.

The class can create an object of the original class copy.

Innovation Award
PHP Programming Innovation award nominee
September 2009
Number 5


Prize: One subscription to the PDF edition of the PHP Architect magazine
When you want to perform a tests that verify whether a given class works as expected, you may need to call functions or access variables that are private or protected.

That circumstance raises a difficulty because you can only access private and protected members from inside the same class.

This class provides a workaround that consists in creating a clone of the original class which has all private and protected variables and functions made public.

This way it becomes possible to access all class members for testing purposes.

Manuel Lemos
Picture of Mathias Krieck
Name: Mathias Krieck is available for providing paid consulting. Contact Mathias Krieck .
Classes: 1 package by
Country: Germany Germany
Age: 45
All time rank: 3329189 in Germany Germany
Week rank: 295 Up7 in Germany Germany Up
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files  
File Role Description
Plain text file SuperProxy.php Class Proxy class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:476
This week:0
All time:5,974
This week:660Up
User Ratings User Comments (2)
 All time
Utility:87%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:-
Tests:-
Videos:-
Overall:51%StarStarStar
Rank:2450
 
Interestingly and short art for change of properties and meth...
11 years ago (franzusow)
60%StarStarStarStar
Great idea.
14 years ago (Vladimir Bogdanov)
57%StarStarStar