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