Пример #1
0
        /// <summary>
        /// Default implementation of PHP autoload looks for <c>__autoload</c> global function and calls it.
        /// </summary>
        PhpTypeInfo IPhpAutoloadService.AutoloadTypeByName(string fullName)
        {
            var autoload = _lazyAutoloadRoutine;

            if (autoload == null)
            {
                _lazyAutoloadRoutine = autoload = GetDeclaredFunction(AutoloadFunctionName);

                if (autoload == null)
                {
                    return(null);
                }
            }

            using (var token = new RecursionCheckToken(this, fullName))
            {
                if (!token.IsInRecursion)
                {
                    // CALL __autoload(fullName)
                    autoload.PhpCallable(this, new PhpValue[] { (PhpValue)fullName });

                    //
                    return(GetDeclaredType(fullName));
                }
            }

            //
            return(null);
        }
Пример #2
0
        /// <summary>
        /// Default implementation of PHP autoload looks for <c>__autoload</c> global function and calls it.
        /// </summary>
        PhpTypeInfo IPhpAutoloadService.AutoloadTypeByName(string fullName)
        {
            var autoload = _lazyAutoloadRoutine;

            if (autoload == null)
            {
                _lazyAutoloadRoutine = autoload = GetDeclaredFunction(AutoloadFunctionName);

                if (autoload == null)
                {
                    return(null);
                }
            }

            // remove leading \ from the type name
            if (fullName.Length != 0 && fullName[0] == '\\')
            {
                fullName = fullName.Substring(1);
            }

            //
            using (var token = new RecursionCheckToken(this, fullName.ToLowerInvariant()))
            {
                if (!token.IsInRecursion)
                {
                    // CALL __autoload(fullName)
                    autoload.PhpCallable(this, new PhpValue[] { (PhpValue)fullName });

                    //
                    return(GetDeclaredType(fullName));
                }
            }

            //
            return(null);
        }