You are here

protected function PropertyMetadata::newReflectionMember in Plug 7

Creates a new reflection instance for accessing the member's value.

Must be implemented by subclasses.

Parameters

object|string $objectOrClassName The object or the class name:

Return value

\ReflectionMethod|\ReflectionProperty The reflection instance

Overrides MemberMetadata::newReflectionMember

File

lib/Symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php, line 59

Class

PropertyMetadata
Stores all metadata needed for validating a class property.

Namespace

Symfony\Component\Validator\Mapping

Code

protected function newReflectionMember($objectOrClassName) {
  $class = new \ReflectionClass($objectOrClassName);
  while (!$class
    ->hasProperty($this
    ->getName())) {
    $class = $class
      ->getParentClass();
  }
  $member = new \ReflectionProperty($class
    ->getName(), $this
    ->getName());
  $member
    ->setAccessible(true);
  return $member;
}