1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90:
<?php
/**
* MvcCore
*
* This source file is subject to the BSD 3 License
* For the full copyright and license information, please view
* the LICENSE.md file that are distributed with this source code.
*
* @copyright Copyright (c) 2016 Tom FlĂdr (https://github.com/mvccore/mvccore)
* @license https://mvccore.github.io/docs/mvccore/5.0.0/LICENCE.md
*/
namespace MvcCore {
/**
* @inheritDocs
*/
class Debug implements IDebug {
use \MvcCore\Debug\Props;
use \MvcCore\Debug\Initializations;
use \MvcCore\Debug\Handlers;
}
}
namespace {
\MvcCore\Debug::$InitGlobalShortHands = function ($development) {
/**
* Dump any variable with output buffering in browser debug bar,
* store result for printing later. Return printed variable as string.
* @param mixed $value Variable to dump.
* @param string $title Optional title.
* @param array $options Dumper options.
* @return mixed Variable itself.
*/
function x ($value, $title = NULL, $options = []) {
$options['backtraceIndex'] = 2;
return \MvcCore\Debug::BarDump($value, $title, $options);
}
/**
* Dumps multiple variables with output buffering in browser debug bar.
* store result for printing later.
* @param ...mixed Variables to dump.
* @return void
*/
function xx () {
$args = func_get_args();
foreach ($args as $arg) \MvcCore\Debug::BarDump($arg, NULL, ['backtraceIndex' => 2]);
}
if ($development) {
/**
* Dump variables and die. If no variable, throw stop exception.
* @param mixed $args,... Variables to dump.
* @throws \Exception
* @return void
*/
function xxx ($args = NULL) {
$args = func_get_args();
if (count($args) === 0) {
throw new \ErrorException('Stopped.', 500);
} else {
\MvcCore\Application::GetInstance()->GetResponse()->SetHeader('Content-Type', 'text/html');
@header('Content-Type: text/html');
echo '<pre><code>';
foreach ($args as $arg) {
$dumpedArg = \MvcCore\Debug::Dump($arg, TRUE, TRUE);
echo preg_replace("#\[([^\]]*)\]=>([^\n]*)\n(\s*)#", "[$1] => ", $dumpedArg);
echo '</code></pre>';
}
}
exit;
}
} else {
/**
* Log variables and die. If no variable, throw stop exception.
* @param mixed $args,... Variables to dump.
* @throws \Exception
* @return void
*/
function xxx ($args = NULL) {
$args = func_get_args();
if (count($args) > 0)
foreach ($args as $arg)
\MvcCore\Debug::Log($arg, \MvcCore\IDebug::DEBUG);
echo 'Error 500 - Stopped.';
exit;
}
}
};
}