code: private function isTypeMismatch($type, $value)
      {
          if (!($type instanceof \ReflectionClass)) {
              return false;
          }
  
          if (!is_object($value)) {
              return true;
          }
  
          return !$type->isInstance($value);
      }
docs: checks if given type and type of value are a mismatch
  
  A type mismatch is defined as follows: $value is an object and it's
  an instance of the class defined with $type. In any other case there's no
  type mismatch
  
  @param   string|\ReflectionClass  $type
  @param   mixed                    $value
  @return  bool