本文整理匯總了PHP中Nette\PhpGenerator\ClassType::from方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassType::from方法的具體用法?PHP ClassType::from怎麽用?PHP ClassType::from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\PhpGenerator\ClassType
的用法示例。
在下文中一共展示了ClassType::from方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generate
/**
* @param string $className
* @return string
*/
public function generate($className)
{
if (!class_exists($className)) {
throw new InvalidArgumentException("Unknown class {$className}. Check for typos in class name and make sure" . " that given class is properly loaded.");
}
$origin = new ReflectionClass($className);
$interface = ClassType::from(self::ACCESSOR_INTERFACE);
$namespace = new PhpNamespace($this->naming->getNamespace());
$class = $namespace->addClass($this->naming->deriveClassName($className));
$class->addDocument("This class was automatically generated by Markatom/Accessor library.");
$class->addImplement(self::ACCESSOR_INTERFACE);
$class->addConst('TARGET', $origin->getName());
$class->addProperty('writer')->setVisibility('private');
$class->setMethods($interface->getMethods());
$class->getMethod('read')->setVisibility('public')->setBody($this->generateReadBody($origin));
$class->getMethod('write')->setVisibility('public')->setBody($this->generateWriteBody($origin));
return (string) $namespace;
}