當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ReflectionFunction::getEndline方法代碼示例

本文整理匯總了PHP中ReflectionFunction::getEndline方法的典型用法代碼示例。如果您正苦於以下問題:PHP ReflectionFunction::getEndline方法的具體用法?PHP ReflectionFunction::getEndline怎麽用?PHP ReflectionFunction::getEndline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ReflectionFunction的用法示例。


在下文中一共展示了ReflectionFunction::getEndline方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getClosure

 static function getClosure($fn)
 {
     $source = new \ReflectionFunction($fn);
     $class = $source->getFileName();
     $beginLine = $source->getStartLine();
     $endLine = $source->getEndline();
     return "{$class} {$beginLine} : {$endLine}";
 }
開發者ID:WickyLeo,項目名稱:bobcat,代碼行數:8,代碼來源:Util.class.php

示例2: reflect

 /**
  * Show reflection
  *
  * Show reflection
  *
  * <code>
  * Panda_Debug::reflect('BEAR_Form');  // Class
  * Panda_Debug::reflect($obj);        // Objecy
  * Panda_Debug::reflect('p');         // Function
  * </code>
  *
  * @param string $target      target
  * @param boll   $cehckParent check parent class
  *
  * @return void
  */
 public static function reflect($target, $cehckParent = false)
 {
     if (is_object($target)) {
         $target = get_class($target);
     }
     switch (true) {
         case function_exists($target):
             $ref = new ReflectionFunction($target);
             $info['name'] = $ref->isInternal() ? 'The internal ' : 'The user-defined ';
             $info['name'] .= $targetName = $ref->getName();
             $info['declare in'] = $ref->getFileName() . ' lines ' . $ref->getStartLine() . ' to ' . $ref->getEndline();
             $info['Documentation'] = $ref->getDocComment();
             $statics = $ref->getStaticVariables();
             if ($statics) {
                 $info['Static variables'] = $statics;
             }
             $type = 'function';
             break;
         case class_exists($target, false):
             $ref = new ReflectionClass($target);
             $type = 'class';
             $info['name'] = $ref->isInternal() ? 'The internal ' : 'The user-defined ';
             $info['name'] .= $ref->isAbstract() ? ' abstract ' : '';
             $info['name'] .= $ref->isFinal() ? ' final ' : '';
             $info['name'] .= $ref->isInterface() ? 'interface ' : 'class ';
             $info['name'] .= $targetName = $ref->getName();
             $info['declare in'] = $ref->getFileName() . ' lines ' . $ref->getStartLine() . ' to ' . $ref->getEndline();
             $info['modifiers'] = Reflection::getModifierNames($ref->getModifiers());
             $info['Documentation'] = $ref->getDocComment();
             $info['Implements'] = $ref->getInterfaces();
             $info['Constants'] = $ref->getConstants();
             foreach ($ref->getProperties() as $prop) {
                 // ReflectionProperty クラスのインスタンスを生成する
                 $propRef = new ReflectionProperty($targetName, $prop->name);
                 if ($propRef->isPublic()) {
                     $porps[] = $prop->name;
                 }
             }
             //            $info['Public Properties'] = $porps;
             foreach ($ref->getMethods() as $method) {
                 $methodRef = new ReflectionMethod($targetName, $method->name);
                 if ($methodRef->isPublic() || $method->isStatic()) {
                     $final = $method->isFinal() ? 'final ' : '';
                     $pubic = $method->isPublic() ? 'public ' : '';
                     $static = $method->isStatic() ? ' static ' : '';
                     $methods[] = sprintf("%s%s%s %s", $final, $pubic, $static, $method->name);
                 }
             }
             $info['Public Methods'] = $methods;
             if ($ref->isInstantiable() && is_object($target)) {
                 $info['isInstance ?'] = $ref->isInstance($target) ? 'yes' : 'no';
             }
             if ($parent) {
                 $info['parent'] .= $ref->getParentClass();
             }
             break;
         default:
             $type = 'Invalid Object/Class';
             $targetName = $target;
             $info = null;
             break;
     }
     print_a($info, "show_objects:1;label: Reflection of {$type} '{$targetName}'");
 }
開發者ID:sssAlchemy,項目名稱:Panda,代碼行數:80,代碼來源:Debug.php

