本文整理汇总了PHP中Lib::package_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Lib::package_path方法的具体用法?PHP Lib::package_path怎么用?PHP Lib::package_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lib
的用法示例。
在下文中一共展示了Lib::package_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __new__
protected function __new__($path, $detail = true)
{
list($ref, $class, $path) = self::reflection_class($path);
$parent = $ref->getParentClass();
if ($parent !== false && $parent->getName() !== "stdClass") {
$i = new self($parent->getName(), false);
$this->extends($i->fm_package());
}
$this->name($ref->getName());
$this->updated(File::last_update($ref->getFileName()));
$this->path(str_replace("\\", "/", $ref->getFileName()));
try {
$this->package(Lib::package_path($this->path()));
if ($ref->getName() != substr($this->package, ($p = strrpos($this->package, ".")) + ($p === false ? 0 : 1))) {
$package_path = str_replace('.', '/', $this->package) . '/';
list($module, $null) = explode('.', substr($this->path, strpos($this->path, $package_path) + strlen($package_path)));
$this->module = str_replace('/', '.', $module);
}
} catch (RuntimeException $e) {
}
if ($this->is_path()) {
$class_src = str_replace(array("\r\n", "\r"), "\n", File::read($this->path()));
$this->valid_line(sizeof(explode("\n", preg_replace("/^[\\s\t\n\r]*" . "/sm", "", preg_replace("/\\/\\*.*?\\*\\//s", "", $class_src)))));
if (preg_match_all('/module_const\\((["\'])(.+?)\\1/', $class_src, $match)) {
foreach ($match[2] as $n) {
$this->def[$this->package() . '@' . $n] = new InfoAt($this->package() . '@' . $n, $this->package());
}
}
if (preg_match_all("/@const[\\s]+(.+)/", $class_src, $match)) {
foreach ($match[1] as $m) {
InfoAt::merge($this->def, $m, $this->package(), $this->package() . '@');
}
}
if (preg_match_all("/(\\/\\/|#)[\\s]*TODO[\t ]+(.+)/", $class_src, $todos)) {
foreach ($todos[2] as $v) {
$this->tasks[] = trim($v);
}
}
if ($detail) {
$pure_class_src = explode("\n", $class_src);
foreach ($ref->getMethods() as $method) {
$mname = $method->getName();
if (($mname[0] != '_' || $mname == '__init__' || strpos($mname, "__setup_") === 0) && (!$this->is_methods($mname) && !$this->is_setup($mname))) {
$package = $this->package();
if (empty($package)) {
$package = $this->name();
}
$mobj = new InfoMethod($package, $this->name(), $method);
if ($mobj->is_static() && $mobj->pure_perm() == "public" && strpos($mname, "__setup_") === 0 && substr($mname, -2) === "__") {
$this->setup($mobj->name(), $mobj);
} else {
if ($mobj->name() == '__init__') {
if (!$this->is_init()) {
$this->init($mobj);
}
} else {
$this->methods($mobj->name(), $mobj);
}
}
if (!$mobj->is_extends()) {
for ($i = $method->getStartLine() - 1; $i < $method->getEndLine(); $i++) {
$pure_class_src[$i] = "";
}
}
}
}
ksort($this->methods);
$this->class_method = new InfoMethod($this->package(), $this->name(), null);
foreach (InfoDoctest::get(implode("\n", $pure_class_src), $this->name(), $this->package()) as $k => $v) {
$this->class_method->test($k, $v);
}
foreach ($ref->getDefaultProperties() as $k => $v) {
if ($k == "_mixin_" && !empty($v)) {
foreach (explode(",", $v) as $o) {
$r = new self($o);
$this->mixin_object[] = $r->package() == "" ? $r->name() : $r->package();
}
break;
}
}
if (is_subclass_of($class, "Flow") && $this->is_init()) {
foreach ($this->methods() as $k => $v) {
$this->methods[$k]->context(array_merge($this->init()->context(), $v->context()));
$this->methods[$k]->request(array_merge($this->init()->request(), $v->request()));
}
}
if (is_subclass_of($class, "Object")) {
$ex_src = array();
$search_src = null;
$default_properties = $ref->getDefaultProperties();
foreach ($ref->getProperties() as $prop) {
if (!$prop->isPrivate()) {
$name = $prop->getName();
if ($name[0] != "_" && !$prop->isStatic()) {
$this->properties[$name] = new InfoAt($name, $this->package());
if ($prop->getDocComment() != "") {
$this->properties[$name]->document(str_replace(array("\r", "\n"), "", trim(preg_replace("/^[\\s]*\\*[\\s]{0,1}/m", "", str_replace(array("/" . "**", "*" . "/"), "", $prop->getDocComment())))));
} else {
if ($prop->getDeclaringClass()->getName() == $class) {
$search_src = $class_src;
//.........这里部分代码省略.........
示例2: module_const
/**
* モジュールの定数を取得する
* def()と対で利用する
*
* @param string $name 設定名
* @param mixed $default 未設定の場合に返す値
* @return mixed
*/
function module_const($name, $default = null)
{
$packege = null;
list($debug) = debug_backtrace(false);
$package = Lib::package_path($debug["file"]);
return App::def($package . "@" . $name, $default);
}