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 59%Total: 475 All time: 5,936 This week: 290Up
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: 43
All time rank: 3286189 in Germany Germany
Week rank: 523 Up19 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:475
This week:0
All time:5,936
This week:290Up
User Ratings User Comments (2)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:-
Examples:-
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1454
 
Interestingly and short art for change of properties and meth...
9 years ago (franzusow)
60%StarStarStarStar
Great idea.
12 years ago (Vladimir Bogdanov)
57%StarStarStar
 
For more information send a message to info at phpclasses dot org.