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


PHP ReflectionClass::GetMethods方法代码示例

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


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

示例1: run

 public static function run($className)
 {
     $runner = new TestRunner();
     $rc = new ReflectionClass($className);
     $methods = $rc->GetMethods(ReflectionMethod::IS_PUBLIC);
     foreach ($methods as $m) {
         $name = $m->name;
         if (!$runner->isValidTest($name)) {
             continue;
         }
         $count = count($className::$errors);
         $rt = new $className();
         try {
             $rt->setUp();
             $rt->{$name}();
             echo $count === count($className::$errors) ? "." : "F";
         } catch (Exception $e) {
             if ($e instanceof RedisException) {
                 $className::$errors[] = "Uncaught exception '" . $e->getMessage() . "' ({$name})\n";
                 echo 'F';
             } else {
                 echo 'S';
             }
         }
     }
     echo "\n";
     echo implode('', $className::$warnings);
     if (empty($className::$errors)) {
         echo "All tests passed.\n";
         return 0;
     }
     echo implode('', $className::$errors);
     return 1;
 }
开发者ID:stonegithubs,项目名称:phpredis,代码行数:34,代码来源:test.php

示例2: run

 public static function run($className, $str_limit)
 {
     $rc = new ReflectionClass($className);
     $methods = $rc->GetMethods(ReflectionMethod::IS_PUBLIC);
     $i_limit = -1;
     $i_idx = 0;
     $boo_printed = false;
     $arr_ran_methods = array();
     if ($str_limit && is_numeric($str_limit)) {
         echo "Limiting to {$str_limit} tests!\n";
         $i_limit = (int) $str_limit;
     } else {
         if ($str_limit) {
             echo "Limiting to tests with the substring: '{$str_limit}'\n";
         }
     }
     foreach ($methods as $m) {
         $name = $m->name;
         if (substr($name, 0, 4) !== 'test') {
             continue;
         }
         /* If TestRedis.php was envoked with an argument, do a simple
          * match against the routine.  Useful to limit to one test */
         if ($i_limit == -1 && $str_limit && strpos(strtolower($name), strtolower($str_limit)) === false) {
             continue;
         }
         if ($i_limit > -1 && $i_idx++ >= $i_limit) {
             continue;
         }
         $arr_ran_methods[] = $name;
         $count = count($className::$errors);
         $rt = new $className();
         try {
             $rt->setUp();
             $rt->{$name}();
             echo $count === count($className::$errors) ? "." : "F";
         } catch (Exception $e) {
             if ($e instanceof RedisException) {
                 $className::$errors[] = "Uncaught exception '" . $e->getMessage() . "' ({$name})\n";
                 echo 'F';
             } else {
                 echo 'S';
             }
         }
     }
     echo "\n";
     echo implode('', $className::$warnings);
     echo " --- tests run ---\n";
     echo implode("\n", $arr_ran_methods) . "\n";
     echo " --- fin ---\n";
     if (empty($className::$errors)) {
         echo "All tests passed.\n";
         return 0;
     }
     echo implode('', $className::$errors);
     return 1;
 }
开发者ID:MrGekko,项目名称:phpredis,代码行数:57,代码来源:test.php

示例3: run

 public static function run($className)
 {
     $rc = new ReflectionClass($className);
     $methods = $rc->GetMethods(ReflectionMethod::IS_PUBLIC);
     foreach ($methods as $m) {
         $name = $m->name;
         if (substr($name, 0, 4) !== 'test') {
             continue;
         }
         $count = count($className::$errors);
         $rt = new $className();
         $rt->setUp();
         $rt->{$name}();
         echo $count === count($className::$errors) ? "." : "F";
     }
     echo "\n";
     if (empty($className::$errors)) {
         echo "All tests passed.\n";
     }
     echo implode('', $className::$errors);
 }
开发者ID:neatstudio,项目名称:phpredis,代码行数:21,代码来源:test.php

