Determine class of an object
===

It know it can be done with `get_class($variable)`.
The problem is that my `$object` is actually a string containing the variable name.

so:

    $object = new MyClass();
    
    $var = '$object';
    
    $class = get_class($var); // obviously fails


I can't use `get_class($object)`, because I don't have direct access to that variable (I'm producing the `$var` string from [parsing a PHP expression][1] using token_get_all())


I tried using `eval(sprintf('return get_class(%s);', $var))`, but it doesn't work because the variable appear undefined from eval's scope :(

Is there a way to do this?

I need to know the class in order to pass it to ReflectionMethod, so I can get information about a method (the next element in the PHP expression).


  [1]: http://stackoverflow.com/questions/11632001/determine-elements-of-a-php-expression