CodeInstrumentationClass Class Reference

Inheritance diagram for CodeInstrumentationClass:

CodeReflectionClass ExtendedReflectionClass ReflectionClass

List of all members.

Public Member Functions

 __construct ($strClassName, $strEvalContent="")
 getClassName ()
 setClassName ($strName)
 createMethodsDefinitionCode ()

Protected Member Functions

 createExtendedReflectionClass (ReflectionClass $objOriginalReflectionClass)
 createExtendedReflectionProperty (ReflectionProperty $objOriginalReflectionProperty)
 createExtendedReflectionMethod (ReflectionMethod $objOriginalReflectionMethod)

Protected Attributes

 $strName = null


Detailed Description

Code Instrumentation Class extends a Code Reflection Class to create not a exactly code of the original class but a changed version with some code instrumentation messages what will be send to the Code Instrumentation Receiver

Author:
Thiago Henrique Ramos da Mata <thiago.henrique.mata@gmail.com>

Definition at line 15 of file CodeInstrumentationClass.class.php.


Constructor & Destructor Documentation

__construct ( strClassName,
strEvalContent = "" 
)

Construct the Code Instrumentation of the class.

It must receive the eval content if the class it was created into a eval command.

Parameters:
string $strClassName
string $strEvalContent

Reimplemented from CodeReflectionClass.

Definition at line 32 of file CodeInstrumentationClass.class.php.

00033     {
00034         parent::__construct( $strClassName );
00035         if( $strEvalContent != "" )
00036         {
00037             new CodeReflectionFile( $this->getFileName() , $strEvalContent , false );
00038         }
00039     }


Member Function Documentation

createExtendedReflectionClass ( ReflectionClass objOriginalReflectionClass  )  [protected]

Make the recursive calls and indirectly call return the extended reflection object and not a native reflection class.

See also:
ExtendedReflectionClass::createExtendedReflectionClass( ReflectionClass )
Parameters:
ReflectionClass $objOriginalReflectionClass
Returns:
CodeInstrumentationClass

Reimplemented from CodeReflectionClass.

Definition at line 151 of file CodeInstrumentationClass.class.php.

00152     {
00153         return new CodeInstrumentationClass( $objOriginalReflectionClass->getName() );
00154     }

createExtendedReflectionMethod ( ReflectionMethod objOriginalReflectionMethod  )  [protected]

Make the recursive calls and indirectly call return the extended reflection object and not a native reflection class.

See also:
ExtendedReflectionClass::createExtendedReflectionMethod( ReflectionMethod )
Parameters:
ReflectionClass $objOriginalReflectionClass
Returns:
CodeInstrumentationClass

Reimplemented from CodeReflectionClass.

Definition at line 177 of file CodeInstrumentationClass.class.php.

00178     {
00179         return new CodeInstrumentationMethod( $this->getName() , $objOriginalReflectionMethod->getName() );
00180     }

createExtendedReflectionProperty ( ReflectionProperty objOriginalReflectionProperty  )  [protected]

Make the recursive calls and indirectly call return the extended reflection object and not a native reflection class.

See also:
ExtendedReflectionClass::createExtendedReflectionProperty( ReflectionProperty )
Parameters:
ReflectionClass $objOriginalReflectionClass
Returns:
CodeInstrumentationClass

Reimplemented from CodeReflectionClass.

Definition at line 164 of file CodeInstrumentationClass.class.php.

00165     {
00166         return new CodeInstrumentationProperty( $this->getName() , $objOriginalReflectionProperty->getName() );
00167     }

createMethodsDefinitionCode (  ) 

Create the methods definition code with code instrumentation.

Create the methods of the class changed to can send the messages to the code instrumentation receive before and after each call.

  • Interfaces will not change
  • If the class dont have a constructor and a destructor force existence.
  • call the parent createMethodsDefinitionCode what will call the CodeInstrumentationMethod

See also:
CodeInstrumentationMethod
Returns:
string

Reimplemented from CodeReflectionClass.

