本文整理汇总了PHP中Nette\Reflection\ClassType::getNamespaceName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassType::getNamespaceName方法的具体用法?PHP ClassType::getNamespaceName怎么用?PHP ClassType::getNamespaceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Reflection\ClassType
的用法示例。
在下文中一共展示了ClassType::getNamespaceName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
/**
* @param string $name
* @param array $args
* @throws Exceptions\MemberAccessException
* @return IPaypalPaymentButton|mixed
*/
public function __call($name, $args)
{
if (substr($name, 0, 6) == 'create' && strlen($name) > 6) {
$name = substr($name, -(strlen($name) - 6));
$reflection = new ClassType(get_called_class());
$componentName = $reflection->getNamespaceName() . '\\' . $name;
if ($this->config === NULL) {
throw new MemberAccessException('Config is not set');
}
/** @var IPaypalPaymentButton $component */
$component = new $componentName($this->config);
if (!empty($args) && is_array($settings = $args[0])) {
$component->assign($settings);
}
return $component;
} else {
throw new MemberAccessException(sprintf('%s is not create method', $name));
}
}
示例2: findEntityWholeName
/**
* Try to find entity class in possible NS
*
* @param class $className
* @param object $entity
* @return null|string
*/
private function findEntityWholeName($className, $entity)
{
$existingClass = NULL;
// try to locate class in this namespace
if (!class_exists($className)) {
// try to find in namespace of entity
$reflection = new ClassType($entity);
$existingClass = $reflection->getNamespaceName() . "\\" . $className;
// try to locate in parents namespace (recursive)
if (!class_exists($existingClass)) {
$parentClass = $reflection->getParentClass();
while ($parentClass !== NULL) {
$existingClass = $reflection->getParentClass()->getNamespaceName() . "\\" . $className;
// not found try to find in parent namespace
if (!class_exists($existingClass)) {
$rc = new ClassType($parentClass);
$parentClass = $rc->getParentClass();
$existingClass = NULL;
} else {
$parentClass = NULL;
}
}
}
} else {
$existingClass = $className;
}
return $existingClass;
}
示例3: parseProperties
/**
* Parse Annotation
* @param ClassType $ref
* @param array $annotations
* @param string $type name of annotation
* @throws RestException
*/
private function parseProperties(ClassType $ref, array $annotations, $type)
{
if (!isset($annotations[$type])) {
return;
}
foreach ($annotations[$type] as $val) {
$trimmed = trim(preg_replace('!\\s+!', ' ', $val));
//Replace multiple whitespaces
$expectedClassName = $className = strstr($trimmed, ' ', true);
//Try find full name of existing class
if (!class_exists($className)) {
$expectedClassName = $ref->getNamespaceName() . '\\' . trim($className, '\\');
if (!class_exists($expectedClassName)) {
$expectedClassName = $this->getClassNameFromAlias($ref, $className);
if (!$expectedClassName or !class_exists($expectedClassName)) {
continue;
}
}
}
$parents = class_parents($expectedClassName);
if ($expectedClassName != DataHash::class and (!$parents or !in_array(DataHash::class, $parents))) {
throw RestException::notInheritedForm($expectedClassName, DataHash::class);
}
$prop = strstr($trimmed, '$');
$pos = strpos($prop, ' ');
$propertyName = $pos != false ? substr($prop, 1, $pos - 1) : substr($prop, 1);
$property = $this->getClassPropertyByName($ref, $propertyName);
if ($property and !$property->protected) {
throw RestException::notProtectedProperty($ref->getName(), $propertyName);
}
$this->classProperties[$ref->getName()][$propertyName] = $expectedClassName;
}
}