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


PHP ReflectionMethod::getEndLine方法代码示例

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


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

示例1: parseMethod

 private function parseMethod($class, $method)
 {
     $refl = new \ReflectionMethod($class, $method);
     //        var_dump($refl->getFileName());
     //        var_dump($refl->getStartLine());
     //        var_dump($refl->getEndLine());
     $body = trim(implode(array_slice(file($refl->getFileName()), $refl->getStartLine(), $refl->getEndLine() - $refl->getStartLine() - 1)));
     $spec = $this->createSpecification($body, $refl->getFileName(), $refl->getStartLine(), $refl->getEndLine());
     return $spec;
 }
开发者ID:ribozz,项目名称:PhpSpock,代码行数:10,代码来源:SpecificationParser.php

示例2: getMethod

 public function getMethod($filePath, $ext = '')
 {
     $fileName = dirname($filePath);
     $className = basename(dirname(dirname($filePath)));
     if (!class_exists($className)) {
         helper::import($fileName);
     }
     $methodName = basename($filePath);
     $method = new ReflectionMethod($className . $ext, $methodName);
     $data = new stdClass();
     $data->startLine = $method->getStartLine();
     $data->endLine = $method->getEndLine();
     $data->comment = $method->getDocComment();
     $data->parameters = $method->getParameters();
     $data->className = $className;
     $data->methodName = $methodName;
     $data->fileName = $fileName;
     $data->post = false;
     $file = file($fileName);
     for ($i = $data->startLine - 1; $i <= $data->endLine; $i++) {
         if (strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST')) {
             $data->post = true;
         }
     }
     return $data;
 }
开发者ID:caiwenhao,项目名称:zentao,代码行数:26,代码来源:model.php

示例3: getTrace

 /**
  * Process the exception. Calls the Exception::getTrace() method to
  * get the backtrace. Gets the relevant lines of code for each step
  * in the backtrace.
  */
 public function getTrace($e)
 {
     $trace = $e->getTrace();
     foreach ($trace as $i => &$entry) {
         if (isset($entry['class'])) {
             try {
                 $refl = new ReflectionMethod($entry['class'], $entry['function']);
                 if (isset($trace[$i - 1]) && isset($trace[$i - 1]['line'])) {
                     $entry['caller'] = (int) $trace[$i - 1]['line'] - 1;
                 } else {
                     if ($i === 0) {
                         $entry['caller'] = (int) $e->getLine() - 1;
                     }
                 }
                 $start = $entry['caller'] - self::BACKTRACE_CONTEXT;
                 if ($start < $refl->getStartLine()) {
                     $start = $refl->getStartLine() - 1;
                 }
                 $end = $entry['caller'] + self::BACKTRACE_CONTEXT;
                 if ($end > $refl->getEndLine()) {
                     $end = $refl->getEndLine();
                 }
                 $entry['source'] = $this->getSourceFromFile($refl->getFileName(), $start, $end);
             } catch (Exception $e) {
                 $entry['caller'] = null;
                 $entry['source'] = '';
             }
         }
         if (isset($entry['args'])) {
             // Duplicate so we don't overwrite by-reference variables
             $args = array();
             foreach ($entry['args'] as $i => $arg) {
                 $args[$i] = gettype($arg);
             }
             $entry['args'] = $args;
         }
     }
     $exceptionParams = array();
     if (method_exists($e, 'getParams')) {
         $exceptionParams = $e->getParams();
     }
     $d = array('backtrace' => $trace, 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'name' => api_helpers_class::getBaseName($e), 'params' => $exceptionParams);
     if (!empty($e->userInfo)) {
         $d['userInfo'] = $e->userInfo;
     }
     return $d;
 }
开发者ID:jonolsson,项目名称:Saturday,代码行数:52,代码来源:default.php