示例4: LinkObject

 public function LinkObject($Object, $ConstsWithPrefix = true, $MethodsWithPrefix = false, $PropertiesWithPrefix = false)
 {
     # Reflection
     $Class = new ReflectionClass($Object);
     $ClassName = $Class->GetShortName();
     $Constants = $Class->GetConstants();
     $Methods = $Class->GetMethods(ReflectionMethod::IS_PUBLIC);
     $Properties = $Class->GetProperties(ReflectionProperty::IS_PUBLIC);
     # Prefixes
     $ClassPrefix = $ClassName . '_';
     $ConstsPrefix = $ConstsWithPrefix ? strtoupper($ClassPrefix) : null;
     $MethodsPrefix = $MethodsWithPrefix ? $ClassPrefix : null;
     $PropertiesPrefix = $PropertiesWithPrefix ? $ClassPrefix : null;
     # Consts
     $this->AssignVariables($Constants, $ConstsPrefix);
     # Callbacks
     /**
      * If you can do this
      * In one line
      * Without using aux vars
      * Without repeating code
      * Without doing things like: asd($a = dsa(), ...)
      * 
      * YOU'RE A GOD. 
      */
     // Convert ReflectionMethod's into array(MethodName => Callback, [...])
     $Methods = array_map(function ($Method) {
         return $Method->name;
     }, $Methods);
     $Methods = array_combine($Methods, array_map(function ($Method) use($Object) {
         return array($Object, $Method);
     }, $Methods));
     $Methods = array_filter($Methods, function ($Method) {
         return strpos($Method, '__') !== 0;
     }, ARRAY_FILTER_USE_KEY);
     $this->RegisterCallbacks($Methods, $MethodsPrefix);
     # Vars
     // Convert ReflectionProperty's into array(PropertyName => Value, [...])
     $Properties = array_map(function ($Property) {
         return $Property->name;
     }, $Properties);
     $Properties = array_combine($Properties, array_map(function ($Property) use($Object) {
         return $Object->{$Property};
     }, $Properties));
     $this->AssignVariables($Properties);
     return true;
     // Return consts && methods && properties (all of it)
 }
开发者ID:hasanalom,项目名称:WhatsBot,代码行数:48,代码来源:LuaWithPHP.php

示例5: run

 public static function run($className, $str_limit = NULL)
 {
     /* Lowercase our limit arg if we're passed one */
     $str_limit = $str_limit ? strtolower($str_limit) : $str_limit;
     $rc = new ReflectionClass($className);
     $methods = $rc->GetMethods(ReflectionMethod::IS_PUBLIC);
     $i_max_len = self::getMaxTestLen($methods, $str_limit);
     foreach ($methods as $m) {
         $name = $m->name;
         if (substr($name, 0, 4) !== 'test') {
             continue;
         }
         /* If we're trying to limit to a specific test and can't match the
          * substring, skip */
         if ($str_limit && strstr(strtolower($name), $str_limit) === FALSE) {
             continue;
         }
         $str_out_name = str_pad($name, $i_max_len + 1);
         echo self::make_bold($str_out_name);
         $count = count($className::$errors);
         $rt = new $className();
         try {
             $rt->setUp();
             $rt->{$name}();
             if ($count === count($className::$errors)) {
                 $str_msg = self::make_success('PASSED');
             } else {
                 $str_msg = self::make_fail('FAILED');
             }
             //echo ($count === count($className::$errors)) ? "." : "F";
         } catch (Exception $e) {
             if ($e instanceof RedisException) {
                 $className::$errors[] = "Uncaught exception '" . $e->getMessage() . "' ({$name})\n";
                 $str_msg = self::make_fail('FAILED');
             } else {
                 $str_msg = self::make_warning('SKIPPED');
             }
         }
         echo "[" . $str_msg . "]\n";
     }
     echo "\n";
     echo implode('', $className::$warnings) . "\n";
     if (empty($className::$errors)) {
         echo "All tests passed. \\o/\n";
         return 0;
     }
     echo implode('', $className::$errors);
     return 1;
 }
开发者ID:qmario,项目名称:phpredis-2.5.5,代码行数:49,代码来源:TestSuite.php


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