Пример #1
0
        /// <summary>
        /// Verifies that the contents of a variable can be called as a function.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="variable">The variable.</param>
        /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/>
        /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or
        /// method) is also verified.</param>
        /// <param name="callableName">Receives the name of the function or method (for example
        /// <c>SomeClass::SomeMethod</c>).</param>
        /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B>
        /// otherwise.</returns>
        public static bool is_callable(Context ctx /*, caller*/, PhpValue variable, bool syntaxOnly, out string callableName)
        {
            var callback = variable.AsCallable();

            if (PhpVariable.IsValidCallback(callback))
            {
                callableName = callback.ToString();
                return(true);
            }

            callableName = variable.ToString(ctx);
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Verifies that the contents of a variable can be called as a function.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="callerCtx">Type of the current calling context.</param>
        /// <param name="variable">The variable.</param>
        /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/>
        /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or
        /// method) is also verified.</param>
        /// <param name="callableName">Receives the name of the function or method (for example
        /// <c>SomeClass::SomeMethod</c>).</param>
        /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B>
        /// otherwise.</returns>
        public static bool is_callable(Context ctx, [ImportCallerClass] RuntimeTypeHandle callerCtx, PhpValue variable, bool syntaxOnly, out string callableName)
        {
            var callback = variable.AsCallable(callerCtx);

            if (PhpVariable.IsValidCallback(callback))
            {
                callableName = callback.ToString();
                return(true);
            }

            callableName = variable.ToString(ctx);
            return(false);
        }
Пример #3
0
 /// <summary>
 /// Verifies that the contents of a variable can be called as a function.
 /// </summary>
 /// <param name="ctx">Runtime context.</param>
 /// <param name="variable">The variable.</param>
 /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/>
 /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or
 /// method) is also verified.</param>
 /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B>
 /// otherwise.</returns>
 public static bool is_callable(Context ctx, IPhpCallable variable, bool syntaxOnly = false)
 {
     return(syntaxOnly
         ? PhpVariable.IsValidCallback(variable)
         : PhpVariable.IsValidBoundCallback(ctx, variable));
 }
Пример #4
0
 /// <summary>
 /// Verifies that the contents of a variable can be called as a function.
 /// </summary>
 /// <param name="variable">The variable.</param>
 /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/>
 /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or
 /// method) is also verified.</param>
 /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B>
 /// otherwise.</returns>
 public static bool is_callable(PhpValue variable, bool syntaxOnly = false)
 {
     return(PhpVariable.IsValidCallback(variable.AsCallable()));  // TODO: check syntaxOnly || can be bound
 }