You are here

public function RuntimePublicReflectionProperty::getValue in Plug 7

Checks is the value actually exist before fetching it. This is to avoid calling `__get` on the provided $object if it is a {

See also

\Doctrine\Common\Proxy\Proxy}.

File

lib/doctrine/common/lib/Doctrine/Common/Reflection/RuntimePublicReflectionProperty.php, line 40

Class

RuntimePublicReflectionProperty
PHP Runtime Reflection Public Property - special overrides for public properties.

Namespace

Doctrine\Common\Reflection

Code

public function getValue($object = null) {
  $name = $this
    ->getName();
  if ($object instanceof Proxy && !$object
    ->__isInitialized()) {
    $originalInitializer = $object
      ->__getInitializer();
    $object
      ->__setInitializer(null);
    $val = isset($object->{$name}) ? $object->{$name} : null;
    $object
      ->__setInitializer($originalInitializer);
    return $val;
  }
  return isset($object->{$name}) ? parent::getValue($object) : null;
}