PHP get_token_all对象类型

is it possible to get the objects types through the standard PHP tokenizer while doing a static analysis?

I'm trying to evaluate the possibility to implement a design patterns detector but to accomplish my goal I have to know the actual type of the objects when messages are sent to them (i.e. when methods are called on them).

Thanks in advance to everyone will try to help me.

Sorry :(. While trying to write a complete example I realized that it seems possible to infer variable types by looking at objects instantiations (i.e. "new" invocations) and by tracing variable assignments. However I'll need to implement a proper algorithm to parse the result of token_get_all(). @sectus Let me say thank you again for your time and patience.

Yes... but it not easy. My sample of code(using states) for this.

$file_path = 'template.php';

$contents = file_get_contents($file_path);
$tokens = token_get_all($contents);

$classes = array();
$namespace_state = false;           // we are not inside namespace name
$class_or_interface_state = false;  // we are not inside class name

$current_namespace = '';
foreach ($tokens as $token)
    {
    switch (true)
        {
        // namespace?
        case (is_array($token) && $token[0] == T_NAMESPACE): 
            $namespace_state = true; // we are going inside namespace name
            break;

        // semicolon inside namespace name?
        case ($token === ';' && $namespace_state): 
            $namespace_state = false; // we are leaving namespace name
            $current_namespace .= '\\'; // add it to namespace name
            break;

        // \(namespace separator) inside namespace name?
        case (is_array($token) && $namespace_state && $token[0] == T_NS_SEPARATOR):
            $current_namespace .= '\\'; // add it to namespace name
            break;

        // string inside namespace name?
        case (is_array($token) && $namespace_state && $token[0] == T_STRING):
            $current_namespace .= $token[1]; // add it to namespace name
            break;

        // class or interface?
        case (is_array($token) && ($token[0] == T_CLASS || $token[0] == T_INTERFACE)):
            $class_or_interface_state = true; // we are going inside class or interface name
            break;

        // string inside class or interface name?
        case (is_array($token) && $token[0] == T_STRING && $class_or_interface_state):
            $class_or_interface_state = false; // we are leaving class or interface name
            $classes[strtolower($current_namespace . $token[1])] = $file_path; // we have founded full class name
            break;
        }
    }

var_dump($classes);

P.S. this code was not tested with few namespaces in one file.