function ReflectionHelper::getProperty
Retrieves property by name from object and all its ancestors.
Parameters
object|string $object:
string $name:
Return value
ReflectionProperty
Throws
ReflectionException
5 calls to ReflectionHelper::getProperty()
- DoctrineCollectionFilter::apply in vendor/
myclabs/ deep-copy/ src/ DeepCopy/ Filter/ Doctrine/ DoctrineCollectionFilter.php - Copies the object property doctrine collection.
- DoctrineEmptyCollectionFilter::apply in vendor/
myclabs/ deep-copy/ src/ DeepCopy/ Filter/ Doctrine/ DoctrineEmptyCollectionFilter.php - Sets the object property to an empty doctrine collection.
- PropertyTypeMatcher::matches in vendor/
myclabs/ deep-copy/ src/ DeepCopy/ Matcher/ PropertyTypeMatcher.php - ReplaceFilter::apply in vendor/
myclabs/ deep-copy/ src/ DeepCopy/ Filter/ ReplaceFilter.php - Replaces the object property by the result of the callback called with the object property.
- SetNullFilter::apply in vendor/
myclabs/ deep-copy/ src/ DeepCopy/ Filter/ SetNullFilter.php - Sets the object property to null.
File
-
vendor/
myclabs/ deep-copy/ src/ DeepCopy/ Reflection/ ReflectionHelper.php, line 58
Class
Namespace
DeepCopy\ReflectionCode
public static function getProperty($object, $name) {
$reflection = is_object($object) ? new ReflectionObject($object) : new ReflectionClass($object);
if ($reflection->hasProperty($name)) {
return $reflection->getProperty($name);
}
if ($parentClass = $reflection->getParentClass()) {
return self::getProperty($parentClass->getName(), $name);
}
throw new PropertyException(sprintf('The class "%s" doesn\'t have a property with the given name: "%s".', is_object($object) ? get_class($object) : $object, $name));
}