示例4: getCodeBody

 /**
  * @param \ReflectionMethod $reflectionMethod
  *
  * @return string
  */
 private function getCodeBody(\ReflectionMethod $reflectionMethod)
 {
     $reflectionClass = $reflectionMethod->getDeclaringClass();
     $length = $reflectionMethod->getEndLine() - $reflectionMethod->getStartLine();
     $lines = file($reflectionClass->getFileName());
     $code = join(PHP_EOL, array_slice($lines, $reflectionMethod->getStartLine() - 1, $length + 1));
     return preg_replace('/.*function[^{]+{/s', '', $code);
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:13,代码来源:MethodAnalyser.php

示例5: getEndLine

 /**
  * Returns the line this method's declaration ends at
  *
  * @return integer Line this methods's declaration ends at
  */
 public function getEndLine()
 {
     if ($this->reflectionSource instanceof ReflectionMethod) {
         return $this->reflectionSource->getEndLine();
     } else {
         return parent::getEndLine();
     }
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:13,代码来源:method.php

示例6: getMethodBodyAndDocComment

 public static function getMethodBodyAndDocComment($cls, $mtd)
 {
     $func = new \ReflectionMethod($cls, $mtd);
     $start_line = $func->getStartLine() + 1;
     $length = $func->getEndLine() - $start_line - 1;
     $lines = array_slice(file($func->getFileName()), $start_line, $length);
     return array(implode('', $lines), $func->getDocComment());
 }
开发者ID:cal127,项目名称:phpcrud,代码行数:8,代码来源:Helpers.php

示例7: getRawBody

 public function getRawBody()
 {
     $method = new \ReflectionMethod($this->testClassInstance, $this->testMethod);
     $start_line = $method->getStartLine() - 1; // it's actually - 1, otherwise you wont get the function() block
     $end_line = $method->getEndLine();
     $source = file($method->getFileName());
     return implode("", array_slice($source, $start_line, $end_line - $start_line));
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:8,代码来源:Cest.php

示例8: getMethodSource

 static function getMethodSource(ReflectionMethod $method)
 {
     $path = $method->getFileName();
     $lines = @file($path);
     $from = $method->getStartLine();
     $to = $method->getEndLine();
     $len = $to - $from + 1;
     return implode(array_slice($lines, $from - 1, $len));
 }
开发者ID:jabouzi,项目名称:projet,代码行数:9,代码来源:listing5.29.php

示例9: _getCode

 /**
  * Get the source code for the method
  *
  * @param \ReflectionMethod $method
  *
  * @return string
  */
 protected function _getCode(\ReflectionMethod $method)
 {
     $filename = $method->getFileName();
     $start_line = $method->getStartLine() + 1;
     $end_line = $method->getEndLine() - 1;
     $length = $end_line - $start_line;
     $source = file($filename);
     return preg_replace('/^\\s{4}/m', '', implode("", array_slice($source, $start_line, $length)));
 }
开发者ID:fortifi,项目名称:ui,代码行数:16,代码来源:AbstractUiExampleView.php

示例10: getCodeBody

 /**
  * @param \ReflectionMethod $reflectionMethod
  *
  * @return string
  */
 private function getCodeBody(\ReflectionMethod $reflectionMethod)
 {
     $endLine = $reflectionMethod->getEndLine();
     $startLine = $reflectionMethod->getStartLine();
     $reflectionClass = $this->getMethodOwner($reflectionMethod, $startLine, $endLine);
     $length = $endLine - $startLine;
     $lines = file(StreamWrapper::wrapPath($reflectionClass->getFileName()));
     $code = join(PHP_EOL, array_slice($lines, $startLine - 1, $length + 1));
     return preg_replace('/.*function[^{]+{/s', '', $code);
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:15,代码来源:MethodAnalyser.php

示例11: getCodeBody

 /**
  * @param ReflectionMethod $reflectionMethod
  *
  * @return string
  */
 private function getCodeBody(\ReflectionMethod $reflectionMethod)
 {
     $reflectionClass = $reflectionMethod->getDeclaringClass();
     $length = $reflectionMethod->getEndLine() - $reflectionMethod->getStartLine();
     $lines = file($reflectionClass->getFileName());
     if ($length == 0) {
         return preg_replace('/.*function.*{/', '', $lines[$reflectionMethod->getStartLine() - 1]);
     }
     return join("\n", array_slice($lines, $reflectionMethod->getStartLine(), $length));
 }
开发者ID:franzliedke,项目名称:phpspec,代码行数:15,代码来源:MethodAnalyser.php

示例12: sourceMethod

 function sourceMethod(\ReflectionMethod $method)
 {
     $filename = $method->getFileName();
     $start_line = $method->getStartLine() - 1;
     // it's actually - 1, otherwise you wont get the function() block
     $end_line = $method->getEndLine();
     $length = $end_line - $start_line;
     $source = file($filename);
     $body = implode("", array_slice($source, $start_line, $length));
     return $method->getDocComment() . PHP_EOL . $body;
 }
开发者ID:larakit,项目名称:lk,代码行数:11,代码来源:AdminCodegenModelController.php

示例13: testImplementationsAreSynchronized

 public function testImplementationsAreSynchronized()
 {
     $adapterReflector = new ReflectionMethod('ehough_finder_adapter_PhpAdapter', 'searchInDirectory');
     $finderReflector = new ReflectionMethod('ehough_finder_Finder', 'searchInDirectory');
     $adapterSource = array_slice(file($adapterReflector->getFileName()), $adapterReflector->getStartLine() + 1, $adapterReflector->getEndLine() - $adapterReflector->getStartLine() - 1);
     $adapterSource = implode('', $adapterSource);
     $adapterSource = str_replace(array('$this->minDepth', '$this->maxDepth'), array('$minDepth', '$maxDepth'), $adapterSource);
     $finderSource = array_slice(file($finderReflector->getFileName()), $finderReflector->getStartLine() + 1, $finderReflector->getEndLine() - $finderReflector->getStartLine() - 1);
     $finderSource = implode('', $finderSource);
     $this->assertStringEndsWith($adapterSource, $finderSource);
 }
开发者ID:ehough,项目名称:finder,代码行数:11,代码来源:PhpFinderTest.php

示例14: generateMethodArguments

 /**
  * @param ReflectionMethod $method
  * @return string
  */
 function generateMethodArguments(ReflectionMethod $method)
 {
     if ($method->isInternal()) {
         // This code can`t handle constants, it replaces its with value
         return implode(', ', array_map(array($this, 'generateMethodArgument'), $method->getParameters()));
     } else {
         $lines = $this->getFileLines($method->getFileName());
         $start_line = $method->getStartLine() - 1;
         $function_lines = array_slice($lines, $start_line, $method->getEndLine() - $start_line);
         // todo: use code beautifier?
         return $this->parseFunctionArgs(implode(PHP_EOL, $function_lines));
     }
 }
开发者ID:Garcy111,项目名称:Garcy-Framework-2,代码行数:17,代码来源:ReflectionHelper.php

示例15: collect

 /**
  * Called by the DebugBar when data needs to be collected
  * @return array Collected data
  */
 function collect()
 {
     $dispatcher = $this->di['dispatcher'];
     $router = $this->di['router'];
     $route = $router->getMatchedRoute();
     if (!$route) {
         return array();
     }
     $uri = $route->getPattern();
     $paths = $route->getPaths();
     $result['uri'] = $uri ?: '-';
     $result['paths'] = $this->formatVar($paths);
     if ($params = $router->getParams()) {
         $result['params'] = $this->formatVar($params);
     }
     $result['HttpMethods'] = $route->getHttpMethods();
     $result['RouteName'] = $route->getName();
     $result['hostname'] = $route->getHostname();
     if ($this->di->has('app') && ($app = $this->di['app']) instanceof Micro) {
         if (($handler = $app->getActiveHandler()) instanceof \Closure || is_string($handler)) {
             $reflector = new \ReflectionFunction($handler);
         } elseif (is_array($handler)) {
             $reflector = new \ReflectionMethod($handler[0], $handler[1]);
         }
     } else {
         $result['Moudle'] = $router->getModuleName();
         $result['Controller'] = get_class($controller_instance = $dispatcher->getActiveController());
         $result['Action'] = $dispatcher->getActiveMethod();
         $reflector = new \ReflectionMethod($controller_instance, $result['Action']);
     }
     if (isset($reflector)) {
         $start = $reflector->getStartLine() - 1;
         $stop = $reflector->getEndLine();
         $filename = substr($reflector->getFileName(), mb_strlen(realpath(dirname($_SERVER['DOCUMENT_ROOT']))));
         $code = array_slice(file($reflector->getFileName()), $start, $stop - $start);
         $result['file'] = $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine() . "  [CODE]: \n" . implode("", $code);
     }
     return array_filter($result);
 }
开发者ID:minhlaoleu,项目名称:phalcon-debugbar,代码行数:43,代码来源:RouteCollector.php


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