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


PHP Inspector::lines方法代码示例

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


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

示例1: _method

 protected static function _method(array $object, array $data, array $options = array())
 {
     if (!$data) {
         return array();
     }
     $lines = Inspector::lines($data['file'], range($data['start'], $data['end']));
     $object = array('source' => join("\n", $lines)) + $object;
     $object += array('tags' => isset($data['tags']) ? $data['tags'] : array());
     if (isset($object['tags']['return'])) {
         list($type, $text) = explode(' ', $object['tags']['return'], 2) + array('', '');
         $object['return'] = compact('type', 'text');
     }
     return $object;
 }
开发者ID:rapzo,项目名称:li3_docs,代码行数:14,代码来源:Extractor.php

示例2: apply

 /**
  * Takes an instance of an object (usually a Collection object) containing test
  * instances. Introspects the test subject classes to extract cyclomatic complexity data.
  *
  * @param object $report Instance of Report which is calling apply.
  * @param array $tests The test to apply this filter on
  * @param array $options Not used.
  * @return object|void Returns the instance of `$tests`.
  */
 public static function apply($report, $tests, array $options = array())
 {
     $results = array();
     foreach ($tests->invoke('subject') as $class) {
         $results[$class] = array();
         if (!($methods = Inspector::methods($class, 'ranges', array('public' => false)))) {
             continue;
         }
         foreach ($methods as $method => $lines) {
             $lines = Inspector::lines($class, $lines);
             $branches = Parser::tokenize(join("\n", (array) $lines), array('include' => static::$_include));
             $results[$class][$method] = count($branches) + 1;
             $report->collect(__CLASS__, $results);
         }
     }
     return $tests;
 }
开发者ID:rudiedirkx,项目名称:MyLithium,代码行数:26,代码来源:Complexity.php

示例3: range

<h3 id="source">Source</h3>

<div id="sourceCode"></div>

<h3>Stack Trace</h3>

<div class="lithium-stack-trace">
    <ol>
        <?php 
foreach ($stack as $id => $frame) {
    ?>
            <?php 
    $location = "{$frame['file']}: {$frame['line']}";
    $lines = range($frame['line'] - $context, $frame['line'] + $context);
    $code = Inspector::lines($frame['file'], $lines);
    ?>
            <li>
                <tt><a href="#source" id="<?php 
    echo $id;
    ?>
" class="display-source-excerpt">
                    <?php 
    echo $frame['functionRef'];
    ?>
                </a></tt>
                <div id="sourceCode<?php 
    echo $id;
    ?>
" style="display: none;">
开发者ID:nervetattoo,项目名称:li3_start,代码行数:29,代码来源:development.html.php

示例4: _definition

 /**
  * Locates original location of closures.
  *
  * @param mixed $reference File or class name to inspect.
  * @param integer $callLine Line number of class reference.
  * @return mixed Returns the line number where the method called is defined.
  */
 protected static function _definition($reference, $callLine)
 {
     if (file_exists($reference)) {
         foreach (array_reverse(token_get_all(file_get_contents($reference))) as $token) {
             if (!is_array($token) || $token[2] > $callLine) {
                 continue;
             }
             if ($token[0] === T_FUNCTION) {
                 return $token[2];
             }
         }
         return;
     }
     list($class, ) = explode('::', $reference);
     if (!class_exists($class)) {
         return;
     }
     $classRef = new ReflectionClass($class);
     $methodInfo = Inspector::info($reference);
     $methodDef = join("\n", Inspector::lines($classRef->getFileName(), range($methodInfo['start'] + 1, $methodInfo['end'] - 1)));
     foreach (array_reverse(token_get_all("<?php {$methodDef} ?>")) as $token) {
         if (!is_array($token) || $token[2] > $callLine) {
             continue;
         }
         if ($token[0] === T_FUNCTION) {
             return $token[2] + $methodInfo['start'];
         }
     }
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:36,代码来源:Debugger.php

示例5: lines

 public function lines($data, $start, $end)
 {
     return Inspector::lines($data, range($start, $end));
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:4,代码来源:SourceCode.php

示例6: testLineIntrospectionWithCRLFLineEndings

 /**
  * Tests reading specific line numbers of a file that has CRLF line endings.
  */
 public function testLineIntrospectionWithCRLFLineEndings()
 {
     $tmpPath = Libraries::get(true, 'resources') . '/tmp/tests/inspector_crlf';
     $contents = implode("\r\n", array('one', 'two', 'three', 'four', 'five'));
     file_put_contents($tmpPath, $contents);
     $result = Inspector::lines($tmpPath, array(2));
     $expected = array(2 => 'two');
     $this->assertEqual($expected, $result);
     $result = Inspector::lines($tmpPath, array(1, 5));
     $expected = array(1 => 'one', 5 => 'five');
     $this->assertEqual($expected, $result);
     $this->_cleanUp();
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:16,代码来源:InspectorTest.php

示例7: testLineIntrospection

 /**
  * Tests reading specific line numbers of a file.
  *
  * @return void
  */
 public function testLineIntrospection()
 {
     $result = Inspector::lines(__FILE__, array(__LINE__ - 1));
     $expected = array(__LINE__ - 2 => "\tpublic function testLineIntrospection() {");
     $this->assertEqual($expected, $result);
     $result = Inspector::lines(__CLASS__, array(14));
     $expected = array(14 => 'class InspectorTest extends \\lithium\\test\\Unit {');
     $this->assertEqual($expected, $result);
     $this->expectException('/Missing argument 2/');
     $this->assertNull(Inspector::lines('\\lithium\\core\\Foo'));
     $this->assertNull(Inspector::lines(__CLASS__, array()));
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:17,代码来源:InspectorTest.php

示例8: _extractFileCode

 protected static function _extractFileCode($ref, $options)
 {
     $library = Libraries::get($options['library']);
     $file = $ref['file'];
     if (!($path = realpath("{$library['path']}/{$file}"))) {
         return;
     }
     list($start, $end) = array_map('intval', explode('-', $ref['lines']));
     $lines = Inspector::lines(file_get_contents($path), range($start, $end));
     return array("{$ref['file']}::{$ref['lines']}", "\t" . join("\n\t", $lines));
 }
开发者ID:unionofrad,项目名称:li3_docs,代码行数:11,代码来源:Code.php


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