Phan\Language\FQSEN\FullyQualifiedGlobalStructuralElement::fromStringInContext PHP Méthode

fromStringInContext() public static méthode

public static fromStringInContext ( string $fqsen_string, Context $context ) : static
$fqsen_string string An FQSEN string like '\Namespace\Class'
$context Phan\Language\Context The context in which the FQSEN string was found
Résultat static
    public static function fromStringInContext(string $fqsen_string, Context $context)
    {
        // Check to see if we're fully qualified
        if (0 === strpos($fqsen_string, '\\')) {
            return static::fromFullyQualifiedString($fqsen_string);
        }
        // Split off the alternate ID
        $parts = explode(',', $fqsen_string);
        $fqsen_string = $parts[0];
        $alternate_id = (int) ($parts[1] ?? 0);
        assert(is_int($alternate_id), "Alternate must be an integer");
        $parts = explode('\\', $fqsen_string);
        $name = array_pop($parts);
        assert(!empty($name), "The name cannot be empty");
        // Check for a name map
        if ($context->hasNamespaceMapFor(static::getNamespaceMapType(), $name)) {
            return $context->getNamespaceMapFor(static::getNamespaceMapType(), $name);
        }
        $namespace = implode('\\', array_filter($parts));
        // n.b.: Functions must override this method because
        //       they don't prefix the namespace for naked
        //       calls
        if (empty($namespace)) {
            $namespace = $context->getNamespace();
        }
        return static::make($namespace, $name, $alternate_id);
    }