Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PropertyMetadata.php

function PropertyMetadata::getPropertyValue

Overrides PropertyMetadataInterface::getPropertyValue

File

vendor/symfony/validator/Mapping/PropertyMetadata.php, line 46

Class

PropertyMetadata
Stores all metadata needed for validating a class property.

Namespace

Symfony\Component\Validator\Mapping

Code

public function getPropertyValue(mixed $object) : mixed {
    $reflProperty = $this->getReflectionMember($object);
    if ($reflProperty->hasType() && !$reflProperty->isInitialized($object)) {
        // There is no way to check if a property has been unset or if it is uninitialized.
        // When trying to access an uninitialized property, __get method is triggered.
        // If __get method is not present, no fallback is possible
        // Otherwise we need to catch an Error in case we are trying to access an uninitialized but set property.
        if (!method_exists($object, '__get')) {
            return null;
        }
        try {
            return $reflProperty->getValue($object);
        } catch (\Error) {
            return null;
        }
    }
    return $reflProperty->getValue($object);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal