1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Bluz Framework Component |
5
|
|
|
* |
6
|
|
|
* @copyright Bluz PHP Team |
7
|
|
|
* @link https://github.com/bluzphp/framework |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
use Bluz\Common\Collection; |
|
|
|
|
13
|
|
|
use Bluz\Common\Str; |
14
|
|
|
use Bluz\Translator\Translator; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Simple functions of framework |
18
|
|
|
* be careful with this way |
19
|
|
|
* |
20
|
|
|
* @author Anton Shevchuk |
21
|
|
|
*/ |
22
|
|
|
if (!function_exists('debug')) { |
23
|
|
|
/** |
24
|
|
|
* Debug variables |
25
|
|
|
* |
26
|
|
|
* Example of usage |
27
|
|
|
* debug(123); |
28
|
|
|
* debug(new stdClass()); |
29
|
|
|
* debug($_GET, $_POST, $_FILES); |
30
|
|
|
* |
31
|
|
|
* @codeCoverageIgnore |
32
|
|
|
* |
33
|
|
|
* @param mixed ...$params |
34
|
|
|
*/ |
35
|
|
|
function debug(...$params) |
36
|
|
|
{ |
37
|
|
|
// check definition |
38
|
|
|
if (!getenv('BLUZ_DEBUG') || !isset($_COOKIE['BLUZ_DEBUG'])) { |
39
|
|
|
return; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
ini_set('xdebug.var_display_max_children', '512'); |
43
|
|
|
|
44
|
|
|
if (PHP_SAPI === 'cli') { |
45
|
|
|
if (extension_loaded('xdebug')) { |
46
|
|
|
// try to enable CLI colors |
47
|
|
|
ini_set('xdebug.cli_color', '1'); |
48
|
|
|
xdebug_print_function_stack(); |
49
|
|
|
} else { |
50
|
|
|
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
51
|
|
|
} |
52
|
|
|
var_dump($params); |
|
|
|
|
53
|
|
|
} else { |
54
|
|
|
echo '<div class="textleft clear"><pre class="bluz-debug">'; |
55
|
|
|
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
56
|
|
|
var_dump($params); |
57
|
|
|
echo '</pre></div>'; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if (!function_exists('esc')) { |
63
|
|
|
/** |
64
|
|
|
* Escape variable for use in View |
65
|
|
|
* |
66
|
|
|
* Example of usage |
67
|
|
|
* esc($_GET['name']); |
68
|
|
|
* esc($_GET['name'], ENT_QUOTES); |
69
|
|
|
* |
70
|
|
|
* @param string $variable |
71
|
|
|
* @param integer $flags |
72
|
|
|
* |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
function esc($variable, int $flags = ENT_HTML5) |
76
|
|
|
{ |
77
|
1 |
|
return htmlentities((string)$variable, $flags, 'UTF-8'); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
if (!function_exists('str_trim_end')) { |
82
|
|
|
/** |
83
|
|
|
* Added symbol to end of string, trim it before |
84
|
|
|
* |
85
|
|
|
* @param string $subject |
86
|
|
|
* @param string $symbols |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
function str_trim_end($subject, $symbols) |
91
|
|
|
{ |
92
|
587 |
|
return rtrim($subject, $symbols) . $symbols; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
if (!function_exists('to_camel_case')) { |
97
|
|
|
/** |
98
|
|
|
* Convert string to camel case |
99
|
|
|
* |
100
|
|
|
* @param string $subject |
101
|
|
|
* |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
function to_camel_case($subject) |
105
|
|
|
{ |
106
|
4 |
|
return Str::toCamelCase($subject); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
if (!function_exists('class_namespace')) { |
111
|
|
|
/** |
112
|
|
|
* Get namespace of class |
113
|
|
|
* |
114
|
|
|
* @param string $class |
115
|
|
|
* |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
|
function class_namespace($class) |
119
|
|
|
{ |
120
|
6 |
|
return substr($class, 0, strrpos($class, '\\')); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
if (!function_exists('value')) { |
125
|
|
|
/** |
126
|
|
|
* Return the value for callable |
127
|
|
|
* |
128
|
|
|
* @param callable|mixed $value |
129
|
|
|
* |
130
|
|
|
* @return mixed |
131
|
|
|
*/ |
132
|
|
|
function value($value) |
133
|
|
|
{ |
134
|
6 |
|
return is_callable($value) ? $value() : $value; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
// @codingStandardsIgnoreStart |
139
|
|
|
if (!function_exists('__')) { |
140
|
|
|
/** |
141
|
|
|
* Translate message |
142
|
|
|
* |
143
|
|
|
* Example of usage |
144
|
|
|
* |
145
|
|
|
* // simple |
146
|
|
|
* // equal to gettext('Message') |
147
|
|
|
* __('Message'); |
148
|
|
|
* |
149
|
|
|
* // simple replace of one or more argument(s) |
150
|
|
|
* // equal to sprintf(gettext('Message to %s'), 'Username') |
151
|
|
|
* __('Message to %s', 'Username'); |
152
|
|
|
* |
153
|
|
|
* @param string $message |
154
|
|
|
* @param string[] $text [optional] |
155
|
|
|
* |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
|
|
function __($message, ...$text) |
159
|
|
|
{ |
160
|
447 |
|
return Translator::translate($message, ...$text); |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
if (!function_exists('_n')) { |
165
|
|
|
/** |
166
|
|
|
* Translate plural form |
167
|
|
|
* |
168
|
|
|
* Example of usage |
169
|
|
|
* |
170
|
|
|
* // plural form + sprintf |
171
|
|
|
* // equal to sprintf(ngettext('%d comment', '%d comments', 4), 4) |
172
|
|
|
* _n('%d comment', '%d comments', 4, 4) |
173
|
|
|
* |
174
|
|
|
* // plural form + sprintf |
175
|
|
|
* // equal to sprintf(ngettext('%d comment', '%d comments', 4), 4, 'Topic') |
176
|
|
|
* _n('%d comment to %s', '%d comments to %s', 4, 'Topic') |
177
|
|
|
* |
178
|
|
|
* @param string $singular |
179
|
|
|
* @param string $plural |
180
|
|
|
* @param integer $number |
181
|
|
|
* @param string[] $text [optional] |
182
|
|
|
* |
183
|
|
|
* @return string |
184
|
|
|
*/ |
185
|
|
|
function _n($singular, $plural, $number, ...$text) |
186
|
|
|
{ |
187
|
|
|
return Translator::translatePlural($singular, $plural, $number, ...$text); |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
// @codingStandardsIgnoreEnd |
191
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths