Twig/UtilsExtension.php
public function getProperty($object, $propertyPath, $required = true)
    {
        if (!$required) {
            try {
                return $this->accessor->getValue($object, $propertyPath);
            } catch(NoSuchIndexException $e) {
                return null;
            }
        }
        return $this->accessor->getValue($object, $propertyPath);
    }
public function getProperty($object, $propertyPath, $required = true)
    {
        if (!$required) {
            try {
                return $this->accessor->getValue($object, $propertyPath);
            } catch(NoSuchIndexException $e) {
                return null;
            }
        }
        return $this->accessor->getValue($object, $propertyPath);
    }
Uses PropertyAccess component to return the object property value.

@param mixed  $object
@param string $propertyPath
@param bool   $required

@return mixed