本文整理汇总了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;
}