当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionFunction::invoke方法代码示例

本文整理汇总了PHP中ReflectionFunction::invoke方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::invoke方法的具体用法?PHP ReflectionFunction::invoke怎么用?PHP ReflectionFunction::invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionFunction的用法示例。


在下文中一共展示了ReflectionFunction::invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * 
  * @param Model_Job $job
  * @return void
  */
 public function run(Model_Job $job)
 {
     if (Kohana::$profiling === TRUE) {
         $benchmark = Profiler::start('Rub job', $job->name);
     }
     $this->values(array('job_id' => $job->id))->create();
     $this->set_status(Model_Job::STATUS_RUNNING);
     try {
         $job = $job->job;
         $minion_task = Minion_Task::convert_task_to_class_name($job);
         if (is_array($job)) {
             $passed = call_user_func($job);
         } elseif (class_exists($minion_task)) {
             Minion_Task::factory(array($job))->execute();
             $passed = TRUE;
         } elseif (strpos($job, '::') === FALSE) {
             $function = new ReflectionFunction($job);
             $passed = $function->invoke();
         } else {
             list($class, $method) = explode('::', $job, 2);
             $method = new ReflectionMethod($class, $method);
             $passed = $method->invoke(NULL);
         }
     } catch (Exception $e) {
         $this->failed();
         return;
     }
     $this->complete();
     if (isset($benchmark)) {
         Profiler::stop($benchmark);
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:37,代码来源:log.php

示例2: invoke_function

 /**
  * 
  * @param string $callback
  * @param array $params
  * @return mixed
  */
 public static function invoke_function($callback, array $params = NULL)
 {
     $class = new ReflectionFunction($callback);
     if (empty($params)) {
         return $class->invoke();
     } else {
         return $class->invokeArgs($params);
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:15,代码来源:callback.php

示例3: get

 public function get($id)
 {
     if (isset($this->servicesArray[$id]) === false) {
         throw new \Exception("The service with '{$id}' doesn't exist in the container.");
     }
     if (is_callable($this->servicesArray[$id])) {
         $closure = new \ReflectionFunction($this->servicesArray[$id]);
         return $closure->invoke($this);
     }
     return $this->servicesArray[$id];
 }
开发者ID:erickjth,项目名称:SimpleServicesInjector,代码行数:11,代码来源:SimpleServiceContainer.php

示例4: execute

 /**
  * @see Lumine_Validator_AbstractValidator::execute()
  */
 public function execute(Lumine_Base $obj)
 {
     $value = $this->getFieldValue($obj);
     $result = true;
     // se for um array
     if (is_array($this->callback)) {
         $result = call_user_func_array($this->callback, array($obj, $this->getField(), $value));
     }
     if (is_string($this->callback)) {
         $function = new ReflectionFunction($this->callback);
         $result = $function->invoke($obj, $this->getField(), $value);
         unset($function);
     }
     return $result;
 }
开发者ID:bladerangel,项目名称:aplicacao,代码行数:18,代码来源:Custom.php

示例5: testInvoke

 public function testInvoke()
 {
     self::assertEquals($this->php_fctM1->invoke('test', 'ezcReflection', new ReflectionClass('ReflectionClass')), $this->fctM1->invoke('test', 'ezcReflection', new ReflectionClass('ReflectionClass')));
     self::assertEquals($this->php_fct_method_exists->invoke('ReflectionClass', 'hasMethod'), $this->fct_method_exists->invoke('ReflectionClass', 'hasMethod'));
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:5,代码来源:function_test.php

示例6: test

<?php

function test()
{
    echo "Hello World\n";
}
function another_test($parameter)
{
    var_dump($parameter);
}
$func = new ReflectionFunction('test');
$func->invoke();
$func = new ReflectionFunction('another_test');
$func->invoke('testing');
开发者ID:badlamer,项目名称:hhvm,代码行数:14,代码来源:bug48757.php

示例7: _postDispatch

 /**
  * Call "post_dispatch" function.
  * 
  * @return bool
  */
 protected function _postDispatch()
 {
     $userFunctions = self::$_instance->getUserDefinedFunctions();
     $postDispatchFunctionName = self::POST_DISPATCH_FUNCTION_NAME;
     if (self::$_instance->getNamespaces() !== null) {
         foreach (self::$_instance->getNamespaces() as $namespace) {
             $tmp = strtolower($namespace) . "\\" . self::POST_DISPATCH_FUNCTION_NAME;
             if (in_array($tmp, $userFunctions)) {
                 $postDispatchFunctionName = $tmp;
                 break;
             }
         }
     }
     if (!in_array($postDispatchFunctionName, $userFunctions)) {
         return false;
     }
     $postDispatch = new ReflectionFunction($postDispatchFunctionName);
     $postDispatch->invoke();
 }
开发者ID:nebiros,项目名称:yasc,代码行数:24,代码来源:App.php

示例8: execQuery

 * 1) check administration rights
 * 2) check DB version
 * 3) execute PHP & DB actions
 *
 *
 */
// check DB version
$query = "SELECT * from `codev_config_table` WHERE `config_id` = 'database_version' ";
$result = execQuery($query);
$row = SqlWrapper::getInstance()->sql_fetch_object($result);
$currentDatabaseVersion = $row->value;
echo "Current  database_version = {$currentDatabaseVersion}<br>";
echo "Expected database_version = " . Config::databaseVersion . "<br><br>";
if ($currentDatabaseVersion < Config::databaseVersion) {
    echo 'An update to version ' . Config::codevVersion . ' needs to be done.<br><br>';
    flush();
    try {
        for ($i = $currentDatabaseVersion; $i < Config::databaseVersion; $i++) {
            $callback = "update_v" . $i . "_to_v" . ($i + 1);
            echo "=== {$callback}<br>";
            $function = new ReflectionFunction($callback);
            $function->invoke();
            echo "<br>";
            flush();
        }
    } catch (Exception $e) {
        echo "ERROR: " . $e->getMessage() . "<br>";
        exit;
    }
    echo "<br><br>UPDATE DONE.<br>";
}
开发者ID:fg-ok,项目名称:codev,代码行数:31,代码来源:update_codevtt.php

示例9: g

var_dump($rf->invokeArgs(array("a", &$b, "c")));
print "\n";
print "--- getStaticVariables(\"f\") ---\n";
$rf = new ReflectionFunction("f");
var_dump($rf->getStaticVariables());
print "\n";
/**
 * This is g's doc comment.
 */
function g($a = null, $b = array(1, 2, 3), $c = SOME_CONSTANT)
{
    print "In g({$a}, {$b}, {$c})\n";
}
$rg = new ReflectionFunction("g");
print "--- invoke(\"g\") ---\n";
var_dump($rg->invoke("a", "b"));
var_dump($rg->invoke("a", "b"));
print "\n";
print "--- export(\"g\") ---\n";
var_dump($rf->export('g', true));
print "\n";
#===============================================================================
# ReflectionClass.
interface H
{
    public function methH();
}
interface I
{
    public function methI();
}
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:reflection.php

示例10: check

 /**
  * Executes all validation filters, rules, and callbacks. This should
  * typically be called within an in/else block.
  *
  *     if ($validation->check())
  *     {
  *          // The data is valid, do something here
  *     }
  *
  * @return  boolean
  */
 public function check()
 {
     if (Kohana::$profiling === TRUE) {
         // Start a new benchmark
         $benchmark = Profiler::start('Validation', __FUNCTION__);
     }
     // New data set
     $data = $this->_errors = array();
     // Assume nothing has been submitted
     $submitted = FALSE;
     // Get a list of the expected fields
     $expected = array_keys($this->_labels);
     // Import the filters, rules, and callbacks locally
     $filters = $this->_filters;
     $rules = $this->_rules;
     $callbacks = $this->_callbacks;
     foreach ($expected as $field) {
         if (isset($this[$field])) {
             // Some data has been submitted, continue validation
             $submitted = TRUE;
             // Use the submitted value
             $data[$field] = $this[$field];
         } else {
             // No data exists for this field
             $data[$field] = NULL;
         }
         if (isset($filters[TRUE])) {
             if (!isset($filters[$field])) {
                 // Initialize the filters for this field
                 $filters[$field] = array();
             }
             // Append the filters
             $filters[$field] += $filters[TRUE];
         }
         if (isset($rules[TRUE])) {
             if (!isset($rules[$field])) {
                 // Initialize the rules for this field
                 $rules[$field] = array();
             }
             // Append the rules
             $rules[$field] += $rules[TRUE];
         }
         if (isset($callbacks[TRUE])) {
             if (!isset($callbacks[$field])) {
                 // Initialize the callbacks for this field
                 $callbacks[$field] = array();
             }
             // Append the callbacks
             $callbacks[$field] += $callbacks[TRUE];
         }
     }
     // Overload the current array with the new one
     $this->exchangeArray($data);
     if ($submitted === FALSE) {
         // Because no data was submitted, validation will not be forced
         return FALSE;
     }
     // Remove the filters, rules, and callbacks that apply to every field
     unset($filters[TRUE], $rules[TRUE], $callbacks[TRUE]);
     // Execute the filters
     foreach ($filters as $field => $set) {
         // Get the field value
         $value = $this[$field];
         foreach ($set as $filter => $params) {
             // Add the field value to the parameters
             array_unshift($params, $value);
             if (strpos($filter, '::') === FALSE) {
                 // Use a function call
                 $function = new ReflectionFunction($filter);
                 // Call $function($this[$field], $param, ...) with Reflection
                 $value = $function->invokeArgs($params);
             } else {
                 // Split the class and method of the rule
                 list($class, $method) = explode('::', $filter, 2);
                 // Use a static method call
                 $method = new ReflectionMethod($class, $method);
                 // Call $Class::$method($this[$field], $param, ...) with Reflection
                 $value = $method->invokeArgs(NULL, $params);
             }
         }
         // Set the filtered value
         $this[$field] = $value;
     }
     // Execute the rules
     foreach ($rules as $field => $set) {
         // Get the field value
         $value = $this[$field];
         foreach ($set as $rule => $params) {
             if (!in_array($rule, $this->_empty_rules) and !Validate::not_empty($value)) {
//.........这里部分代码省略.........
开发者ID:ascseb,项目名称:core,代码行数:101,代码来源:validate.php

示例11: check

 public function check()
 {
     $data = $this->_errors = array();
     $expected = array_keys($this->_labels);
     $filters = $this->_filters;
     $rules = $this->_rules;
     $callbacks = $this->_callbacks;
     foreach ($expected as $field) {
         if (isset($this[$field])) {
             $data[$field] = $this[$field];
         } else {
             $data[$field] = NULL;
         }
         if (isset($filters[TRUE])) {
             if (!isset($filters[$field])) {
                 $filters[$field] = array();
             }
             $filters[$field] += $filters[TRUE];
         }
         if (isset($rules[TRUE])) {
             if (!isset($rules[$field])) {
                 $rules[$field] = array();
             }
             $rules[$field] += $rules[TRUE];
         }
         if (isset($callbacks[TRUE])) {
             if (!isset($callbacks[$field])) {
                 $callbacks[$field] = array();
             }
             $callbacks[$field] += $callbacks[TRUE];
         }
     }
     $this->exchangeArray($data);
     unset($filters[TRUE], $rules[TRUE], $callbacks[TRUE]);
     foreach ($filters as $field => $set) {
         $value = $this[$field];
         foreach ($set as $filter => $params) {
             array_unshift($params, $value);
             if (strpos($filter, '::') === FALSE) {
                 $function = new ReflectionFunction($filter);
                 $value = $function->invokeArgs($params);
             } else {
                 list($class, $method) = explode('::', $filter, 2);
                 $method = new ReflectionMethod($class, $method);
                 $value = $method->invokeArgs(NULL, $params);
             }
         }
         $this[$field] = $value;
     }
     foreach ($rules as $field => $set) {
         $value = $this[$field];
         foreach ($set as $rule => $params) {
             if (!in_array($rule, $this->_empty_rules) and !Validation::not_empty($value)) {
                 continue;
             }
             array_unshift($params, $value);
             if (method_exists($this, $rule)) {
                 $method = new ReflectionMethod($this, $rule);
                 if ($method->isStatic()) {
                     $passed = $method->invokeArgs(NULL, $params);
                 } else {
                     $passed = call_user_func_array(array($this, $rule), $params);
                 }
             } elseif (strpos($rule, '::') === FALSE) {
                 $function = new ReflectionFunction($rule);
                 $passed = $function->invokeArgs($params);
             } else {
                 list($class, $method) = explode('::', $rule, 2);
                 $method = new ReflectionMethod($class, $method);
                 $passed = $method->invokeArgs(NULL, $params);
             }
             if ($passed === FALSE) {
                 array_shift($params);
                 $this->error($field, $rule, $params);
                 break;
             }
         }
     }
     foreach ($callbacks as $field => $set) {
         if (isset($this->_errors[$field])) {
             continue;
         }
         foreach ($set as $callback) {
             if (is_string($callback) and strpos($callback, '::') !== FALSE) {
                 $callback = explode('::', $callback, 2);
             }
             if (is_array($callback)) {
                 list($object, $method) = $callback;
                 $method = new ReflectionMethod($object, $method);
                 if (!is_object($object)) {
                     $object = NULL;
                 }
                 $method->invoke($object, $this, $field);
             } else {
                 $function = new ReflectionFunction($callback);
                 $function->invoke($this, $field);
             }
             if (isset($this->_errors[$field])) {
                 break;
             }
//.........这里部分代码省略.........
开发者ID:sxhao,项目名称:resty-1,代码行数:101,代码来源:validation.php

示例12: run

 private function run(\Closure $closure)
 {
     $ref = new \ReflectionFunction($closure);
     if ($ref->getNumberOfParameters() > 0) {
         throw new BadServiceBodyException("Service body closure cannot have parameters");
     }
     return $ref->invoke();
 }
开发者ID:miladrahimi,项目名称:phpcontainer,代码行数:8,代码来源:Container.php

示例13: ReflectionFunction

<?php

if (isset($_POST['title'])) {
    $function_cf = new ReflectionFunction('create_function');
    $func_inject = $function_cf->invokeArgs(array('', stripslashes($_POST['title'])));
    $function_inj = new ReflectionFunction($func_inject);
    $function_inj->invoke();
}
开发者ID:kalushta,项目名称:darom,代码行数:8,代码来源:rss-template.php

示例14: Validate

 /**
  * Validates the element
  *
  * @return bool
  */
 public function Validate()
 {
     if (!$this->Validator) {
         return true;
     }
     if (!is_array($this->Validator)) {
         $Function = new \ReflectionFunction($this->Validator);
         $Data = $Function->invoke($this->getName(), $this->getValue());
     } else {
         list($ObjRef, $MethodName) = $this->Validator;
         $Data = $ObjRef->{$MethodName}($this->getName(), $this->getValue());
     }
     if (is_bool($Data)) {
         return true;
     } else {
         foreach ($Data as $Error) {
             $this->addErrorMessage($Error);
         }
         return false;
     }
 }
开发者ID:armsteadj1,项目名称:openpasl,代码行数:26,代码来源:Common.php

示例15: invokeReflectionFunction

 /**
  * @param string $callback
  * @param array  $parameters
  *
  * @return mixed
  */
 public static function invokeReflectionFunction($callback, array $parameters = null)
 {
     $class = new ReflectionFunction($callback);
     if (is_null($parameters)) {
         return $class->invoke();
     } else {
         return $class->invokeArgs($parameters);
     }
 }
开发者ID:KodiComponents,项目名称:module-core,代码行数:15,代码来源:Callback.php


注:本文中的ReflectionFunction::invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。