本文整理汇总了PHP中Info::reflection方法的典型用法代码示例。如果您正苦于以下问题:PHP Info::reflection方法的具体用法?PHP Info::reflection怎么用?PHP Info::reflection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Info
的用法示例。
在下文中一共展示了Info::reflection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: po_generate
/**
* クラスファイルからgettext文字列を抜き出してpotファイルを作成する
* @param string $path
* @param string $lc_messages_path
*/
public static function po_generate($path, $lc_messages_path)
{
$messages = array();
foreach (File::ls($path, true) as $file) {
if ($file->isClass()) {
ob_start();
include_once $file->fullname();
Rhaco::import($file->oname());
ob_get_clean();
$ref = Info::reflection($file->oname());
foreach ($ref->methods as $method) {
foreach ($method->gettext as $text) {
$messages[$text->str]["#: " . str_replace($path, "", $file->fullname()) . ":" . $text->line] = true;
}
}
}
}
ksort($messages, SORT_STRING);
$output_src = sprintf(Text::plain('
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE\'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\\n"
"Report-Msgid-Bugs-To: \\n"
"POT-Creation-Date: %s\\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
"Language-Team: LANGUAGE <team@exsample.com>\\n"
'), date("Y-m-d H:iO")) . "\n\n";
foreach ($messages as $str => $lines) {
$output_src .= "\n" . implode("\n", array_keys($lines)) . "\n";
$output_src .= "msgid \"" . $str . "\"\n";
$output_src .= "msgstr \"\"\n";
}
File::write(File::absolute($lc_messages_path, "messages.pot"), $output_src);
//Rhaco::import("ext.Setup");
//Setup::po_generate(dirname(__FILE__),Rhaco::selfpath()."/resources/locale/");
//Setup::mo_generate(Rhaco::selfpath()."/resources/locale/");
//Test::each_flush();
}
示例2: verify
/**
* テストを実行する
* @param string $class クラス名
* @param strgin $method メソッド名
*/
public static final function verify($class, $method = null, $block_name = null)
{
if (!class_exists($class) && Rhaco::import($class)) {
$pos = strrpos($class, ".");
$class = substr($class, $pos !== false ? $pos + 1 : $pos);
}
$ref = Info::reflection($class);
self::$current_file = $ref->path;
self::$current_class = $ref->name;
foreach ($ref->methods as $name => $m) {
self::$current_method = $name;
if ($method === null || $method == $name) {
self::execute($m, $block_name);
}
}
self::$current_class = null;
self::$current_file = null;
self::$current_method = null;
return new self();
}