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


PHP Kint::displayCalledFrom方法代码示例

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


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

示例1: setUpKint

 protected function setUpKint()
 {
     if (class_exists('Kint')) {
         Kint::$cliDetection = true;
         Kint::$maxLevels = 10;
         Kint::$theme = 'aante-light';
         Kint::$displayCalledFrom = true;
         Kint::enabled(Kint::MODE_RICH);
     }
 }
开发者ID:bozhich,项目名称:PHP-on-Rails,代码行数:10,代码来源:Bootstrap.php

示例2: Config

<?php

use PhpSandbox\Evaluator\Config;
// start count memory usage
$ev__memory_bootstrap_start = ['usage' => memory_get_usage(), 'peak' => memory_get_peak_usage()];
require __DIR__ . '/../vendor/raveren/kint/Kint.class.php';
require __DIR__ . '/Evaluator/Config.php';
$config = new Config(__DIR__ . '/config.php');
if (file_exists($config->read('vendors_dir') . '/autoload.php')) {
    require $config->read('vendors_dir') . '/autoload.php';
}
// Kint configuration
Kint::$displayCalledFrom = false;
Kint::$expandedByDefault = true;
Kint::$cliDetection = false;
Kint::$theme = 'solarized-dark';
// we do not want calculate memory used by bootstrap
$ev__memory = ['usage' => memory_get_usage(), 'peak' => memory_get_peak_usage()];
array_walk($ev__memory, function (&$value, $key) use($ev__memory_bootstrap_start) {
    $value = $value - $ev__memory_bootstrap_start[$key];
});
开发者ID:plugowski,项目名称:php_sandbox,代码行数:21,代码来源:bootstrap.php

示例3: kint

 /**
  * Provides Kint function to Twig templates.
  *
  * Handles 0, 1, or multiple arguments.
  *
  * Code derived from https://github.com/barelon/CgKintBundle.
  *
  * @param Twig_Environment $env
  *   The twig environment instance.
  * @param array $context
  *   An array of parameters passed to the template.
  */
 public function kint(\Twig_Environment $env, array $context)
 {
     // Don't do anything unless twig_debug is enabled. This reads from the Twig
     // environment, not Drupal Settings, so a container rebuild is necessary
     // when toggling twig_debug on and off. We can consider injecting Settings.
     if (!$env->isDebug()) {
         return;
     }
     kint_require();
     // Don't display where Kint was called from.
     // @todo Can we add information about which template Kint was called from?
     \Kint::$displayCalledFrom = FALSE;
     $output = '';
     if (func_num_args() === 2) {
         // No arguments passed to kint(), display full Twig context.
         $kint_variable = array();
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $kint_variable[$key] = $value;
             }
         }
         $result = @\Kint::dump($kint_variable);
         $output = str_replace('$kint_variable', 'Twig context', $result);
     } else {
         // Try to get the names of variables from the Twig template.
         $trace = debug_backtrace();
         $callee = $trace[0];
         $lines = file($callee['file']);
         $source = $lines[$callee['line'] - 1];
         preg_match('/kint\\((.+)\\);/', $source, $matches);
         $parameters = $matches[1];
         $parameters = preg_replace('/\\$this->getContext\\(\\$context, "(.+)"\\)/U', "\$1", $parameters);
         $parameters = preg_replace('/\\(isset\\(\\$context\\["(.+)"\\]\\) \\? \\$context\\["(.+)"\\] : null\\)/U', "\$1", $parameters);
         do {
             $parameters = preg_replace('/\\$this->getAttribute\\((.+), "(.+)"\\)/U', "\$1.\$2", $parameters, 1, $found);
         } while ($found);
         $parameters = explode(', ', $parameters);
         foreach ($parameters as $index => $parameter) {
             // Remove bad entries from the parameters array. Maybe we can avoid this
             // by doing more with the regular expressions.
             // This only seems to be needed for cases like:
             // {{ my_array['#hash_index'] }}
             if (in_array($parameter, array('array()', '"array'))) {
                 unset($parameters[$index]);
                 continue;
             }
             // Trim parens and quotes from the parameter strings.
             $parameters[$index] = trim($parameter, '()"');
         }
         // Don't include $env and $context arguments in $args and $parameters.
         $args = array_slice(func_get_args(), 2);
         $parameters = array_slice($parameters, 2);
         // If there is only one argument, pass to Kint without too much hassle.
         if (count($args) == 1) {
             $kint_variable = reset($args);
             $result = @\Kint::dump($kint_variable);
             // Replace $kint_variable with the name of the variable in the Twig
             // template.
             $output = str_replace('$kint_variable', reset($parameters), $result);
         } else {
             // Build an array of variable to pass to Kint.
             // @todo Can we just call_user_func_array while still retaining the
             //   variable names?
             foreach ($args as $index => $arg) {
                 // Prepend a unique index to allow debugging the same variable more
                 // than once in the same Kint dump.
                 $kint_args['_index_' . $index . '_' . $parameters[$index]] = $arg;
             }
             $result = @\Kint::dump($kint_args);
             // Display a comma separated list of the variables contained in this group.
             $output = str_replace('$kint_args', implode(', ', $parameters), $result);
             // Remove unique indexes from output.
             $output = preg_replace('/_index_([0-9]+)_/', '', $output);
         }
     }
     return $output;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:89,代码来源:KintExtension.php


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