本文整理汇总了PHP中Webmozart\Assert\Assert::notInstanceOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::notInstanceOf方法的具体用法?PHP Assert::notInstanceOf怎么用?PHP Assert::notInstanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::notInstanceOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAccessibleReflectionProperty
/**
* Get an reflection property that you can access directly.
*
* @param object|string $objectOrClass
* @param string $propertyName
*
* @return \ReflectionProperty
*
* @throws \InvalidArgumentException
* @throws \LogicException if the property is not found on the object
*/
protected static function getAccessibleReflectionProperty($objectOrClass, $propertyName)
{
Assert::string($propertyName, 'Property name must be a string. Variable of type "%s" was given.');
$class = $objectOrClass;
if (!is_string($objectOrClass)) {
Assert::object($objectOrClass, 'Can not get a property of a non object. Variable of type "%s" was given.');
Assert::notInstanceOf($objectOrClass, '\\stdClass', 'Can not get a property of \\stdClass.');
$class = get_class($objectOrClass);
}
if (null === ($refl = static::getReflectionClassWithProperty($class, $propertyName))) {
throw new \LogicException(sprintf('The property %s does not exist on %s or any of its parents.', $propertyName, $class));
}
$property = $refl->getProperty($propertyName);
$property->setAccessible(true);
if (!$property->isStatic()) {
Assert::object($objectOrClass, 'Can not access non-static property without an object.');
}
return $property;
}