/**
  * 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();
 }
<?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));
<?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));
    }
}