本文整理汇总了PHP中Phan\CodeBase::getProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP CodeBase::getProperty方法的具体用法?PHP CodeBase::getProperty怎么用?PHP CodeBase::getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phan\CodeBase
的用法示例。
在下文中一共展示了CodeBase::getProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPropertyByNameInContext
/**
* @param string $name
* The name of the property
*
* @param Context $context
* The context of the caller requesting the property
*
* @return Property
* A property with the given name
*
* @throws AccessException
* An exception may be thrown if the caller does not
* have access to the given property from the given
* context
*/
public function getPropertyByNameInContext(CodeBase $code_base, string $name, Context $context) : Property
{
$property = $code_base->getProperty($this->getFQSEN(), $name);
// If we're getting the property from outside of this
// class and the property isn't public and we don't
// have a getter or setter, emit an access error
if ((!$context->hasClassFQSEN() || $context->getClassFQSEN() != $this->getFQSEN()) && !$property->isPublic() && !$this->hasMethodWithName($code_base, '__get') && !$this->hasMethodWithName($code_base, '__set')) {
if ($property->isPrivate()) {
throw new AccessException("Cannot access private property {$this->getFQSEN()}::\${$property->getName()}");
}
if ($property->isProtected()) {
throw new AccessException("Cannot access protected property {$this->getFQSEN()}::\${$property->getName()}");
}
}
return $property;
}