Пример #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="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
 }
Пример #3
0
 /// <summary>
 /// Gets value as a callable object that can be invoked dynamically.
 /// </summary>
 public static IPhpCallable AsCallable(PhpValue value) => value.AsCallable();
Пример #4
0
 /// <summary>
 /// Gets value as a callable object that can be invoked dynamically.
 /// </summary>
 public static IPhpCallable AsCallable(PhpValue value, RuntimeTypeHandle callerCtx) => value.AsCallable(callerCtx);
Пример #5
0
 /// <summary>
 /// Gets value as a callable object that can be invoked dynamically.
 /// </summary>
 public static IPhpCallable AsCallable(PhpValue value) => value.AsCallable();
Пример #6
0
 /// <summary>
 /// Gets value as a callable object that can be invoked dynamically.
 /// </summary>
 public static IPhpCallable AsCallable(PhpValue value, RuntimeTypeHandle callerCtx, object callerObj) => value.AsCallable(callerCtx, callerObj);