1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xmf;
13:
14: /**
15: * Debugging tools for developers
16: *
17: * @category Xmf\Debug
18: * @package Xmf
19: * @author trabis <lusopoemas@gmail.com>
20: * @author Richard Griffith <richard@geekwright.com>
21: * @copyright 2011-2016 XOOPS Project (http://xoops.org)
22: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
23: * @link http://xoops.org
24: */
25: class Debug extends \Kint
26: {
27: /**
28: * Dump one or more variables
29: *
30: * @param mixed $data variable(s) to dump
31: *
32: * @return void
33: */
34: public static function dump($data = null)
35: {
36: $args = func_get_args();
37: // options: 'original' (default), 'solarized', 'solarized-dark' and 'aante-light'
38: parent::$displayCalledFrom = false;
39: parent::$theme = 'aante-light'; // options: 'original' (default), 'solarized', 'solarized-dark' and 'aante-light'
40: call_user_func_array('parent::dump', $args);
41: }
42:
43: /**
44: * Display debug backtrace
45: *
46: * @return void
47: */
48: public static function backtrace()
49: {
50: static::dump(debug_backtrace());
51: }
52:
53: /**
54: * start_trace - turn on xdebug trace
55: *
56: * Requires xdebug extension
57: *
58: * @param string $tracefile file name for trace file
59: * @param string $collect_params argument for ini_set('xdebug.collect_params',?)
60: * Controls display of parameters in trace output
61: * @param string $collect_return argument for ini_set('xdebug.collect_return',?)
62: * Controls display of function return value in trace
63: *
64: * @return void
65: */
66: public static function startTrace($tracefile = '', $collect_params = '3', $collect_return = 'On')
67: {
68: if (function_exists('xdebug_start_trace')) {
69: ini_set('xdebug.collect_params', $collect_params);
70: ini_set('xdebug.collect_return', $collect_return);
71: if ($tracefile == '') {
72: $tracefile = XOOPS_VAR_PATH . '/logs/php_trace';
73: }
74: xdebug_start_trace($tracefile);
75: }
76: }
77:
78: /**
79: * stop_trace - turn off xdebug trace
80: *
81: * Requires xdebug extension
82: *
83: * @return void
84: */
85: public static function stopTrace()
86: {
87: if (function_exists('xdebug_stop_trace')) {
88: xdebug_stop_trace();
89: }
90: }
91: }
92: