1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* JPGraph v4.1.0-beta.01 |
5
|
|
|
*/ |
6
|
|
|
if (!defined('STDIN')) { |
7
|
|
|
define('STDIN', fopen('php://stdin', 'rb')); |
8
|
|
|
} |
9
|
|
|
|
10
|
|
|
if (!defined('STDOUT')) { |
11
|
|
|
define('STDOUT', fopen('php://stdout', 'wb')); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
if (!defined('STDERR')) { |
15
|
|
|
define('STDERR', fopen('php://stderr', 'wb')); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
if (!class_exists('\Kint')) { |
19
|
|
|
/** |
20
|
|
|
* Class that mocks Kint |
21
|
|
|
* (will use this when dev dependencies are not installed). |
22
|
|
|
*/ |
23
|
|
|
class Kint |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
public static $enabled_mode = true; |
26
|
|
|
public static $aliases = []; |
27
|
|
|
public static $mode_default_cli = false; |
28
|
|
|
public static function dump() |
29
|
|
|
{ |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
if (class_exists('\Kint\Renderer\RichRenderer')) { |
34
|
|
|
\Kint\Renderer\RichRenderer::$folder = false; |
35
|
|
|
} |
36
|
|
|
if (method_exists('\Kint', 'enabled')) { |
37
|
|
|
\Kint::enabled(DEBUGMODE); |
38
|
|
|
} elseif (property_exists('\Kint', 'enabled_mode')) { |
39
|
|
|
\Kint::$enabled_mode = Kint::$mode_default_cli; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if (!class_exists('\PhpConsole\Handler')) { |
43
|
|
|
/** |
44
|
|
|
* Class that mocks PHP-Console debug feature. |
45
|
|
|
*/ |
46
|
|
|
class PC |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
public static function debug() |
49
|
|
|
{ |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
function ddd(...$vars) |
54
|
|
|
{ |
55
|
|
|
Kint::dump(...$vars); |
|
|
|
|
56
|
|
|
exit; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function kdump(...$vars) |
60
|
|
|
{ |
61
|
|
|
ob_start(); |
62
|
|
|
|
63
|
|
|
d(...$vars); |
64
|
|
|
|
65
|
|
|
$kintdump = (ob_get_clean()); |
66
|
|
|
|
67
|
|
|
//dump($kintdump); |
68
|
|
|
fwrite(STDERR, $kintdump); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
\Kint::$aliases[] = 'ddd'; |
72
|
|
|
\Kint::$aliases[] = 'kdump'; |
73
|
|
|
|
74
|
|
|
if (getenv('JPGRAPH_USE_PHPCONSOLE') && |
75
|
|
|
isset($_SERVER['HTTP_USER_AGENT']) && |
76
|
|
|
strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false |
77
|
|
|
) { |
78
|
|
|
$handler = \PhpConsole\Handler::getInstance(); |
79
|
|
|
\PhpConsole\Helper::register(); |
80
|
|
|
$handler->start(); |
81
|
|
|
\PC::debug('Started'); |
82
|
|
|
} |
83
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.