當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。