• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP analysis\Inspector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: analyze

 /**
  * Analyzes code coverage results collected from XDebug, and performs coverage density analysis.
  *
  * @param object $report The report instance running this filter and aggregating results
  * @param array $classes A list of classes to analyze coverage on. By default, gets all
  *              defined subclasses of lithium\test\Unit which are currently in memory.
  * @return array|void Returns an array indexed by file and line, showing the number of
  *                    instances each line was called.
  */
 public static function analyze($report, array $classes = array())
 {
     $data = static::collect($report->results['filters'][__CLASS__]);
     $classes = $classes ?: array_filter(get_declared_classes(), function ($class) use($data) {
         $unit = 'lithium\\test\\Unit';
         return !is_subclass_of($class, $unit) || array_key_exists($class, $data);
     });
     $classes = array_values(array_intersect((array) $classes, array_keys($data)));
     $densities = $result = array();
     foreach ($classes as $class) {
         $classMap = array($class => Libraries::path($class));
         $densities += static::_density($data[$class], $classMap);
     }
     $executableLines = array();
     if (!empty($classes)) {
         $executableLines = array_combine($classes, array_map(function ($cls) {
             return Inspector::executable($cls, array('public' => false));
         }, $classes));
     }
     foreach ($densities as $class => $density) {
         $executable = $executableLines[$class];
         $covered = array_intersect(array_keys($density), $executable);
         $uncovered = array_diff($executable, $covered);
         $percentage = round(count($covered) / (count($executable) ?: 1), 4) * 100;
         $result[$class] = compact('class', 'executable', 'covered', 'uncovered', 'percentage');
     }
     $result = static::collectLines($result);
     return $result;
 }
开发者ID:EHER,项目名称:chegamos,代码行数:38,代码来源:Coverage.php


示例2: _initSteps

 /**
  * Creates step list for this exercise.
  * 
  * @return void
  */
 protected function _initSteps()
 {
     $methods = Inspector::methods($this)->to('array');
     foreach ($methods as $method) {
         if (substr($method['name'], 0, strlen($this->_methodPrefix)) === $this->_methodPrefix) {
             $this->_steps[] = $method['name'];
         }
     }
 }
开发者ID:raisinbread,项目名称:li3_exercises,代码行数:14,代码来源:Exercise.php


示例3: explainExplainMethods

 /**
  * "Explain" methods step.
  *
  * @return void
  */
 public function explainExplainMethods()
 {
     $this->header("The Explain Methods");
     $this->out("The next step is to create your first `explain` method. When an exercise is run, each user-defined method that begins with 'explain' is run in the order it was defined.\n");
     $this->out("Let's start by defining a new method called `explainIntro`.");
     $this->halt();
     $methods = \lithium\analysis\Inspector::methods('\\li3_exercises\\extensions\\exercises\\Blog', 'extents');
     $this->assertTrue(isset($methods['explainIntro']), "Hmmm. I can't seem to find a method defined on your new Blog class named '{:purple}explainIntro{:end}'. {:error}Make sure it has public visibility!{:end}");
 }
开发者ID:raisinbread,项目名称:li3_exercises,代码行数:14,代码来源:Example.php


