0

Example i got a proxy object from Doctrine manager.

// $entity is an proxy object from doctrine
$relectionClass = new \ReflectionClass($entity);
$properties = $class->getProperties();

$properties will return us an empty array, because it reflected from doctrine proxy object.

How i can get list of all properties from my object if it's an doctrine proxy object?

GusDeCooL
  • 5,639
  • 17
  • 68
  • 102

1 Answers1

3

You should reflect the real class instead of the proxy.

Try this (not tested):

$realClass = \Doctrine\Common\Util\ClassUtils::getRealClass(get_class($entity));
$properties = (new \ReflectionClass($realClass))->getProperties();
Pi Wi
  • 1,076
  • 1
  • 11
  • 20