本文整理汇总了PHP中Kint::enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Kint::enabled方法的具体用法?PHP Kint::enabled怎么用?PHP Kint::enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kint
的用法示例。
在下文中一共展示了Kint::enabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
\Kint::enabled($config['enabled']);
\Kint::$maxLevels = $config['nesting_depth'];
\Kint::$maxStrLength = $config['string_length'];
$container->setParameter('cg_kint.enabled', $config['enabled']);
$container->setParameter('cg_kint.nesting_depth', $config['nesting_depth']);
$container->setParameter('cg_kint.string_length', $config['string_length']);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
}
示例3: debugLite
/**
* Returns a lite debug string of passed on variables
*
* @return string
*/
function debugLite()
{
if (!Kint::enabled()) {
return '';
} else {
ob_start();
$argv = func_get_args();
echo '<pre>';
foreach ($argv as $k => $v) {
$k && (print "\n\n");
echo s($v);
}
echo '</pre>' . "\n";
return ob_get_clean();
}
}
示例4: __construct
/**
* Application constructor.
*
* @param object $loader The autoloader instance.
* @param array $config The custom configuration of the application.
* @param string $appPath The application absolute path.
* @param array $classesMap The custom classes map of the application.
*/
public function __construct($loader, array $config = [], $appPath = null, array $classesMap = [])
{
# Utilities
$this->utilities = new Utilities($this);
# Register start time
$this->utilities->registerStartTime();
# Store application path
$this->utilities->setApplicationPath($appPath);
# Store classes map
$this['class'] = $this->utilities->setClassesMap($classesMap);
# Call container constructor
parent::__construct($this->utilities->setConfiguration($config));
# Register core services providers
$this->register(new FilesystemServiceProvider());
$this->register(new FinderServiceProvider());
$this->register(new HttpServiceProvider());
$this->register(new LoggerServiceProvider());
$this->register(new MessagesServiceProvider());
$this->register(new RouterServiceProvider());
$this->register(new SupportServiceProvider());
$this->register(new TemplatingServiceProvider());
$this->register(new TriggersServiceProvider());
# Enables the portablity layer and configures PHP for UTF-8
Utf8Bootup::initAll();
# Redirects to an UTF-8 encoded URL if it's not already the case
Utf8Bootup::filterRequestUri();
# Normalizes HTTP inputs to UTF-8 NFC
Utf8Bootup::filterRequestInputs();
# Print errors in debug mode
if ($this['debug']) {
$whoops = new WhoopsRun();
$whoops->pushHandler(new WhoopsHandler());
$whoops->register();
} else {
ErrorHandler::register($this['phpLogger']);
}
# Only enable Kint in debug mode
\Kint::enabled($this['debug']);
}
示例5: array
$timer = array();
$timer['start'] = microtime(true);
/**
* includes
* adjust dirname depth as needed
*/
$base_path = dirname(dirname(dirname(__FILE__)));
require_once $base_path . "/redcap_connect.php";
require_once $base_path . '/plugins/includes/functions.php';
require_once APP_PATH_DOCROOT . '/ProjectGeneral/header.php';
/**
* restricted use
*/
$allowed_pids = array('38');
REDCap::allowProjects($allowed_pids);
Kint::enabled($enable_kint);
/**
* project metadata
*/
global $Proj;
$first_event_id = $Proj->firstEventId;
$plugin_title = "Derive stuff";
/**
* plugin title
*/
echo "<h3>$plugin_title</h3>";
/**
* MAIN
*/
if ($debug) {
$timer['main_start'] = microtime(true);
示例6: init
public static function init()
{
self::$_enableColors = Kint::$cliColors && (DIRECTORY_SEPARATOR === '/' || getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON');
return Kint::enabled() === Kint::MODE_PLAIN ? '<style>.-kint i{color:#d00;font-style:normal}.-kint u{color:#030;text-decoration:none;font-weight:bold}</style>' : '';
}
示例7: dump
/**
* Dump information about variables, accepts any number of parameters, supports modifiers:
*
* clean up any output before kint and place the dump at the top of page:
* - Kint::dump()
* *****
* expand all nodes on display:
* ! Kint::dump()
* *****
* dump variables disregarding their depth:
* + Kint::dump()
* *****
* return output instead of displaying it (also disables ajax/cli detection):
* @ Kint::dump()
* *****
* disable ajax and cli auto-detection and just output as requested (plain/rich):
* ~ Kint::dump()
*
* Modifiers are supported by all dump wrapper functions, including Kint::trace(). Space is optional.
*
*
* You can also use the following shorthand to display debug_backtrace():
* Kint::dump( 1 );
*
* Passing the result from debug_backtrace() to kint::dump() as a single parameter will display it as trace too:
* $trace = debug_backtrace( true );
* Kint::dump( $trace );
* Or simply:
* Kint::dump( debug_backtrace() );
*
*
* @param mixed $data
*
* @return void|string
*/
public static function dump($data = null)
{
if (!Kint::enabled()) {
return '';
}
# find caller information
list($names, $modifiers, $callee, $previousCaller, $miniTrace) = self::_getPassedNames(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace());
# process modifiers: @, +, !, ~ and -
if (strpos($modifiers, '-') !== false) {
self::$_firstRun = true;
while (ob_get_level()) {
ob_end_clean();
}
}
if (strpos($modifiers, '!') !== false) {
$expandedByDefaultOldValue = self::$expandedByDefault;
self::$expandedByDefault = true;
}
if (strpos($modifiers, '+') !== false) {
$maxLevelsOldValue = self::$maxLevels;
self::$maxLevels = false;
}
if (strpos($modifiers, '@') !== false) {
$firstRunOldValue = self::$_firstRun;
self::$_firstRun = true;
}
# disable mode detection
if (strpos($modifiers, '@') !== false || strpos($modifiers, '~') === false) {
$modeOldValue = self::$mode;
$isAjaxOldValue = self::$_isAjax;
if (self::$_detected === 'ajax') {
self::$_isAjax = true;
} elseif (self::$_detected === 'cli' && self::$cliDetection) {
# cli detection is checked here as you can toggle the feature for individual dumps
self::$mode = self::$cliColors ? 'cli' : 'whitespace';
}
}
$decoratorsMap = array('cli' => 'Kint_Decorators_Cli', 'plain' => 'Kint_Decorators_Plain', 'rich' => 'Kint_Decorators_Rich', 'whitespace' => 'Kint_Decorators_Whitespace');
$decorator = $decoratorsMap[self::$mode];
$output = $decorator::wrapStart($callee);
$trace = false;
if ($names === array(null) && func_num_args() === 1 && $data === 1) {
$trace = debug_backtrace(true);
# Kint::dump(1) shorthand
} elseif (func_num_args() === 1 && is_array($data)) {
$trace = $data;
# test if the single parameter is result of debug_backtrace()
}
$trace and $trace = self::_parseTrace($trace);
if ($trace) {
$output .= $decorator::decorateTrace($trace);
} else {
$data = func_num_args() === 0 ? array("[[no arguments passed]]") : func_get_args();
foreach ($data as $k => $argument) {
kintParser::reset();
$output .= $decorator::decorate(kintParser::factory($argument, $names[$k]));
}
}
$output .= $decorator::wrapEnd($callee, $miniTrace, $previousCaller);
if (strpos($modifiers, '~') === false) {
self::$mode = $modeOldValue;
}
if (strpos($modifiers, '!') !== false) {
self::$expandedByDefault = $expandedByDefaultOldValue;
}
//.........这里部分代码省略.........
示例8: example1
<?php
//--------------------------------------------------------------
// Examples: Quandl API
//--------------------------------------------------------------
require "./vendor/autoload.php";
if (file_exists(__DIR__ . '/.env')) {
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
}
Kint::enabled(true);
$api_key = getenv('QUANDL_API_KEY');
$symbol = "GOOG/NASDAQ_AAPL";
// Modify this call to check different samples
$data = example1($api_key, $symbol);
d($data);
// Example 1: Hello Quandl
function example1($api_key, $symbol)
{
$quandl = new Royopa\Quandl\Quandl();
return $quandl->getSymbol($symbol);
}
// Example 2: API Key + JSON
function example2($api_key, $symbol)
{
$quandl = new Royopa\Quandl\Quandl($api_key);
$quandl->format = "json";
return $quandl->getSymbol($symbol);
}
// Example 3: Date Range + Last URL
function example3($api_key, $symbol)
示例9: set_treatment_exp
/**
* @param $record
* @param $debug
*/
public static function set_treatment_exp($record, $debug)
{
global $Proj, $project_id;
$trt_exp_array = array('gen2_mhoccur', 'pegifn_mhoccur', 'triple_mhoccur', 'nopegifn_mhoccur', 'dm_suppdm_trtexp');
$enable_kint = $debug && (isset($record) && $record != '') ? true : false;
Kint::enabled($enable_kint);
$baseline_event_id = $Proj->firstEventId;
$data = REDCap::getData('array', $record, $trt_exp_array, $baseline_event_id);
if ($debug) {
error_log(print_r($data, TRUE));
}
foreach ($data AS $subject_id => $subject) {
/**
* Are you experienced?
*/
$experienced = false;
foreach ($subject AS $event_id => $event) {
if ($event['simsof_mhoccur'] == 'Y' || $event['simsofrbv_mhoccur'] == 'Y' || $event['pegifn_mhoccur'] == 'Y' || $event['triple_mhoccur'] == 'Y' || $event['nopegifn_mhoccur'] == 'Y') {
$experienced = true;
}
}
$trt_exp = $experienced ? 'Y' : 'N';
update_field_compare($subject_id, $project_id, $baseline_event_id, $trt_exp, $subject[$baseline_event_id]['dm_suppdm_trtexp'], 'dm_suppdm_trtexp', $debug);
}
}
示例10: dump
/**
* Dump information about a variable
*
* @param mixed $data
* @return void|string
*/
public static function dump($data)
{
if (!Kint::enabled()) {
return;
}
// decide what action to take based on parameter count
if (func_num_args() === 0) {
// todo if no arguments were provided, dump the whole environment
// self::env(); // todo
return;
}
// find caller information
$prevCaller = array();
$trace = debug_backtrace();
while ($callee = array_pop($trace)) {
if (strtolower($callee['function']) === 'd' || strtolower($callee['function']) === 'dd' || isset($callee['class']) && strtolower($callee['class']) === strtolower(__CLASS__)) {
break;
} else {
$prevCaller = $callee;
}
}
list($names, $modifier) = self::_getPassedNames($callee, '');
// catches @, + and -
switch ($modifier) {
case '-':
self::$_firstRun = TRUE;
ob_clean();
break;
case '+':
$prevLevels = self::$maxLevels;
self::$maxLevels = 0;
break;
}
$ret = self::_css() . self::_wrapStart($callee);
foreach (func_get_args() as $k => $argument) {
$dump = self::_dump($argument);
list($class, $plus) = self::_collapsed();
$ret .= "<dl><dt{$class}>{$plus}" . (!empty($names[$k]) ? "<dfn>{$names[$k]}</dfn> " : "") . "{$dump}</dl>";
}
$ret .= self::_wrapEnd($callee, $prevCaller);
self::$_firstRun = FALSE;
if ($modifier === '+') {
self::$maxLevels = $prevLevels;
}
if ($modifier === '@') {
self::$_firstRun = TRUE;
return $ret;
}
ob_start('kint_debug_globals');
echo $ret;
ob_end_flush();
}
示例11: sd
/**
* @see s()
*
* [!!!] IMPORTANT: execution will halt after call to this function
*
* @return string
*/
function sd()
{
if (!Kint::enabled()) {
return '';
}
Kint::enabled(PHP_SAPI === 'cli' ? Kint::MODE_WHITESPACE : Kint::MODE_PLAIN);
call_user_func_array(array('Kint', 'dump'), func_get_args());
die;
}
示例12: dump_array
/**
* Dumps/Echo out array data with print_r or var_dump if xdebug installed
*
* Will check if xdebug is installed and if so will use standard var_dump,
* otherwise will use print_r inside <pre> tags to give formatted output.
*
* @since 1.1.9
*
* @param $field_data
*/
function dump_array($field_data)
{
if (!$field_data) {
_e('No field data found!', 'wp-job-manager-field-editor');
return;
}
require_once WPJM_FIELD_EDITOR_PLUGIN_DIR . "/includes/kint/Kint.class.php";
Kint::enabled(TRUE);
Kint::dump($field_data);
Kint::enabled(FALSE);
}
示例13: set_hcvrna_outcome
/**
* @param $record
* @param $debug
*/
public static function set_hcvrna_outcome($record, $debug)
{
global $Proj, $project_id, $ie_criteria_labels;
$enable_kint = $debug && (isset($record) && $record != '') ? true : false;
Kint::enabled($enable_kint);
$baseline_event_id = $Proj->firstEventId;
$fieldsets = array('abstracted' => array(array('date_field' => 'hcv_lbdtc'), array('value_field' => 'hcv_lbstresn'), array('detect_field' => 'hcv_supplb_hcvdtct')), 'imported' => array(array('date_field' => 'hcv_im_lbdtc'), array('value_field' => 'hcv_im_lbstresn'), array('detect_field' => 'hcv_im_supplb_hcvdtct'), array('trust' => 'hcv_im_nxtrust')));
$data = array();
$field_translate = array();
$reverse_translate = array();
foreach ($fieldsets as $formtype => $fieldset) {
$filter_logic = $formtype == 'abstracted' ? "[hcv_lbdtc] != ''" : "[hcv_im_lbdtc] != '' AND [hcv_im_nxtrust] != 'N'";
$fields = array();
foreach ($fieldset as $field) {
foreach ($field as $key => $value) {
$fields[] = $value;
$field_translate[$formtype][$key] = $value;
$reverse_translate[$formtype][$value] = $key;
}
}
$data[$formtype] = REDCap::getData('array', $record, $fields, null, null, false, false, false, $filter_logic);
}
/**
* Main
*/
$ie_fields = array('ie_ietestcd');
$ie_data = REDCap::getData('array', $record, $ie_fields);
$date_fields = array('dm_usubjid', 'dm_rfstdtc', 'dis_suppfa_txendt', 'eot_dsterm', 'dis_dsstdy', 'hcv_suppfa_fuelgbl', 'hcv_suppfa_nlgblrsn', 'hcv_suppfa_hcvout', 'hcv_suppfa_wk10rna', 'hcv_suppfa_lastbloq', 'dis_suppds_funcmprsn', 'hcv_suppfa_fudue', 'dm_suppdm_hcvt2id', 'dm_actarmcd', 'dm_suppdm_rtrtsdtc');
$date_data = REDCap::getData('array', $record, $date_fields, $baseline_event_id);
foreach ($date_data as $subject_id => $subject) {
$all_events = array();
$post_tx_dates = array();
$post_tx_bloq_dates = array();
$re_treat_candidate = false;
$re_treat_dates = array();
foreach ($subject as $date_event_id => $date_event) {
/**
* HCV RNA Outcome
*/
$hcvrna_improved = false;
$on_tx_scores = array();
$hcvrna_previous_score = '';
$post_tx_scores = array();
$post_tx_plus10w_scores = array();
$post_tx_plus10d_scores = array();
$last_hcvrna_bloq = false;
$stop_date_plus_10w = null;
$stop_date_plus_10d = null;
$tx_stopped_10_wks_ago = false;
$started_tx = false;
$stopped_tx = false;
$hcv_fu_eligible = true;
$hcv_fu_ineligible_reason = array();
$lost_to_followup = false;
$hcv_data_due = false;
$tx_start_date = isset($date_event['dm_rfstdtc']) && $date_event['dm_rfstdtc'] != '' ? $date_event['dm_rfstdtc'] : null;
$stop_date = isset($date_event['dis_suppfa_txendt']) && $date_event['dis_suppfa_txendt'] != '' ? $date_event['dis_suppfa_txendt'] : null;
$dis_dsstdy = isset($date_event['dis_dsstdy']) && $date_event['dis_dsstdy'] != '' ? $date_event['dis_dsstdy'] : null;
$eot_dsterm = isset($date_event['eot_dsterm']) && $date_event['eot_dsterm'] != '' ? $date_event['eot_dsterm'] : null;
/**
* look for this dm_usubjid in dm_suppdm_hcvt2id. This is a foreign key between TARGET 2 and TARGET 3 patients.
* Get the start date of the TARGET 3 patient if dm_suppdm_hcvt2id is not empty.
*/
$t3_fk_result = db_query("SELECT record FROM redcap_data WHERE project_id = '{$project_id}' AND field_name = 'dm_suppdm_hcvt2id' AND value = '{$date_event['dm_usubjid']}'");
if ($t3_fk_result) {
$t3_fk = db_fetch_assoc($t3_fk_result);
$t3_start_date_value = get_single_field($t3_fk['record'], $project_id, $baseline_event_id, 'dm_rfstdtc', '');
}
$t3_start_date = isset($t3_start_date_value) ? $t3_start_date_value : '';
/**
* where are we in treatment?
*/
if (isset($tx_start_date)) {
// started treatment
$started_tx = true;
/**
* treatment must have started to stop
*/
if (isset($stop_date)) {
// completed treatment
$stopped_tx = true;
$stop_date_plus_10d = add_date($stop_date, 10, 0, 0);
$stop_date_plus_10w = add_date($stop_date, 64, 0, 0);
if (date("Y-m-d") >= $stop_date_plus_10w && isset($stop_date_plus_10w)) {
$tx_stopped_10_wks_ago = true;
}
} else {
// not completed treatment
$stopped_tx = false;
$hcv_fu_eligible = false;
$hcv_fu_ineligible_reason[] = 'TX Not Completed';
}
} else {
// not started treatment
$started_tx = false;
$hcv_fu_eligible = false;
//.........这里部分代码省略.........
示例14: je
/**
* @see j()
* @see de()
*
* @return string
*/
function je()
{
if (!Kint::enabled()) {
return '';
}
$stash = Kint::settings();
Kint::$delayedMode = true;
Kint::enabled(PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS);
$out = call_user_func_array(array('kint\\Kint', 'dump'), func_get_args());
Kint::settings($stash);
return $out;
}
示例15: _parse_string
private static function _parse_string(&$variable, kintVariableData $variableData)
{
$variableData->type = 'string';
$encoding = self::_detectEncoding($variable);
if ($encoding !== 'ASCII') {
$variableData->type .= ' ' . $encoding;
}
if (Kint::enabled() !== Kint::MODE_RICH) {
$variableData->value = '"' . self::escape($variable, $encoding) . '"';
return;
}
$variableData->size = self::_strlen($variable, $encoding);
if (!self::$_placeFullStringInValue) {
$strippedString = preg_replace('[\\s+]', ' ', $variable);
if (Kint::$maxStrLength && $variableData->size > Kint::$maxStrLength) {
// encode and truncate
$variableData->value = '"' . self::escape(self::_substr($strippedString, 0, Kint::$maxStrLength, $encoding), $encoding) . ' …"';
$variableData->extendedValue = self::escape($variable, $encoding);
return;
} elseif ($variable !== $strippedString) {
// omit no data from display
$variableData->value = '"' . self::escape($variable, $encoding) . '"';
$variableData->extendedValue = self::escape($variable, $encoding);
return;
}
}
$variableData->value = '"' . self::escape($variable, $encoding) . '"';
}