示例3: show_info

function show_info($function, $basic = 0)
{
    $func = new ReflectionFunction($function);
    $ret = '';
    $ret .= "<pre><strong>Information:</strong>\n" . var_export($func->getDocComment(), 1) . "</pre>\n";
    if ($basic) {
        $ret .= "<pre><pre>===> The " . ($func->isInternal() ? 'internal' : 'user-defined') . " function '" . $func->getName() . "'\n" . "\tdeclared in " . $func->getFileName() . "\n\tlines " . $func->getStartLine() . " to " . $func->getEndline() . "</pre>\n";
    }
    return $ret;
}
開發者ID:BillTheBest,項目名稱:1.6.x,代碼行數:10,代碼來源:amavis.stats.php

示例4: serializeClosure

 public function serializeClosure(callable $closure)
 {
     $ref = new \ReflectionFunction($closure);
     $file = $ref->getFileName();
     $start = $ref->getStartLine();
     $end = $ref->getEndline();
     $content = file($file);
     $code = [];
     for ($i = $start - 1; $i < $end; $i++) {
         $code[] = trim($content[$i]);
     }
     $code = implode('', $code) . 'end';
     $function = 'function (' . Utils::cut('function (', '});end', $code) . '}';
     return $function;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:15,代碼來源:utils.php

示例5: sayHello

<pre>
<?php 
function sayHello($name, $h)
{
    static $count = 0;
    return "<h{$h}>Hello, {$name}</h{$h}>";
}
// Обзор функции
Reflection::export(new ReflectionFunction('sayHello'));
// Создание экземпляра класса ReflectionFunction
$func = new ReflectionFunction('sayHello');
// Вывод основной информации
printf("<p>===> %s функция '%s'\n" . "     объявлена в %s\n" . "     строки с %d по %d\n", $func->isInternal() ? 'Internal' : 'User-defined', $func->getName(), $func->getFileName(), $func->getStartLine(), $func->getEndline());
// Вывод статических переменных, если они есть
if ($statics = $func->getStaticVariables()) {
    printf("<p>---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов функции
printf("<p>---> Результат вызова: ");
$result = $func->invoke("John", "1");
echo $result;
?>
</pre>
開發者ID:sydorenkovd,項目名稱:features_for_phpoopsecond.local,代碼行數:23,代碼來源:01-function.php

示例6: ReflectionFunction

 /**
  */
 function get_function_source($name)
 {
     $r = new ReflectionFunction($name);
     $info = ['name' => $r->getName(), 'file' => $r->getFileName(), 'line_start' => $r->getStartLine(), 'line_end' => $r->getEndline(), 'params' => $r->getParameters(), 'comment' => $r->getDocComment()];
     $info['source'] = $this->get_file_slice($info['file'], $info['line_start'], $info['line_end']);
     return $info;
 }
開發者ID:yfix,項目名稱:yf,代碼行數:9,代碼來源:yf_core_api.class.php

示例7: ReflectionFunction

    static $var = 1;
}
$func = new ReflectionFunction("test");
var_dump($func->export("test"));
echo "--getName--\n";
var_dump($func->getName());
echo "--isInternal--\n";
var_dump($func->isInternal());
echo "--isUserDefined--\n";
var_dump($func->isUserDefined());
echo "--getFilename--\n";
var_dump($func->getFilename());
echo "--getStartline--\n";
var_dump($func->getStartline());
echo "--getEndline--\n";
var_dump($func->getEndline());
echo "--getDocComment--\n";
var_dump($func->getDocComment());
echo "--getStaticVariables--\n";
var_dump($func->getStaticVariables());
echo "--invoke--\n";
var_dump($func->invoke(array(1, 2, 3)));
echo "--invokeArgs--\n";
var_dump($func->invokeArgs(array(1, 2, 3)));
echo "--returnsReference--\n";
var_dump($func->returnsReference());
echo "--getParameters--\n";
var_dump($func->getParameters());
echo "--getNumberOfParameters--\n";
var_dump($func->getNumberOfParameters());
echo "--getNumberOfRequiredParameters--\n";
開發者ID:badlamer,項目名稱:hhvm,代碼行數:31,代碼來源:025.php


注:本文中的ReflectionFunction::getEndline方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。