1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
6: */
7:
8: namespace Nette\Reflection;
9:
10: use Nette;
11:
12:
13: /**
14: * @author Jáchym Toušek
15: */
16: class Helpers
17: {
18:
19: /**
20: * Returns declaring class or trait.
21: * @return \ReflectionClass
22: * @internal
23: */
24: public static function getDeclaringClass(\ReflectionProperty $prop)
25: {
26: if (PHP_VERSION_ID >= 50400) {
27: foreach ($prop->getDeclaringClass()->getTraits() as $trait) {
28: if ($trait->hasProperty($prop->getName())) {
29: return self::getDeclaringClass($trait->getProperty($prop->getName()));
30: }
31: }
32: }
33: return $prop->getDeclaringClass();
34: }
35:
36: }
37: