XmlDeserializer::GetTypeHint PHP Méthode

GetTypeHint() private méthode

Determines the type hint of the specified property of the given class.
private GetTypeHint ( string $className, string $propertyName ) : null | string
$className string the class name whose the given property's type will be determined
$propertyName string the property name whose type will be determined
Résultat null | string the type hint of the property
    private function GetTypeHint($className, $propertyName)
    {
        $typeHint = null;
        $clazz = new ReflectionClass($className);
        // Use reflection to get a property of the class whose name is the
        // same as the property's tag name.
        // Then extract the type hint from the annotation of the property.
        if ($clazz->hasProperty($propertyName)) {
            $prop = $clazz->getProperty($propertyName);
            if (preg_match('/@var\\s*(.+)\\s/', $prop->getDocComment(), $annotations)) {
                // The type hints are sometimes prefixed with "tns", which is stripped
                // here to extract only the type names.
                $typeHint = preg_replace('/^tns/', '', $annotations[1]);
            }
        }
        return $typeHint;
    }