本文整理匯總了PHP中ReflectionMethod::exportCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP ReflectionMethod::exportCode方法的具體用法?PHP ReflectionMethod::exportCode怎麽用?PHP ReflectionMethod::exportCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ReflectionMethod
的用法示例。
在下文中一共展示了ReflectionMethod::exportCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: exportCode
/**
* Exports the PHP code
*
* @return string
*/
public function exportCode()
{
$code_lines = array();
$code_lines[] = '<?php';
// Export the namespace
if ($this->_reflection_class->getNamespaceName()) {
$code_lines[] = '';
$code_lines[] = 'namespace ' . $this->_reflection_class->getNamespaceName() . ';';
$code_lines[] = '';
}
// Export the class' signature
$code_lines[] = sprintf('%s%s%s %s%s%s', $this->_reflection_class->isAbstract() ? 'abstract ' : '', $this->_reflection_class->isFinal() ? 'final ' : '', $this->_reflection_class->isInterface() ? 'interface' : ($this->_reflection_class->isTrait() ? 'trait' : 'class'), $this->getClassName(), $this->_getParentClassName() ? " extends {$this->_getParentClassName()}" : '', $this->_getInterfaceNames() ? " implements " . join(', ', $this->_getInterfaceNames()) : '');
$code_lines[] = '{';
$code_lines[] = '';
// Export constants
foreach ($this->_reflection_class->getConstants() as $name => $value) {
$reflection_constant = new ReflectionConstant($name, $value);
$code_lines[] = "\t" . $reflection_constant->exportCode();
$code_lines[] = '';
}
// Export properties
foreach ($this->_reflection_class->getProperties() as $property) {
$reflection_property = new ReflectionProperty($property);
$code_lines[] = "\t" . $reflection_property->exportCode();
$code_lines[] = '';
}
// Export methods
foreach ($this->_reflection_class->getMethods() as $method) {
$reflection_method = new ReflectionMethod($method);
$code_lines[] = "\t" . $reflection_method->exportCode();
$code_lines[] = '';
}
$code_lines[] = '}';
return join("\n", $code_lines);
}