PHP Classes

Super Proxy: Create object to access private members

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  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 (5 years ago) RSS 2.0 feedNot enough user ratingsTotal: 469 All time: 5,580 This week: 1,259Up
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: 36
All time rank: 3062181 in Germany Germany
Week rank: 1465 Up70 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:469All time:5,580
 This week:0This week:1,259Up
 User Comments (2)  
Interestingly and short art for change of properties and meth...
2 years ago (franzusow)
Great idea.
5 years ago (Vladimir Bogdanov)