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


PHP ReflectionMethod::getEndline方法代码示例

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


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

示例1: getMethodData

 private function getMethodData(ReflectionMethod $reflectionMethod, $classContent, &$classData)
 {
     //TODO: parse local variable
     $modifiers = Reflection::getModifierNames($reflectionMethod->getModifiers());
     $startLine = $reflectionMethod->getStartLine();
     $endLine = $reflectionMethod->getEndline();
     $parameters = $reflectionMethod->getParameters();
     $docComment = $reflectionMethod->getDocComment();
     if (!$docComment) {
         $docComment = "";
     }
     $parsedComment = $this->parseDocComment($docComment, 'method');
     $out = array();
     $out['params'] = array();
     $out['docComment'] = $this->trimDocComment($docComment);
     $out['inheritdoc'] = $parsedComment['inheritdoc'];
     $out['startLine'] = $startLine;
     $out['endLine'] = $endLine;
     $origin = $reflectionMethod->getDeclaringClass()->getFileName() == false ? "" : $reflectionMethod->getDeclaringClass()->getFileName();
     $origin = $this->normalizePath($origin);
     $out['origin'] = $origin;
     $params = array();
     foreach ($parameters as $parameter) {
         $parameterName = '$' . $parameter->getName();
         try {
             $parameterClass = $parameter->getClass();
         } catch (\Exception $e) {
             $parameterClass = "";
         }
         $parameterType = "";
         //not defined try to find in the doccomment
         if (empty($parameterClass)) {
             if (array_key_exists($parameterName, $parsedComment['params'])) {
                 $parameterType = $parsedComment['params'][$parameterName];
             }
         } else {
             $parameterType = $parameter->getClass()->getName();
         }
         $params[] = $parameterType . ' ' . $parameterName;
         $out['params'][$parameterName] = $parameterType;
     }
     if (array_key_exists('return', $parsedComment) && $parsedComment['return'] != "") {
         $returnType = "";
         $arrayReturn = 0;
         $returnTypes = explode('|', trim($parsedComment['return']));
         foreach ($returnTypes as $rType) {
             if (preg_match('/\\[\\]$/', $rType)) {
                 $arrayReturn = 1;
                 $rType = trim($rType, "[]");
             }
             if (!$this->isScalar($rType)) {
                 $returnType = $rType;
                 if ($returnType[0] == '\\') {
                     $returnType = substr($returnType, 1);
                 }
                 break;
             }
         }
         if (empty($returnType)) {
             $out['return'] = "";
         } else {
             $out['return'] = $this->guessClass($returnType, $classData['namespaces']);
         }
         $out['array_return'] = $arrayReturn;
     }
     $return = empty($parsedComment['return']) ? "none" : $parsedComment['return'];
     $out['signature'] = '(' . join(', ', $params) . ')  : ' . $return;
     foreach ($modifiers as $modifier) {
         $classData['methods']['modifier'][$modifier][] = $reflectionMethod->name;
     }
     $classData['methods']['all'][$reflectionMethod->name] = $out;
 }
开发者ID:mingtang,项目名称:phpcomplete-extended,代码行数:72,代码来源:IndexGenerator.php

示例2: increment

