-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflectionUtil.php
More file actions
34 lines (30 loc) · 902 Bytes
/
ReflectionUtil.php
File metadata and controls
34 lines (30 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Oro\Component\PhpUtils;
/**
* Provides utility static methods to get class information via the reflection.
*/
class ReflectionUtil
{
/**
* Finds a property in a given class or any of its superclasses.
*
* @param \ReflectionClass $reflClass
* @param string $propertyName
*
* @return \ReflectionProperty|null
*/
public static function getProperty(\ReflectionClass $reflClass, $propertyName)
{
if ($reflClass->hasProperty($propertyName)) {
return $reflClass->getProperty($propertyName);
}
$reflClass = $reflClass->getParentClass();
while ($reflClass) {
if ($reflClass->hasProperty($propertyName)) {
return $reflClass->getProperty($propertyName);
}
$reflClass = $reflClass->getParentClass();
}
return null;
}
}