Skip to content

Commit

Permalink
Merge pull request #1 from tschaible/proxy-reflection-fix
Browse files Browse the repository at this point in the history
doctrine proxy reflection fix
  • Loading branch information
ScorpioT1000 authored Oct 25, 2017
2 parents a4bf5ab + 0d65b6d commit 3fb41c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Traits/Transformable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public function toArray(
if(!$ar) { $ar = static::createCachedReader(); }
if(!$pr) { $pr = new PolicyResolver(); }
$refClass = new \ReflectionClass($this);
if ($refClass->getName() !== static::getEntityFullName($refClass)) {
// if this was a proxy, use the base class for reflection
$refClass = new \ReflectionClass(static::getEntityFullName($refClass));
}
$result = ['__meta' => ['class' => static::getEntityFullName($refClass)]];
$ps = $refClass->getProperties( \ReflectionProperty::IS_PUBLIC
| \ReflectionProperty::IS_PROTECTED
Expand Down Expand Up @@ -526,4 +530,4 @@ protected static function getEntityFullName(\ReflectionClass $headRefClass, $nam
public static function createCachedReader() {
return new CachedReader(new AnnotationReader(), new ArrayCache());
}
}
}

0 comments on commit 3fb41c2

Please sign in to comment.