本文整理汇总了PHP中Lib::import方法的典型用法代码示例。如果您正苦于以下问题:PHP Lib::import方法的具体用法?PHP Lib::import怎么用?PHP Lib::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lib
的用法示例。
在下文中一共展示了Lib::import方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reflection_class
private static function reflection_class($path)
{
if (is_object($path)) {
$path = get_class($path);
}
if (strpos($path, '::') !== false) {
list($package, $path) = explode('::', $path, 2);
Lib::import($package);
$path = substr($path, ($p = strrpos($path, ".")) + ($p === false ? 0 : 1));
}
$class = Lib::import($path);
$ref = new ReflectionClass($class);
return array($ref, $class, $path);
}
示例2: __new__
protected function __new__()
{
if (func_num_args() == 1) {
$this->dict(func_get_arg(0));
}
if (!empty($this->con)) {
$db = self::connection($this->con);
$this->type = $db->type;
$this->host = $db->host;
$this->dbname = $db->dbname;
$this->user = $db->user;
$this->password = $db->password;
$this->port = $db->port;
$this->sock = $db->sock;
$this->connection = $db->connection;
$this->copy_module($db, true);
} else {
try {
$type = ucfirst(strtolower($this->type));
Rhaco::import("db.controller." . $type);
} catch (Exception $e) {
try {
Lib::import($this->type);
$type = preg_replace("/^.+\\.([^\\.]+)\$/", "\\1", $this->type);
} catch (Exception $e) {
throw new Exception("not support " . $this->type);
}
}
$this->type = $type;
$this->add_modules(new $type());
try {
$this->connection = new PDO($this->call_module("dsn", $this->dbname, $this->host, $this->port, $this->user, $this->password, $this->sock), $this->user, $this->password);
} catch (Exception $e) {
throw new Exception("access denied for " . $this->dbname);
}
$this->connection->beginTransaction();
}
}
示例3: execute_var
private static function execute_var($vars)
{
$results = array();
foreach ($vars as $var) {
$name = $var['name'];
$var_value = $var['value'];
if (isset($var['class'])) {
$r = new ReflectionClass(Lib::import($var['class']));
$var_value = empty($var['method']) ? empty($var_value) ? $r->newInstance() : $r->newInstance($var_value) : call_user_func_array(array($r->getMethod($var['method'])->isStatic() ? $r->getName() : $r->newInstance(), $var['method']), $var_value);
}
if (isset($results[$name])) {
if (!is_array($results[$name])) {
$results[$name] = array($results[$name]);
}
$results[$name][] = $var_value;
} else {
$results[$name] = $var_value;
}
}
return $results;
}
示例4: import
/**
* importし、クラス名を返す
* @param string $class_path
* @return string
*/
function import($class_path)
{
return Lib::import($class_path);
}
示例5: __setup_add_module__
/**
* クラスモジュールを設定する
* ex.
* -add_module Log -module org.rhaco.io.log.LogFile
*
* @param Request $req
* @param string $value 設定するクラス
*/
public static function __setup_add_module__(Request $req, $value)
{
$module = $req->in_vars("module");
if (empty($module) || empty($value)) {
self::cmd_info("add_module");
}
$src = File::read(App::path("__settings__.php"));
Lib::import($value);
Lib::import($module);
if (preg_match("/C(R([\"']" . $value . "[\"']))->add_module(R([\"']" . $module . "[\"']))/", $src, $match)) {
$src = str_replace($match[0], sprintf('C(R("%s"))->add_module(R("%s"));', $value, $module), $src);
} else {
$src .= "\n" . sprintf('C(R("%s"))->add_module(R("%s"));', $value, $module);
}
self::update_settings($src);
}
示例6: verify
/**
* テストを実行する
* @param string $class_path パッケージパス
* @param string $method メソッド名
* @param string $block_name ブロック名
*/
public static final function verify($class_path, $method = null, $block_name = null)
{
if (is_file(self::path(str_replace(".", "/", $class_path) . "_test.php"))) {
$file = App::path(str_replace(".", "/", $class_path) . ".php");
$test = self::path(str_replace(".", "/", $class_path) . "_test.php");
if (is_file($file)) {
if (empty($block_name)) {
include $test;
} else {
$read = File::read($test);
$block = $init = "";
foreach (preg_split("/(#\\s*[\\w_]+)\n/", $read, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE) as $v) {
if ($v[0][0] == "#") {
$block = trim(substr($v[0], 1));
} else {
if (empty($block)) {
$init = $v[0];
} else {
$blocks[$block] = $v;
}
}
}
if (isset($blocks[$block_name])) {
self::$current_map_test_file = $test;
self::$current_file = $test;
$line = sizeof(explode("\n", substr($read, 0, $blocks[$block_name][1]))) - sizeof(explode("\n", $init));
ob_start();
eval("?>" . $init . str_repeat("\n", $line) . $blocks[$block_name][0]);
$result = ob_get_clean();
if (preg_match("/(Parse|Fatal) error:.+/", $result, $match)) {
throw new ErrorException($match[0]);
}
self::$current_map_test_file = null;
}
}
} else {
throw new InvalidArgumentException($file . " not found (" . $test . ")");
}
} else {
$class = !class_exists($class_path) && !interface_exists($class_path) ? Lib::import($class_path) : $class_path;
$cname = str_replace(".", "_", $class_path);
$ref = new InfoClass($class);
$is_setup = false;
$is_teardown = false;
if (method_exists($ref->name(), "__test_setup__")) {
$m = new ReflectionMethod($ref->name(), "__test_setup__");
$is_setup = $m->isStatic();
}
if (method_exists($ref->name(), "__test_teardown__")) {
$m = new ReflectionMethod($ref->name(), "__test_teardown__");
$is_teardown = $m->isStatic();
}
self::$current_file = $ref->path();
self::$current_class = $ref->name();
foreach (array_merge(array("class" => $ref->class_method()), $ref->self_methods_all()) as $name => $m) {
self::$current_method = $name;
if ($method === null || $method == $name) {
self::execute($m, $block_name, $class, $is_setup, $is_teardown);
}
}
self::$current_class = null;
self::$current_file = null;
self::$current_method = null;
}
return new self();
}
示例7: lib
function lib($package_path, $package_server = null)
{
return Lib::import($package_path, $package_server);
}
示例8: vendors_update
/**
* vendorsを更新する
*/
public static function vendors_update()
{
self::set_path();
if (is_dir(self::$vendor_path)) {
File::rm(self::$vendor_path, false);
}
foreach (Lib::classes(true, true) as $key => $class) {
Lib::import($key);
}
foreach (File::ls(App::path()) as $f) {
if ($f->is_ext('php')) {
$src = File::read($f);
if (preg_match_all("/[^\\w](import|R|C)\\(([\"\\'])(.+?)\\2\\)/", $src, $match)) {
foreach ($match[3] as $path) {
try {
self::import(trim($path));
} catch (Exception $e) {
}
}
}
if (Tag::setof($tag, $src, 'app')) {
if (preg_match_all("/[^\\w]class=([\"\\'])(.+?)\\1/", $src, $match)) {
foreach ($match[2] as $path) {
try {
self::import(trim($path));
} catch (Exceptions $e) {
}
}
}
}
}
}
}
示例9: __set_statics__
protected function __set_statics__($name, $class)
{
$this->statics[$name] = Lib::import($class);
}