Definition at line 96 of file CodeInstrumentationClass.class.php.

References ExtendedReflectionClass::getMethods().

00097     {
00098         if( $this->isInterface() )
00099         {
00100             return parent::createMethodsDefinitionCode();
00101         }
00102         
00103         $strCode = '';
00104         $boolHasConstructor = false;
00105         $boolHasDestructor = false;
00106 
00107         foreach( $this->getMethods() as $objMethodReflection )
00108         {
00109             if( $objMethodReflection->getName() == '__construct' )
00110             {
00111                 $boolHasConstructor = true;
00112             }
00113             if( $objMethodReflection->getName() == '__destruct' )
00114             {
00115                 $boolHasDestructor = true;
00116             }
00117         }
00118 
00119         $strCode = parent::createMethodsDefinitionCode();
00120         if( $boolHasConstructor == false )
00121         {
00122             $strCode .= ' public function __construct()                                                                 ' . "\n";
00123             $strCode .= '    {                                                                                          ' . "\n";
00124             $strCode .= '       $arrArguments = func_get_args();                                                        ' . "\n";
00125             $strCode .= '       $mixReturn = null;                                                                      ' . "\n";
00126             $strCode .= '       CodeInstrumentationReceiver::getInstance()->onEnterMethod( spl_object_hash($this) , __CLASS__ , __METHOD__ , $arrArguments );' . "\n";
00127             $strCode .= '       CodeInstrumentationReceiver::getInstance()->onLeaveMethod( spl_object_hash($this) , __CLASS__ , __METHOD__ , $mixReturn    );' . "\n";
00128             $strCode .= '       }                                                                                           ' . "\n";
00129         }
00130         if( $boolHasDestructor == false )
00131         {
00132             $strCode .= ' public function __destruct()                                                                 ' . "\n";
00133             $strCode .= '    {                                                                                          ' . "\n";
00134             $strCode .= '       $arrArguments = func_get_args();                                                        ' . "\n";
00135             $strCode .= '       $mixReturn = null;                                                                      ' . "\n";
00136             $strCode .= '       CodeInstrumentationReceiver::getInstance()->onEnterMethod( spl_object_hash($this) , __CLASS__ , __METHOD__ , $arrArguments );' . "\n";
00137             $strCode .= '       CodeInstrumentationReceiver::getInstance()->onLeaveMethod( spl_object_hash($this) , __CLASS__ , __METHOD__ , $mixReturn    );' . "\n";
00138             $strCode .= '       }                                                                                           ' . "\n";
00139         }
00140         return $strCode;
00141     }

getClassName (  ) 

Returns the editable class name

Example:
  $this->setClassName( "new_class" )->getClassName() == "new_class"
returns
 true 
See also:
CodeInstrumentationClass->strName

CodeInstrumentationClass::setClassName( string )

Returns:
string

Reimplemented from CodeReflectionClass.

Definition at line 51 of file CodeInstrumentationClass.class.php.

00052     {
00053         if( $this->strName == null )
00054         {
00055             return parent::getClassName();
00056         }
00057         else
00058         {
00059             return $this->strName;
00060         }
00061     }

setClassName ( strName  ) 

Set the editable class name

Example:
  $this->setClassName( "new_class" )->getClassName() == "new_class"
returns
 true 
Assert:
( "something" )
See also:
CodeInstrumentationClass->strName

CodeInstrumentationClass::getClassName()

Parameters:
string $strName
Returns:
CodeInstrumentationClass

Definition at line 77 of file CodeInstrumentationClass.class.php.

References $strName.

00078     {
00079         $this->strName = $strName;
00080         return $this;
00081     }


Member Data Documentation

$strName = null [protected]

The editable class name

string

Definition at line 21 of file CodeInstrumentationClass.class.php.

Referenced by setClassName().


The documentation for this class was generated from the following file:

Generated on Thu Feb 3 03:55:02 2011 for CodeToDiagram by  doxygen 1.5.9