本文整理汇总了PHP中ReflectionObject::isInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::isInstance方法的具体用法?PHP ReflectionObject::isInstance怎么用?PHP ReflectionObject::isInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::isInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* ControllerDocumentation constructor.
*
* The reflection object must contain a valid controller class.
*
* @param Controller $controller
* @param \ReflectionObject $reflectionController
* @throws \InvalidArgumentException
*/
public function __construct(Controller $controller, \ReflectionObject $reflectionController = null)
{
$this->controller = $controller;
$this->reflectedController = $reflectionController;
if (!$this->reflectedController) {
$this->reflectedController = new \ReflectionObject($this->controller);
}
if (!$this->reflectedController->isInstance($controller)) {
throw new \InvalidArgumentException('Controller did not match ReflectionObject');
}
$this->documentation = new Documentation();
}
示例2: X
<?php
class X
{
}
$instance = new X();
$ro = new ReflectionObject(new X());
var_dump($ro->isInstance());
var_dump($ro->isInstance($instance, $instance));
var_dump($ro->isInstance(1));
var_dump($ro->isInstance(1.5));
var_dump($ro->isInstance(true));
var_dump($ro->isInstance('X'));
var_dump($ro->isInstance(null));
示例3: array
<?php
class A
{
}
class B extends A
{
}
class X
{
}
$classes = array("A", "B", "X");
$instances = array("myA" => new A(), "myB" => new B(), "myX" => new X());
foreach ($classes as $class) {
$ro = new ReflectionObject(new $class());
foreach ($instances as $name => $instance) {
echo "is {$name} a {$class}? ";
var_dump($ro->isInstance($instance));
}
}