<pre>
<?php 
class Counter
{
    private static $c = 0;
    public static final function increment()
    {
        return ++self::$c;
    }
}
// Создание экземпляра класса ReflectionMethod
$method = new ReflectionMethod('Counter', 'increment');
// exit;
// Вывод основной информации
printf("===> %s%s%s%s%s%s%s метод '%s' (который является %s)\n" . "     объявлен в %s\n" . "     строки с %d по %d\n" . "     имеет модификаторы %d[%s]\n", $method->isInternal() ? 'Встроенный' : 'Пользовательский', $method->isAbstract() ? ' абстрактный' : '', $method->isFinal() ? ' финальный' : '', $method->isPublic() ? ' public' : '', $method->isPrivate() ? ' private' : '', $method->isProtected() ? ' protected' : '', $method->isStatic() ? ' статический' : '', $method->getName(), $method->isConstructor() ? 'конструктором' : 'обычным методом', $method->getFileName(), $method->getStartLine(), $method->getEndline(), $method->getModifiers(), implode(' ', Reflection::getModifierNames($method->getModifiers())));
// Вывод статических переменных, если они есть
if ($statics = $method->getStaticVariables()) {
    printf("---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов метода
printf("---> Результат вызова: ");
$result = $method->invoke(3);
echo $result;
?>
</pre>
开发者ID:sydorenkovd,项目名称:features_for_phpoopsecond.local,代码行数:25,代码来源:03-method.php

示例3: increment

class Counter
{
    private static $c = 0;
    /**
     * Increment counter
     *
     * @final
     * @static
     * @access  public
     * @return  int
     */
    public static final function increment()
    {
        return ++self::$c;
    }
}
// Create an instance of the ReflectionMethod class
$method = new ReflectionMethod('Counter', 'increment');
// Print out basic information
printf("===> The %s%s%s%s%s%s%s method '%s' (which is %s)\n" . "     declared in %s\n" . "     lines %d to %d\n" . "     having the modifiers %d[%s]\n", $method->isInternal() ? 'internal' : 'user-defined', $method->isAbstract() ? ' abstract' : '', $method->isFinal() ? ' final' : '', $method->isPublic() ? ' public' : '', $method->isPrivate() ? ' private' : '', $method->isProtected() ? ' protected' : '', $method->isStatic() ? ' static' : '', $method->getName(), $method->isConstructor() ? 'the constructor' : 'a regular method', $method->getFileName(), $method->getStartLine(), $method->getEndline(), $method->getModifiers(), implode(' ', Reflection::getModifierNames($method->getModifiers())));
echo "\n";
// Print documentation comment
printf("---> Documentation:\n %s\n", var_export($method->getDocComment(), 1));
// Print static variables if existant
if ($statics = $method->getStaticVariables()) {
    printf("---> Static variables: %s\n", var_export($statics, 1));
}
echo "\n";
// Invoke the method
printf("---> Invocation results in: ");
var_dump($method->invoke(NULL));
开发者ID:jinguanio,项目名称:david,代码行数:31,代码来源:reflect_inner_closure.php

示例4: dirname

<?php

$hostDir = dirname(__FILE__);
$hostDir = $hostDir . '\\class';
$filesNames = scanDir($hostDir);
foreach ($filesNames as $fileName) {
    if ($fileName == "." || $fileName === "..") {
        continue;
    } else {
        //echo $fileUrl = $fileName;
        include 'class/' . $fileName;
    }
}
foreach (get_declared_classes() as $class) {
    $reflectionClass = new ReflectionClass($class);
    if ($reflectionClass->isUserDefined()) {
        //echo $reflectionClass->getEndLine();
        //Reflection::export($reflectionClass);
        //Reflection::getName($reflectionClass);
        $className = $reflectionClass->getName();
        $methodsName = $reflectionClass->getMethods();
        //	var_dump($methodsName);exit;
        foreach ($methodsName as $method) {
            $method = new ReflectionMethod($className, $method->name);
            $lines = $method->getEndline() - $method->getStartLine();
            echo "类名:" . $className . "方法名:" . $method->name . "行数:" . $lines;
        }
    }
}
开发者ID:ayoungcoder,项目名称:hello-github,代码行数:29,代码来源:api.php

示例5: extractCode

 /**
  * Extract the function code from its class.
  *
  * @param String $actionsCode
  * @param ReflectionMethod $method
  */
 public function extractCode($actionsCode, ReflectionMethod $method)
 {
     $code = explode("\n", $actionsCode);
     $slice = array_slice($code, $method->getStartLine() - 1, $method->getEndline() - $method->getStartLine() + 1);
     $this->code = implode("\n", $slice);
     $this->characters = strlen(str_replace(array("\n", "\r"), '', $this->code));
     $this->codeLength = count($slice);
 }
开发者ID:rafal2208,项目名称:blues,代码行数:14,代码来源:paSfComponent.class.php


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