CodeReflectionMethod Class Reference

Inheritance diagram for CodeReflectionMethod:

ExtendedReflectionMethod ReflectionMethod CodeInstrumentationMethod

List of all members.

Public Member Functions

 getCode ()
 getCodeContent ()
 createMethodHeaderCode ()

Protected Member Functions

 createExtendedReflectionClass (ReflectionClass $objOriginalReflectionClass)
 createExtendedReflectionParameter (ReflectionParameter $objReflectionParameter)
 createModifiersCode ()
 createParametersCode ()
 createMethodContentCode ()


Detailed Description

Generated the code definition of some method based into its reflection information

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

Definition at line 14 of file CodeReflectionMethod.class.php.


Member Function Documentation

createExtendedReflectionClass ( ReflectionClass objOriginalReflectionClass  )  [protected]

Create the link between the code reflection method and its code reflection class

See also:
ExtendedReflectionMethod::createExtendedReflectionClass( ReflectionClass )
Parameters:
ReflectionClass $objOriginalReflectionClass
Returns:
CodeReflectionClass

Reimplemented from ExtendedReflectionMethod.

Reimplemented in CodeInstrumentationMethod.

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

00052         {
00053                 return new CodeReflectionClass( $objOriginalReflectionClass->getName() );
00054         }

createExtendedReflectionParameter ( ReflectionParameter objReflectionParameter  )  [protected]

Create the link between the code reflection method and its code reflection parameter

See also:
ExtendedReflectionMethod::createExtendedReflectionParameter( ReflectionParameter )
Parameters:
ReflectionParameter $objReflectionParameter
Returns:
CodeReflectionParameter

Reimplemented from ExtendedReflectionMethod.

Reimplemented in CodeInstrumentationMethod.

Definition at line 64 of file CodeReflectionMethod.class.php.

References ExtendedReflectionMethod::getDeclaringClass().

00065         {
00066                 return new CodeReflectionParameter( Array( $this->getDeclaringClass()->getName() , $this->getName() ) , $objReflectionParameter->getName() );
00067         }

createMethodContentCode (  )  [protected]

Create the method code definition content

Returns:
string

Reimplemented in CodeInstrumentationMethod.

Definition at line 144 of file CodeReflectionMethod.class.php.

References $strFileName, and CodeReflectionFile::getCodeInstrFileName().

Referenced by getCode(), and getCodeContent().

00145         {
00146                 $strCode = "";
00147 
00148                 $strFileName = $this->getFileName();
00149 
00150         $objFile = CodeReflectionFile::getCodeInstrFileName( $strFileName );
00151 
00152         $strCode = $objFile->getFileBit( $this->getStartLine() ,  $this->getEndLine() );
00153 
00154                 $strCode = trim( $strCode );
00155 
00156                 // remove the { }
00157                 if( $strCode[0] == "{" )
00158                 {
00159                         $strCode = substr( $strCode , 1 , -1);
00160                 }
00161                 return $strCode;
00162         }

createMethodHeaderCode (  ) 

Create the method code definition header

Returns:
string

Reimplemented in CodeInstrumentationMethod.

Definition at line 128 of file CodeReflectionMethod.class.php.

References createModifiersCode(), createParametersCode(), and CorujaStringManipulation::retab().

Referenced by getCode().

00129         {
00130                 $strCode = $this->getDocComment();
00131                 $strCode .= $this->createModifiersCode();
00132                 $strCode .= " function ";
00133                 $strCode .= $this->getName();
00134                 $strCode .= $this->createParametersCode();
00135 
00136                 return CorujaStringManipulation::retab( $strCode , 1 );
00137         }

createModifiersCode (  )  [protected]

Create the modifiers code definition of the method

Returns:
string

Definition at line 74 of file CodeReflectionMethod.class.php.

Referenced by createMethodHeaderCode(), CodeInstrumentationMethod::createMethodHeaderCode(), and CodeInstrumentationMethod::getCallCodeInstrFunctionHeaderCode().

00075         {
00076                 $strCode = "";
00077                 if( $this->isFinal() )
00078                 {
00079                         $strCode .= " final ";
00080                 }
00081                 if( $this->isPrivate() )
00082                 {
00083                         $strCode .= " private ";
00084                 }
00085                 if( $this->isProtected())
00086                 {
00087                         $strCode .= " protected ";
00088                 }
00089                 if( $this->isPublic())
00090                 {
00091                         $strCode .= " public ";
00092                 }
00093                 if( $this->isStatic() )
00094                 {
00095                         $strCode .= " static ";
00096                 }
00097                 return $strCode;
00098         }

createParametersCode (  )  [protected]

Create the parameters code definition

Returns:
string

Definition at line 105 of file CodeReflectionMethod.class.php.

References ExtendedReflectionMethod::getParameters().

Referenced by createMethodHeaderCode(), CodeInstrumentationMethod::createMethodHeaderCode(), and CodeInstrumentationMethod::getCallCodeInstrFunctionHeaderCode().

00106         {
00107                 $strCode = "";
00108                 $arrParameters = $this->getParameters();
00109                 $arrParametersName = array();
00110 
00111                 foreach(  $arrParameters as $objParameter )
00112                 {
00113                         /*@var $objParameter CodeReflectionParameter */
00114                         $arrParametersName[] = $objParameter->getCode();
00115                 }
00116 
00117                 $strCode .= "(";
00118                 $strCode .= implode( ", " , $arrParametersName);
00119                 $strCode .= ")";
00120                 return $strCode;
00121         }

getCode (  ) 

Create the code definition of the reflected method

Returns:
string code method definition

Reimplemented in CodeInstrumentationMethod.

Definition at line 22 of file CodeReflectionMethod.class.php.

References createMethodContentCode(), and createMethodHeaderCode().

00023         {
00024                 $strCode = "";
00025                 $strCode .= $this->createMethodHeaderCode();
00026                 $strCode .= "{";
00027                 $strCode .= $this->createMethodContentCode();
00028                 $strCode .= "}\n";
00029 
00030                 return $strCode;
00031         }

getCodeContent (  ) 

Get the code content of the method

Returns:
string

Definition at line 38 of file CodeReflectionMethod.class.php.

References createMethodContentCode().

00039     {
00040         return $this->createMethodContentCode();
00041     }


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

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