PHP Classes
elePHPant
Icontem

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    
Last Updated Ratings Unique User Downloads Download Rankings
2009-09-03 (7 years ago) RSS 2.0 feedStarStarStar 59%Total: 472 All time: 5,713 This week: 980Up
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 <contact>
Classes: 1 package by
Country: Germany Germany
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:472
This week:0
All time:5,713
This week:980Up
User Ratings User Comments (2)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:-
Examples:-
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1251
 
Interestingly and short art for change of properties and meth...
3 years ago (franzusow)
60%StarStarStarStar
Great idea.
6 years ago (Vladimir Bogdanov)
57%StarStarStar