
Public Member Functions | |
| __construct ($strClassName, $strEvalContent="") | |
| getClassName () | |
| getNamespace () | |
| getRealClassName () | |
| createClassDefinitionCode () | |
| createAttributesDefinitionCode () | |
| createMethodsDefinitionCode () | |
| getCode () | |
Protected Member Functions | |
| createExtendedReflectionClass (ReflectionClass $objOriginalReflectionClass) | |
| createExtendedReflectionProperty (ReflectionProperty $objOriginalReflectionProperty) | |
| createExtendedReflectionMethod (ReflectionMethod $objOriginalReflectionMethod) | |
With this class you can see the code of some class, method, attribute just as it is and extending this class you can create a similary class of the original one.
This class can be used to debug, detail of some execution or stack and to code instrumentation.
Definition at line 21 of file CodeReflectionClass.class.php.
| __construct | ( | $ | strClassName, | |
| $ | strEvalContent = "" | |||
| ) |
Construct the Code Reflection of the class.
It must receive the eval content if the class it was created into a eval command.
| string | $strClassName | |
| string | $strEvalContent |
Reimplemented in CodeInstrumentationClass.
Definition at line 32 of file CodeReflectionClass.class.php.
00033 { 00034 parent::__construct( $strClassName ); 00035 if( $strEvalContent != "" ) 00036 { 00037 new CodeReflectionFile( $this->getFileName() , $strEvalContent , false ); 00038 } 00039 }
| createAttributesDefinitionCode | ( | ) |
Create a php attribute definition code
Definition at line 113 of file CodeReflectionClass.class.php.
References ExtendedReflectionClass::getProperties().
Referenced by getCode().
00114 { 00115 $strCode = ""; 00116 $arrProperties = $this->getProperties(); 00117 foreach( $arrProperties as $objReflectionProperty ) 00118 { 00119 /*@var $objReflectionProperty CodeReflectionProperty */ 00120 $strCode .= $objReflectionProperty->getCode(); 00121 } 00122 $arrConstants = $this->getConstants(); 00123 foreach( $arrConstants as $strKey => $mixValue ) 00124 { 00125 /*@var $objReflectionProperty CodeReflectionProperty */ 00126 $strCode .= "const " . $strKey . ' = ' . var_export( $mixValue , true ) . ";\n"; 00127 } 00128 return $strCode; 00129 }
| createClassDefinitionCode | ( | ) |
Create a php class definition code
Definition at line 86 of file CodeReflectionClass.class.php.
References getClassName(), ExtendedReflectionClass::getInterfaces(), and ExtendedReflectionClass::getParentClass().
Referenced by getCode().
00087 { 00088 $strCode = ""; 00089 $strCode .= " class " . $this->getClassName(); 00090 if( $this->getParentClass() != "" ) 00091 { 00092 $strCode .= " extends " . $this->getParentClass()->getClassName(); 00093 } 00094 if( sizeof( $this->getInterfaceNames() ) > 0) 00095 { 00096 $arrInterfacesClassName = array(); 00097 $arrInterfaces = $this->getInterfaces(); 00098 foreach( $arrInterfaces as $objInterfaces ) 00099 { 00100 $arrInterfacesClassName[] = $objInterfaces->getClassName(); 00101 } 00102 $strCode .= " implements " . implode( ", " , $arrInterfacesClassName ); 00103 } 00104 $strCode .= "\n"; 00105 return $strCode; 00106 }
| createExtendedReflectionClass | ( | ReflectionClass $ | objOriginalReflectionClass | ) | [protected] |
Make the recursive calls and indirectly call return the extended reflection object and not a native reflection class.
| ReflectionClass | $objOriginalReflectionClass |
Reimplemented from ExtendedReflectionClass.
Reimplemented in CodeInstrumentationClass.
Definition at line 197 of file CodeReflectionClass.class.php.
00198 { 00199 return new CodeReflectionClass( $objOriginalReflectionClass->getName() ); 00200 }
| createExtendedReflectionMethod | ( | ReflectionMethod $ | objOriginalReflectionMethod | ) | [protected] |
Make the recursive calls and indirectly call return the extended reflection object and not a native reflection method.
| ReflectionMethod | $objOriginalReflectionClass |
Reimplemented from ExtendedReflectionClass.
Reimplemented in CodeInstrumentationClass.
Definition at line 223 of file CodeReflectionClass.class.php.
00224 { 00225 return new CodeReflectionMethod( $this->getName() , $objOriginalReflectionMethod->getName() ); 00226 }
| createExtendedReflectionProperty | ( | ReflectionProperty $ | objOriginalReflectionProperty | ) | [protected] |
Make the recursive calls and indirectly call return the extended reflection object and not a native reflection property.
| ReflectionProperty | $objOriginalReflectionClass |
Reimplemented from ExtendedReflectionClass.
Reimplemented in CodeInstrumentationClass.
Definition at line 210 of file CodeReflectionClass.class.php.
00211 { 00212 return new CodeReflectionProperty( $this->getName() , $objOriginalReflectionProperty->getName() ); 00213 }
| createMethodsDefinitionCode | ( | ) |
Create a php method definiton code
Reimplemented in CodeInstrumentationClass.
Definition at line 136 of file CodeReflectionClass.class.php.
References ExtendedReflectionClass::getMethods(), and getRealClassName().
Referenced by getCode().
00137 { 00138 $strCode = ""; 00139 $arrMethods = $this->getMethods(); 00140 foreach( $arrMethods as $objReflectionMethod ) 00141 { 00142 /*@var $objReflectionMethod CodeReflectionMethod */ 00143 if( $objReflectionMethod->getDeclaringClass()->getRealClassName() == $this->getRealClassName()) 00144 { 00145 if( !$this->isInterface() ) 00146 { 00147 $strCode .= $objReflectionMethod->getCode(); 00148 } 00149 else 00150 { 00151 $strCode .= $objReflectionMethod->createMethodHeaderCode(); 00152 } 00153 } 00154 } 00155 return $strCode; 00156 }
| getClassName | ( | ) |
Get the class name
Reimplemented in CodeInstrumentationClass.
Definition at line 46 of file CodeReflectionClass.class.php.
Referenced by createClassDefinitionCode().
00047 { 00048 $strName = parent::getName(); 00049 $arrName = explode( "::" ,$strName) ; 00050 return array_pop( $arrName ); 00051 }
| getCode | ( | ) |
Create the code of the reflected object
CodeReflectionClass::createInterfaceDefinitionCode
Definition at line 167 of file CodeReflectionClass.class.php.
References createAttributesDefinitionCode(), createClassDefinitionCode(), and createMethodsDefinitionCode().
00168 { 00169 $strCode = ""; 00170 if( !$this->isInterface() ) 00171 { 00172 $strCode .= $this->createClassDefinitionCode(); 00173 $strCode .= "{\n"; 00174 $strCode .= $this->createAttributesDefinitionCode(); 00175 $strCode .= $this->createMethodsDefinitionCode(); 00176 $strCode .= "\n}\n"; 00177 } 00178 else 00179 { 00180 $strCode .= $this->createInterfaceDefinitionCode(); 00181 $strCode .= "{\n"; 00182 $strCode .= $this->createAttributesDefinitionCode(); 00183 $strCode .= $this->createMethodsDefinitionCode(); 00184 $strCode .= "\n}\n"; 00185 } 00186 return $strCode; 00187 }
| getNamespace | ( | ) |
Get the namespace name
Definition at line 58 of file CodeReflectionClass.class.php.
00059 { 00060 $strName = parent::getName(); 00061 $arrName = explode( "::" ,$strName) ; 00062 return array_shift( $arrName ); 00063 }
| getRealClassName | ( | ) | [final] |
A version of the get class name what cannot be replaced.
Should be used when the execution need the real original class name
Definition at line 74 of file CodeReflectionClass.class.php.
Referenced by createMethodsDefinitionCode().
00075 { 00076 $strName = ExtendedReflectionClass::getName(); 00077 $arrName = explode( "::" ,$strName) ; 00078 return array_pop( $arrName ); 00079 }
1.5.9