示例4: _methods

 /**
  * Get the methods to test.
  *
  * @param string $request
  * @return string
  */
 protected function _methods($request)
 {
     $use = $this->_use($request);
     $path = Libraries::path($use);
     if (!file_exists($path)) {
         return "";
     }
     $methods = (array) Inspector::methods($use, 'extents');
     $testMethods = array();
     foreach (array_keys($methods) as $method) {
         $testMethods[] = "\tpublic function test" . ucwords($method) . "() {}";
     }
     return join("\n", $testMethods);
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:20,代码来源:Test.php


示例5: 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


示例6: _affected

 /**
  * Returns all classes directly depending on a given class.
  *
  * @param string $dependency The class name to use as a dependency.
  * @param string $exclude Regex path exclusion filter.
  * @return array Classes having a direct dependency on `$dependency`. May contain duplicates.
  */
 protected static function _affected($dependency, $exclude = null)
 {
     $exclude = $exclude ?: '/(tests|webroot|resources|libraries|plugins)/';
     $classes = Libraries::find(true, compact('exclude') + array('recursive' => true));
     $dependency = ltrim($dependency, '\\');
     $affected = array();
     foreach ($classes as $class) {
         if (isset(static::$_cachedDepends[$class])) {
             $depends = static::$_cachedDepends[$class];
         } else {
             $depends = Inspector::dependencies($class);
             $depends = array_map(function ($c) {
                 return ltrim($c, '\\');
             }, $depends);
             static::$_cachedDepends[$class] = $depends;
         }
         if (in_array($dependency, $depends)) {
             $affected[] = $class;
         }
     }
     return $affected;
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:29,代码来源:Affected.php


示例7: run

 /**
  * Runs main console application logic. Returns a list of 
  * available exercises by default. Otherwise runs the specified exercise.
  *
  * @param string $command 
  * @return void
  */
 public function run($command = null)
 {
     if ($command == null) {
         $this->out("{:heading}EXERCISES{:end}");
         foreach ($this->_exercises as $key => $exercise) {
             $library = strtok($exercise, '\\');
             $info = Inspector::info($exercise);
             $this->out($this->_pad($key . " {:blue}via {$library}{:end}"), 'heading');
             $this->out($this->_pad($info['description'] == '' ? '(No description)' : $info['description']), 2);
         }
         $this->stop();
     }
     if (isset($this->_exercises[$command])) {
         $className = $this->_exercises[$command];
         $exercise = new $className(array('command' => $this));
         $exercise->run();
     } else {
         $this->out("{:error}The exercise {:end}{:blue}\"{$command}\"{:end}{:error} you specified cannot be found. Please supply a valid exercise name.{:end}");
         $this->out();
         $this->stop(1);
     }
 }
开发者ID:raisinbread,项目名称:li3_exercises,代码行数:29,代码来源:Learn.php


示例8: run

 /**
  * Generate test cases in the given namespace.
  * `li3 create test model Post`
  * `li3 create test --library=li3_plugin model Post`
  *
  * @param string $type namespace of the class (e.g. model, controller, some.name.space).
  * @param string $name Name of class to test.
  * @return void
  */
 public function run($type = null, $name = null)
 {
     $library = Libraries::get($this->library);
     if (empty($library['prefix'])) {
         return false;
     }
     $namespace = $this->_namespace($type);
     $use = "\\{$library['prefix']}{$namespace}\\{$name}";
     $methods = array();
     if (class_exists($use)) {
         $methods = array();
         foreach (array_keys(Inspector::methods($use, 'extents')) as $method) {
             $methods[] = "\tpublic function test" . ucwords($method) . "() {}";
         }
     }
     $params = array('namespace' => "{$library['prefix']}tests\\cases\\{$namespace}", 'use' => $use, 'class' => "{$name}Test", 'methods' => join("\n", $methods));
     if ($this->_save($this->template, $params)) {
         $this->out("{$params['class']} created for {$name} in {$params['namespace']}.");
         return true;
     }
     return false;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:31,代码来源:Test.php


示例9: getMap

 private function getMap($class)
 {
     $properties = Inspector::properties($class, array('public' => false));
     //parse out fields
     $fields = array();
     /** @var \ReflectionProperty $p */
     foreach ($properties as $p) {
         if (($p->getModifiers() & \ReflectionProperty::IS_PROTECTED) == \ReflectionProperty::IS_PROTECTED) {
             $name = $p->getName();
             if ($name[0] != '_') {
                 $fields[$name] = Docblock::comment($p->getDocComment());
             }
         }
     }
     //Parse out types
     $ret = array();
     foreach ($fields as $field => $data) {
         if (isset($data['tags']['var'])) {
             $ret[$field] = $this->dynamicType($data['tags']['var']);
         }
     }
     return $ret;
 }
开发者ID:splitice,项目名称:radical-db,代码行数:23,代码来源:Instance.php


示例10: respondsTo

 /**
  * Custom check to determine if our given magic methods can be responded to.
  *
  * @param  string  $method     Method name.
  * @param  bool    $internal   Interal call or not.
  * @return bool
  */
 public function respondsTo($method, $internal = false)
 {
     $class = $this->_model;
     $modelRespondsTo = false;
     $parentRespondsTo = parent::respondsTo($method, $internal);
     $staticRespondsTo = $class::respondsTo($method, $internal);
     if (method_exists($class, '_object')) {
         $model = $class::invokeMethod('_object');
         $modelRespondsTo = $model->respondsTo($method);
     } else {
         $modelRespondsTo = Inspector::isCallable($class, $method, $internal);
     }
     return $parentRespondsTo || $staticRespondsTo || $modelRespondsTo;
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:21,代码来源:Entity.php


示例11: _parseClass

 public function _parseClass($class)
 {
     $data = array();
     // $methods = Inspector::methods($class, null, array('public' => false));
     $methods = get_class_methods($class);
     $properties = array_keys(get_class_vars($class));
     $ident = $class;
     $info = Inspector::info($ident);
     $info = Docblock::comment($info['comment']);
     $data = $this->_merge($data, array('id' => $info['description'], 'comments' => array($ident)));
     $this->_merge($data, array('id' => $info['text'], 'comments' => array($class)));
     foreach ($methods as $method) {
         $ident = "{$class}::{$method}()";
         $info = Inspector::info($ident);
         $info = Docblock::comment($info['comment']);
         $this->_merge($data, array('id' => $info['description'], 'comments' => array($ident)));
         $this->_merge($data, array('id' => $info['text'], 'comments' => array($ident)));
         if (isset($info['tags']['return'])) {
             $this->_merge($data, array('id' => $info['tags']['return'], 'comments' => array($ident)));
         }
         foreach (Set::extract($info, '/tags/params/text') as $text) {
             $this->_merge($data, array('id' => $text, 'comments' => array($ident)));
         }
     }
     foreach ($properties as $property) {
         $ident = "{$class}::\${$property}";
         $info = Inspector::info($ident);
         $info = Docblock::comment($info['comment']);
         $data = $this->_merge($data, array('id' => $info['description'], 'comments' => array($ident)));
         $data = $this->_merge($data, array('id' => $info['text'], 'comments' => array($ident)));
     }
     return $data;
 }
开发者ID:rmarscher,项目名称:li3_docs,代码行数:33,代码来源:Docs.php


示例12: testBadlyClosedDocblock

 /**
  * This docblock has an extra * in the closing element.
  *
  */
 public function testBadlyClosedDocblock()
 {
     $info = Inspector::info(__METHOD__ . '()');
     $description = 'This docblock has an extra * in the closing element.';
     $this->assertEqual($description, $info['description']);
     $this->assertEqual('', $info['text']);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:11,代码来源:DocblockTest.php


示例13: _properties

 /**
  * Get the properties for the class
  *
  * @param string $class
  * @param array $options
  * @return array
  */
 protected function _properties($class, $options = array())
 {
     $defaults = array('name' => null);
     $options += $defaults;
     $properties = Inspector::properties($class);
     $results = array();
     foreach ($properties as &$property) {
         $comment = Docblock::comment($property['docComment']);
         $description = trim($comment['description']);
         $type = isset($comment['tags']['var']) ? strtok($comment['tags']['var'], ' ') : null;
         $name = str_replace('_', '-', Inflector::underscore($property['name']));
         $usage = $type == 'boolean' ? "-{$name}" : "--{$name}=" . strtoupper($name);
         $results[$name] = compact('name', 'description', 'type', 'usage');
         if ($name == $options['name']) {
             return array($name => $results[$name]);
         }
     }
     return $results;
 }
开发者ID:EHER,项目名称:chegamos,代码行数:26,代码来源:Help.php


示例14: respondsTo

 /**
  * Will determine if a method can be called.
  *
  * @param  string  $method     Method name.
  * @param  bool    $internal   Interal call or not.
  * @return bool
  */
 public static function respondsTo($method, $internal = false)
 {
     return Inspector::isCallable(get_called_class(), $method, $internal);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:11,代码来源:StaticObject.php


示例15: _reportException

 /**
  * Convert an exception object to an exception result array for test reporting.
  *
  * @param object $exception The exception object to report on. Statistics are gathered and
  *               added to the reporting stack contained in `Unit::$_results`.
  * @param string $lineFlag
  * @return void
  * @todo Refactor so that reporters handle trace formatting.
  */
 protected function _reportException($exception, $lineFlag = null)
 {
     $initFrame = current($exception['trace']) + array('class' => '-', 'function' => '-');
     foreach ($exception['trace'] as $frame) {
         if (isset($scopedFrame)) {
             break;
         }
         if (!class_exists('lithium\\analysis\\Inspector')) {
             continue;
         }
         if (isset($frame['class']) && in_array($frame['class'], Inspector::parents($this))) {
             $scopedFrame = $frame;
         }
     }
     $trace = $exception['trace'];
     unset($exception['trace']);
     $this->_result('exception', $exception + array('class' => $initFrame['class'], 'method' => $initFrame['function'], 'trace' => Debugger::trace(array('trace' => $trace, 'format' => '{:functionRef}, line {:line}', 'includeScope' => false, 'scope' => array_filter(array('functionRef' => __NAMESPACE__ . '\\{closure}', 'line' => $lineFlag))))));
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:27,代码来源:Unit.php


示例16: _closureDef

 /**
  * Helper method for caching closure function references to help the process of building the
  * stack trace.
  *
  * @param  array $frame Backtrace information.
  * @param  callable|string $function The method related to $frame information.
  * @return string Returns either the cached or the fetched closure function reference while
  *                writing its reference to the cache array `$_closureCache`.
  */
 protected static function _closureDef($frame, $function)
 {
     $reference = '::';
     $frame += array('file' => '??', 'line' => '??');
     $cacheKey = "{$frame['file']}@{$frame['line']}";
     if (isset(static::$_closureCache[$cacheKey])) {
         return static::$_closureCache[$cacheKey];
     }
     if ($class = Inspector::classes(array('file' => $frame['file']))) {
         foreach (Inspector::methods(key($class), 'extents') as $method => $extents) {
             $line = $frame['line'];
             if (!($extents[0] <= $line && $line <= $extents[1])) {
                 continue;
             }
             $class = key($class);
             $reference = "{$class}::{$method}";
             $function = "{$reference}()::{closure}";
             break;
         }
     } else {
         $reference = $frame['file'];
         $function = "{$reference}::{closure}";
     }
     $line = static::_definition($reference, $frame['line']) ?: '?';
     $function .= " @ {$line}";
     return static::$_closureCache[$cacheKey] = $function;
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:36,代码来源:Debugger.php


示例17: 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


示例18: _renderCommands

 /**
  * Output the formatted available commands.
  *
  * @return void
  */
 protected function _renderCommands()
 {
     $commands = Libraries::locate('command', null, array('recursive' => false));
     foreach ($commands as $key => $command) {
         $library = strtok($command, '\\');
         if (!$key || strtok($commands[$key - 1], '\\') != $library) {
             $this->out("{:heading}COMMANDS{:end} {:blue}via {$library}{:end}");
         }
         $info = Inspector::info($command);
         $name = strtolower(Inflector::slug($info['shortName']));
         $this->out($this->_pad($name), 'heading');
         $this->out($this->_pad($info['description']), 2);
     }
     $message = 'See `{:command}li3 help COMMAND{:end}`';
     $message .= ' for more information on a specific command.';
     $this->out($message, 2);
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:22,代码来源:Help.php


示例19: getProtectedValue

 /**
  * This is a helper method for testStorageMechanism to fetch a private
  * property of the Inflector class.
  *
  * @param string $property
  * @return string The value of the property.
  */
 private function getProtectedValue($property)
 {
     $info = Inspector::info("lithium\\util\\Inflector::{$property}");
     return $info['value'];
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:12,代码来源:InflectorTest.php


示例20: respondsTo

 /**
  * Determines if a given method can be called.
  *
  * @param string $method Name of the method.
  * @param boolean $internal Provide `true` to perform check from inside the
  *                class/object. When `false` checks also for public visibility;
  *                defaults to `false`.
  * @return boolean Returns `true` if the method can be called, `false` otherwise.
  */
 public function respondsTo($method, $internal = false)
 {
     if (method_exists($class = $this->_model, '_object')) {
         $result = $class::invokeMethod('_object')->respondsTo($method);
     } else {
         $result = Inspector::isCallable($class, $method, $internal);
     }
     $result = $result || parent::respondsTo($method, $internal);
     $result = $result || $class::respondsTo($method, $internal);
     return $result;
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:20,代码来源:Entity.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP core\Environment类代码示例发布时间:2022-05-23
下一篇:
PHP action\Dispatcher类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap