CodeReflectionFunction.class.php

Go to the documentation of this file.
00001 <?php
00014 class CodeReflectionFunction extends ExtendedReflectionFunction
00015 {
00021         public function getCode()
00022         {
00023                 $strCode = "";
00024                 $strCode .= $this->createFunctionHeaderCode();
00025                 $strCode .= "{";
00026                 $strCode .= $this->createFunctionContentCode();
00027                 $strCode .= "}\n";
00028 
00029                 return $strCode;
00030         }
00031 
00037     public function getCodeContent()
00038     {
00039         return $this->createMethodContentCode();
00040     }
00041     
00049         protected function createExtendedReflectionParameter( ReflectionParameter $objReflectionParameter )
00050         {
00051                 return new CodeReflectionParameter( null , $this->getName() , $objReflectionParameter->getName() );
00052         }
00053 
00059         protected function createParametersCode()
00060         {
00061                 $strCode = "";
00062                 $arrParameters = $this->getParameters();
00063                 $arrParametersName = array();
00064 
00065                 foreach(  $arrParameters as $objParameter )
00066                 {
00067                         /*@var $objParameter CodeReflectionParameter */
00068                         $arrParametersName[] = $objParameter->getCode();
00069                 }
00070 
00071                 $strCode .= "(";
00072                 $strCode .= implode( ", " , $arrParametersName);
00073                 $strCode .= ")";
00074                 return $strCode;
00075         }
00076 
00081         public function createFunctionHeaderCode()
00082         {
00083                 $strCode = $this->getDocComment();
00084                 $strCode .= " function ";
00085                 $strCode .= $this->getName();
00086                 $strCode .= $this->createParametersCode();
00087 
00088                 return CorujaStringManipulation::retab( $strCode , 1 );
00089         }
00090 
00096         protected function createFunctionContentCode()
00097         {
00098                 $strCode = "";
00099 
00100                 $strFileName = $this->getFileName();
00101 
00102         $objFile = CodeReflectionFile::getCodeInstrFileName( $strFileName );
00103 
00104         $strCode = $objFile->getFileBit( $this->getStartLine() ,  $this->getEndLine() );
00105 
00106                 $strCode = trim( $strCode );
00107 
00108                 // remove the { }
00109                 if( $strCode[0] == "{" )
00110                 {
00111                         $strCode = substr( $strCode , 1 , -1);
00112                 }
00113                 return $strCode;
00114         }
00115 }
00116 ?>

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