1: | <?php |
2: | |
3: | /* |
4: | * The MIT License (MIT) |
5: | * |
6: | * Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com) |
7: | * |
8: | * Permission is hereby granted, free of charge, to any person obtaining a copy of |
9: | * this software and associated documentation files (the "Software"), to deal in |
10: | * the Software without restriction, including without limitation the rights to |
11: | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
12: | * the Software, and to permit persons to whom the Software is furnished to do so, |
13: | * subject to the following conditions: |
14: | * |
15: | * The above copyright notice and this permission notice shall be included in all |
16: | * copies or substantial portions of the Software. |
17: | * |
18: | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19: | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
20: | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
21: | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
22: | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
23: | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
24: | */ |
25: | |
26: | use Kint\Kint; |
27: | |
28: | if (!\function_exists('d')) { |
29: | /** |
30: | * Alias of Kint::dump(). |
31: | * |
32: | * @return int|string |
33: | */ |
34: | function d() |
35: | { |
36: | $args = \func_get_args(); |
37: | |
38: | return \call_user_func_array(array('Kint', 'dump'), $args); |
39: | } |
40: | |
41: | Kint::$aliases[] = 'd'; |
42: | } |
43: | |
44: | if (!\function_exists('s')) { |
45: | /** |
46: | * Alias of Kint::dump(), however the output is in plain text. |
47: | * |
48: | * Alias of Kint::dump(), however the output is in plain htmlescaped text |
49: | * with some minor visibility enhancements added. |
50: | * |
51: | * If run in CLI mode, output is not escaped. |
52: | * |
53: | * To force rendering mode without autodetecting anything: |
54: | * |
55: | * Kint::$enabled_mode = Kint::MODE_PLAIN; |
56: | * Kint::dump( $variable ); |
57: | * |
58: | * @return int|string |
59: | */ |
60: | function s() |
61: | { |
62: | if (!Kint::$enabled_mode) { |
63: | return 0; |
64: | } |
65: | |
66: | $stash = Kint::$enabled_mode; |
67: | |
68: | if (Kint::MODE_TEXT !== Kint::$enabled_mode) { |
69: | Kint::$enabled_mode = Kint::MODE_PLAIN; |
70: | if (PHP_SAPI === 'cli' && true === Kint::$cli_detection) { |
71: | Kint::$enabled_mode = Kint::$mode_default_cli; |
72: | } |
73: | } |
74: | |
75: | $args = \func_get_args(); |
76: | $out = \call_user_func_array(array('Kint', 'dump'), $args); |
77: | |
78: | Kint::$enabled_mode = $stash; |
79: | |
80: | return $out; |
81: | } |
82: | |
83: | Kint::$aliases[] = 's'; |
84: | } |
85: |