you should use ClassUtil from Doctrine Common to handle proxies properly