/// <summary>
        /// Determines PHP type name of an exported PHP type.
        /// Gets default&lt;QualifiedName&gt; if type is not exported PHP type.
        /// </summary>
        public static QualifiedName GetPhpTypeNameOrNull(this PENamedTypeSymbol s)
        {
            var attrs = s.GetAttributes();

            if (attrs.Length != 0)
            {
                for (int i = 0; i < attrs.Length; i++)
                {
                    if (attrs[i].AttributeClass.MetadataName == "PhpTypeAttribute")
                    {
                        var ctorargs = attrs[i].ConstructorArguments;
                        var tname    = ctorargs[0];
                        var tnamestr = tname.IsNull ? null : tname.DecodeValue <string>(SpecialType.System_String);

                        const string InheritName = "[name]";

                        if (tnamestr == null)
                        {
                            return(s.MakeQualifiedName());
                        }
                        else if (tnamestr == InheritName)
                        {
                            return(new QualifiedName(new Name(s.Name)));
                        }
                        else
                        {
                            return(QualifiedName.Parse(tnamestr.Replace(InheritName, s.Name), true));
                        }
                    }
                }
            }

            return(default(QualifiedName));
        }
Exemple #2
0
        /// <summary>
        /// Determines PHP type name of an exported PHP type.
        /// Gets default&lt;QualifiedName&gt; if type is not exported PHP type.
        /// </summary>
        public static QualifiedName GetPhpTypeNameOrNull(this PENamedTypeSymbol s)
        {
            if (TryGetPhpTypeAttribute(s, out var tname, out var fname))
            {
                return(tname != null
                    ? QualifiedName.Parse(tname, true)
                    : s.MakeQualifiedName());
            }

            return(default);
Exemple #3
0
        /// <summary>
        /// Determines PHP type name of an exported PHP type.
        /// Gets default&lt;QualifiedName&gt; if type is not exported PHP type.
        /// </summary>
        public static QualifiedName GetPhpTypeNameOrNull(this PENamedTypeSymbol s)
        {
            var attrs = s.GetAttributes();

            if (attrs.Length != 0)
            {
                for (int i = 0; i < attrs.Length; i++)
                {
                    if (attrs[i].AttributeClass.MetadataName == "PhpTypeAttribute")
                    {
                        var ctorargs = attrs[i].ConstructorArguments;
                        var tname    = ctorargs[0];
                        return(tname.IsNull ? s.MakeQualifiedName() : QualifiedName.Parse(tname.DecodeValue <string>(SpecialType.System_String), true));
                    }
                }
            }

            return(default(QualifiedName));
        }