
Public Member Functions | |
| getNewName () | |
| getCallCodeInstrFunctionName () | |
| getCode () | |
| createMethodHeaderCode () | |
Public Attributes | |
| const | PREFIX_METHOD = "CODETODIAGRAM_" |
Protected Member Functions | |
| getCallCodeInstrFunctionCode () | |
| getCallCodeInstrFunctionHeaderCode () | |
| getCallCodeInstrFunctionContentCode () | |
| createExtendedReflectionClass (ReflectionClass $objOriginalReflectionClass) | |
| createExtendedReflectionParameter (ReflectionParameter $objReflectionParameter) | |
| createMethodContentCode () | |
Definition at line 14 of file CodeInstrumentationMethod.class.php.
| createExtendedReflectionClass | ( | ReflectionClass $ | objOriginalReflectionClass | ) | [protected] |
make the class calls return a code instrumentation class
| ReflectionClass | $objOriginalReflectionClass |
Reimplemented from CodeReflectionMethod.
Definition at line 211 of file CodeInstrumentationMethod.class.php.
00212 { 00213 return new CodeInstrumentationClass( $objOriginalReflectionClass->getName() ); 00214 }
| createExtendedReflectionParameter | ( | ReflectionParameter $ | objReflectionParameter | ) | [protected] |
make the parameters calls return a Code Instrumentation Parameter
| ReflectionParameter | $objReflectionParameter |
Reimplemented from CodeReflectionMethod.
Definition at line 223 of file CodeInstrumentationMethod.class.php.
References ExtendedReflectionMethod::getDeclaringClass().
00224 { 00225 return new CodeInstrumentationParameter( Array( $this->getDeclaringClass()->getName() , $this->getName() ) , $objReflectionParameter->getName() ); 00226 }
| createMethodContentCode | ( | ) | [protected] |
Create the code instrumentation method content code
Reimplemented from CodeReflectionMethod.
Definition at line 233 of file CodeInstrumentationMethod.class.php.
References CodeReflectionFile::getCodeInstrFileName().
00234 { 00235 $strCode = ""; 00236 00237 $objCodeInstrFile = CodeReflectionFile::getCodeInstrFileName( $this->getFileName() ); 00238 $strCode .= $objCodeInstrFile->getFileBit( $this->getStartLine() , $this->getEndLine() ); 00239 $strCode = trim( $strCode ); 00240 00241 if( strlen( $strCode ) == 0 ) 00242 { 00243 return $strCode; 00244 } 00245 00246 // remove the { } 00247 if( $strCode[0] == "{" ) 00248 { 00249 $strCode = substr( $strCode , 1 ); 00250 } 00251 00252 $intLast = strlen( $strCode ) - 1; 00253 00254 if( $strCode[$intLast] == "}" ) 00255 { 00256 $strCode = substr( $strCode , 0 , -1); 00257 } 00258 return $strCode; 00259 }
| createMethodHeaderCode | ( | ) |
Get the method header of the code instrumentation method
Reimplemented from CodeReflectionMethod.
Definition at line 194 of file CodeInstrumentationMethod.class.php.
References CodeReflectionMethod::createModifiersCode(), CodeReflectionMethod::createParametersCode(), getNewName(), and CorujaStringManipulation::retab().
00195 { 00196 $strCode = $this->getDocComment(); 00197 $strCode .= $this->createModifiersCode(); 00198 $strCode .= " function "; 00199 $strCode .= $this->getNewName(); 00200 $strCode .= $this->createParametersCode(); 00201 return CorujaStringManipulation::retab( $strCode , 1 ); 00202 }
| getCallCodeInstrFunctionCode | ( | ) | [protected] |
Returns the code instrumentation method content what will be append into the class
Definition at line 47 of file CodeInstrumentationMethod.class.php.
References getCallCodeInstrFunctionContentCode(), and getCallCodeInstrFunctionHeaderCode().
Referenced by getCode().
00048 { 00049 $strCode = ""; 00050 $strCode .= $this->getCallCodeInstrFunctionHeaderCode(); 00051 $strCode .= "{" . "\n"; 00052 $strCode .= $this->getCallCodeInstrFunctionContentCode(); 00053 $strCode .= "}" . "\n"; 00054 return $strCode; 00055 }
| getCallCodeInstrFunctionContentCode | ( | ) | [protected] |
Get the code instrumentation content of the method what will be append into the class
1. create the method header 2. if the method is a static one 2.1 log the enter method into the code instrumentation receiver as a static call 2.2 run method 2.3 log the leave method into the code instrumentation receiver as a static call 3. else - if the method is not a static one 3.1 log the enter method into the code instrumentation receiver sending the object id 3.2 if the method is the magic method __call 3.2.1 when some undefined method be called log the call and call the original __call 3.3 else - if the method is not the magic method __call 3.3.1 save the call into the code instrumentation receiver and call the original method 3.4 log the leave method into the code instrumentation receiver sending the object id
Definition at line 91 of file CodeInstrumentationMethod.class.php.
References getNewName().
Referenced by getCallCodeInstrFunctionCode().
00092 { 00093 // 1. create the method header // 00094 $strCode = ""; 00095 $strCode .= ' $strMethod = "' . $this->getNewName() . '"; ' . "\n"; 00096 $strCode .= ' $arrArguments = func_get_args(); ' . "\n"; 00097 $strCode .= ' // prepare caller // ' . "\n"; 00098 00099 // 2. if the method is a static one // 00100 if( $this->isStatic() ) 00101 { 00102 // 2.1 log the enter method into the code instrumentation receiver as a static call 00103 $strCode .= ' $arrCaller = Array( __CLASS__ , $strMethod ) ; ' . "\n"; 00104 $strCode .= ' // log the enter into the real method // ' . "\n"; 00105 $strCode .= ' CodeInstrumentationReceiver::getInstance()->onEnterMethod( "static" , __CLASS__ , __METHOD__ , $arrArguments );' . "\n"; 00106 00107 // 2.2 run method 00108 $strCode .= ' // execute the real method ' . "\n"; 00109 $strCode .= ' $mixReturn = call_user_func_array( $arrCaller, $arrArguments ); ' . "\n"; 00110 00111 // 2.3 log the leave method into the code instrumentation receiver as a static call 00112 $strCode .= ' // log the exit of the real method // ' . "\n"; 00113 $strCode .= ' CodeInstrumentationReceiver::getInstance()->onLeaveMethod( "static" , __CLASS__ , __METHOD__ , $mixReturn );' . "\n"; 00114 $strCode .= ' // return the result of the method into the object // ' . "\n"; 00115 $strCode .= ' return $mixReturn; ' . "\n"; 00116 } 00117 // 3. else - if the method is not a static one // 00118 else 00119 { 00120 // 3.1 log the enter method into the code instrumentation receiver sending the object id // 00121 $strCode .= ' $arrCaller = Array( $this , $strMethod ) ; ' . "\n"; 00122 $strCode .= ' // log the enter into the real method // ' . "\n"; 00123 $strCode .= ' CodeInstrumentationReceiver::getInstance()->onEnterMethod( spl_object_hash($this) , __CLASS__ , __METHOD__ , $arrArguments );' . "\n"; 00124 $strCode .= ' // execute the real method ' . "\n"; 00125 00126 // 3.2 if the method is the magic method __call // 00127 if( $this->getName() == "__call" ) 00128 { 00129 // 3.2.1 when some undefined method be called log the call and call the original __call // 00130 $strCode .= ' // if the method exists ' . "\n"; 00131 $strCode .= ' if( method_exists( $this , $strMethod ) ) ' . "\n"; 00132 $strCode .= ' { ' . "\n"; 00133 $strCode .= ' // call the real method ' . "\n"; 00134 $strCode .= ' $mixReturn = call_user_func_array( $arrCaller, $arrArguments ); ' . "\n"; 00135 $strCode .= ' } ' . "\n"; 00136 $strCode .= ' else ' . "\n"; 00137 $strCode .= ' { ' . "\n"; 00138 $strCode .= ' // exists in the original class a __call method // ' . "\n"; 00139 $strCode .= ' if( method_exists( $this , "' . self::PREFIX_METHOD . '__call" ) ) ' . "\n"; 00140 $strCode .= ' { ' . "\n"; 00141 $strCode .= ' // call it // ' . "\n"; 00142 $strCode .= ' $mixReturn = $this->' . self::PREFIX_METHOD . '__call( $strMethod , $arrArguments ); ' . "\n"; 00143 $strCode .= ' } ' . "\n"; 00144 $strCode .= ' else ' . "\n"; 00145 $strCode .= ' { ' . "\n"; 00146 $strCode .= ' throw new CodeToDiagramException( "Unable to find the method $strMethod "); ' . "\n"; 00147 $strCode .= ' } ' . "\n"; 00148 $strCode .= ' } ' . "\n"; 00149 } 00150 // 3.3 else - if the method is not the magic method __call // 00151 else 00152 { 00153 // 3.3.1 save the call into the code instrumentation receiver and call the original method // 00154 $strCode .= ' // if the method exists ' . "\n"; 00155 $strCode .= ' if( method_exists( $this , $strMethod ) ) ' . "\n"; 00156 $strCode .= ' { ' . "\n"; 00157 $strCode .= ' // call the real method ' . "\n"; 00158 $strCode .= ' $mixReturn = call_user_func_array( $arrCaller, $arrArguments ); ' . "\n"; 00159 $strCode .= ' } ' . "\n"; 00160 $strCode .= ' else ' . "\n"; 00161 $strCode .= ' { ' . "\n"; 00162 $strCode .= ' throw new CodeToDiagramException( "Unable to find the method $strMethod "); ' . "\n"; 00163 $strCode .= ' } ' . "\n"; 00164 } 00165 // 3.4 log the leave method into the code instrumentation receiver sending the object id 00166 $strCode .= ' // log the exit of the real method // ' . "\n"; 00167 $strCode .= ' CodeInstrumentationReceiver::getInstance()->onLeaveMethod( spl_object_hash($this) , __CLASS__ , __METHOD__ , $mixReturn );' . "\n"; 00168 $strCode .= ' // return the result of the method into the object // ' . "\n"; 00169 $strCode .= ' return $mixReturn; ' . "\n"; 00170 } 00171 00172 return $strCode; 00173 }
| getCallCodeInstrFunctionHeaderCode | ( | ) | [protected] |
Get the code instrumentation header of the method what will be append into the class
Definition at line 63 of file CodeInstrumentationMethod.class.php.
References CodeReflectionMethod::createModifiersCode(), CodeReflectionMethod::createParametersCode(), getCallCodeInstrFunctionName(), and CorujaStringManipulation::retab().
Referenced by getCallCodeInstrFunctionCode().
00064 { 00065 $strCode = CorujaStringManipulation::retab( $this->getDocComment() , 1 ); 00066 $strCode .= $this->createModifiersCode(); 00067 $strCode .= " function " . $this->getCallCodeInstrFunctionName(); 00068 $strCode .= $this->createParametersCode(); 00069 return $strCode; 00070 }
| getCallCodeInstrFunctionName | ( | ) |
Returns de name of the code instrumentation method name what will be append into the class
Definition at line 37 of file CodeInstrumentationMethod.class.php.
Referenced by getCallCodeInstrFunctionHeaderCode().
| getCode | ( | ) |
Get the code of the code instrumentation method
Reimplemented from CodeReflectionMethod.
Definition at line 180 of file CodeInstrumentationMethod.class.php.
References getCallCodeInstrFunctionCode().
00181 { 00182 $strCode = ""; 00183 $strCode .= $this->getCallCodeInstrFunctionCode(); 00184 $strCode .= parent::getCode(); 00185 return $strCode; 00186 00187 }
| getNewName | ( | ) |
Returns the new name of the original method. '
Definition at line 27 of file CodeInstrumentationMethod.class.php.
Referenced by createMethodHeaderCode(), and getCallCodeInstrFunctionContentCode().
| const PREFIX_METHOD = "CODETODIAGRAM_" |
The original method should be renamed. This is the new prefix what will be append into it's name.
Definition at line 20 of file CodeInstrumentationMethod.class.php.
1.5.9