Login   Register  
PHP Classes
elePHPant
Icontem

Super Proxy: Create object to access private members

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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 (4 years ago) RSS 2.0 feedNot enough user ratingsTotal: 466 All time: 5,438 This week: 1,733Up
Version License PHP version Categories  
super-proxy 1.0GNU General Public Lice...5.2PHP 5, Language, Testing
Description Author  
PHP Programming Innovation award nominee
September 2009
Number 5


Prize: One subscription to the PDF edition of the PHP Architect magazine
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.
Picture of Mathias Krieck
Name: Mathias Krieck is available for providing paid consulting. Contact Mathias Krieck .
Classes: 1 package by
Country: Germany Germany
Age: 35
All time rank: 2982178 in Germany Germany
Week rank: 1779 Up91 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

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
 Version Control Unique User Downloads Download Rankings  
 0%Total:466All time:5,438
 This week:0This week:1,733Up
 User Comments (2)  
 
Interestingly and short art for change of properties and meth...
1 year ago (franzusow)
60%StarStarStarStar
Great idea.
4 years ago (Vladimir Bogdanov)
57%StarStarStar