00001 <?php 00002 require_once( "_start.php" ); 00003 00009 // 1. create a example class definiton 00010 $strOriginalClass = ' 00011 class ExampleSimple 00012 { 00013 public function __construct() 00014 { 00015 print "i am"; 00016 } 00017 }; 00018 '; 00019 00020 // 2. eval it 00021 eval( $strOriginalClass ); 00022 00023 // 3. create a code instrumentation of the example class 00024 $oReflectionCode = new CodeInstrumentationClass( "ExampleSimple" , $strOriginalClass ); 00025 00026 // 4. change the class name into the code instrumentation 00027 $oReflectionCode->setClassName( "SomethingElse" ); 00028 00029 // 5. get the code of the new class with code instrumentation 00030 $strNewCode = $oReflectionCode->getCode(); 00031 00032 // 6. eval it 00033 eval( $strNewCode ); 00034 00035 // 7. create a code reflection of both classes 00036 $objOldCode = new CodeReflectionClass( "ExampleSimple" , $strOriginalClass ); 00037 $objNewCode = new CodeReflectionClass( "SomethingElse" , $strNewCode ); 00038 00039 // 8. compare the old class construct method with the old class construct method 00040 // with the new class construct method with prefix 00041 print trim($objOldCode->getMethod( "__construct" )->getCodeContent() ) == 00042 trim( $objNewCode->getMethod( CodeInstrumentationMethod::PREFIX_METHOD . "__construct" )->getCodeContent() ); 00043 ?>
1.5.9