root/components/codeReflection/CodeReflectionProperty.class.php
Author: blaine
File Size: 2.45 KB
(April 30, 2009 21:14 UTC) About 3 years ago
phpdoc change. separating the package notation of the class notation to make easy to the doxygen generate the phpdoc html description
<?php
/**
* CodeReflectionProperty - to get the code reflection of the property
* @package CodeReflection
*/
/**
* Code Reflection Property it is a code reflection version of the
* reflection property
*
* @author Thiago Henrique Ramos da Mata <thiago.henrique.mata@gmail.com>
*/
class CodeReflectionProperty extends ExtendedReflectionProperty
{
/**
* Get the default value of the property.
*
* While the PHP Reflection don't make this method native.
* We have to create this workaround to get the default value
* of the attribute. This brings a problem of classes what need
* of paramenters into it's constructors. In this cases, the default
* value will be ignored.
*
* @workaround getDafaultValue don't exist into reflection
* @fixme unable to get default value on constructors with parameters
* @todo get the default value of the attribute reading direct from the file
* @return mix
*/
public function getDefaultValue()
{
/*
try
{
$objParent = $this->getDeclaringClass();
$strClassName = $objParent->getClassName();
$objTemp = new $strClassName();
$arrTemp = (array)$objTemp;
$arrNew = array();
foreach( $arrTemp as $strKeyTemp => $mixValue )
{
$strNewKey = substr( $strKeyTemp , 3 );
$arrNew[ $strNewKey ] = $mixValue;
}
return $arrNew[ $this->getName() ];
}catch( Exception $objException )
{
// error on init object //
return null;
}
* *
*/
return null;
}
public function getCode()
{
$strCode = "";
$strCode .= CorujaStringManipulation::retab( $this->getDocComment() , 1 );
if( $this->isPrivate() )
{
$strCode .= " private ";
}
if( $this->isProtected())
{
$strCode .= " protected ";
}
if( $this->isPublic())
{
$strCode .= " public ";
}
if( $this->isStatic() )
{
$strCode .= " static ";
}
$strCode .= '$'. $this->getName();
$strCode .= ' = ' . var_export( $this->getDefaultValue() , true );
$strCode .= ";" . "\n";
return $strCode;
}
protected function createExtendedReflectionClass( ReflectionClass $objOriginalReflectionClass )
{
return new CodeReflectionClass( $objOriginalReflectionClass->getName() );
}
}
?> |