@@ -5,10 +5,8 @@ |
||
5 | 5 | use Cassandra\Exception; |
6 | 6 | use DebugBar\DataCollector\ConfigCollector; |
7 | 7 | use DebugBar\DebugBarException; |
8 | -use DebugBar\StandardDebugBar; |
|
9 | 8 | use Ffcms\Core\App; |
10 | 9 | use Ffcms\Core\Helper\Type\Any; |
11 | -use Ffcms\Core\Helper\Type\Obj; |
|
12 | 10 | |
13 | 11 | /** |
14 | 12 | * Class Debug. Provide methods of display information about debug and collected data in debug bar |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } elseif (method_exists($class, $obj)) { // maybe its a function? |
138 | 138 | $class = $class::$obj; // call function |
139 | 139 | } else { |
140 | - throw new SyntaxException('Filter callback execution failed: ' . $filterName); |
|
140 | + throw new SyntaxException('Filter callback execution failed: '.$filterName); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if (method_exists($class, $method)) { |
147 | 147 | $check = @$class::$method($fieldValue, $filterArgs); |
148 | 148 | } else { |
149 | - throw new SyntaxException('Filter callback execution failed: ' . $filterName); |
|
149 | + throw new SyntaxException('Filter callback execution failed: '.$filterName); |
|
150 | 150 | } |
151 | 151 | } elseif (method_exists('Ffcms\Core\Helper\ModelFilters', $filterName)) { // only full namespace\class path based :( |
152 | 152 | if ($filterArgs != null) { |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | $check = ModelFilters::$filterName($fieldValue); |
156 | 156 | } |
157 | 157 | } else { |
158 | - throw new SyntaxException('Filter "' . $filterName . '" is not exist'); |
|
158 | + throw new SyntaxException('Filter "'.$filterName.'" is not exist'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // if one from all validation tests is fail - mark as incorrect attribute |
162 | 162 | if ($check !== true) { |
163 | 163 | $this->_badAttr[] = $propertyName; |
164 | 164 | if (App::$Debug) |
165 | - App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning'); |
|
165 | + App::$Debug->addMessage('Validation failed. Property: '.$propertyName.', filter: '.$filterName, 'warning'); |
|
166 | 166 | } else { |
167 | 167 | $field_set_name = $propertyName; |
168 | 168 | // prevent array-type setting |
@@ -59,21 +59,24 @@ discard block |
||
59 | 59 | public function runValidate(array $rules = null) |
60 | 60 | { |
61 | 61 | // skip validation on empty rules |
62 | - if ($rules === null) |
|
63 | - return true; |
|
62 | + if ($rules === null) { |
|
63 | + return true; |
|
64 | + } |
|
64 | 65 | |
65 | 66 | $success = true; |
66 | 67 | // list each rule as single one |
67 | 68 | foreach ($rules as $rule) { |
68 | 69 | // 0 = field (property) name, 1 = filter name, 2 = filter value |
69 | - if ($rule[0] === null || $rule[1] === null) |
|
70 | - continue; |
|
70 | + if ($rule[0] === null || $rule[1] === null) { |
|
71 | + continue; |
|
72 | + } |
|
71 | 73 | |
72 | 74 | $propertyName = $rule[0]; |
73 | 75 | $validationRule = $rule[1]; |
74 | 76 | $validationValue = null; |
75 | - if (isset($rule[2])) |
|
76 | - $validationValue = $rule[2]; |
|
77 | + if (isset($rule[2])) { |
|
78 | + $validationValue = $rule[2]; |
|
79 | + } |
|
77 | 80 | |
78 | 81 | // check if target field defined as array and make recursive validation |
79 | 82 | if (Any::isArray($propertyName)) { |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | // if one from all validation tests is fail - mark as incorrect attribute |
162 | 165 | if ($check !== true) { |
163 | 166 | $this->_badAttr[] = $propertyName; |
164 | - if (App::$Debug) |
|
165 | - App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning'); |
|
167 | + if (App::$Debug) { |
|
168 | + App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning'); |
|
169 | + } |
|
166 | 170 | } else { |
167 | 171 | $field_set_name = $propertyName; |
168 | 172 | // prevent array-type setting |
@@ -173,8 +177,9 @@ discard block |
||
173 | 177 | if ($propertyName !== $field_set_name) { // array-based property |
174 | 178 | $dot_path = trim(strstr($propertyName, '.'), '.'); |
175 | 179 | // prevent throws any exceptions for null and false objects |
176 | - if (!Any::isArray($this->{$field_set_name})) |
|
177 | - $this->{$field_set_name} = []; |
|
180 | + if (!Any::isArray($this->{$field_set_name})) { |
|
181 | + $this->{$field_set_name} = []; |
|
182 | + } |
|
178 | 183 | |
179 | 184 | // use dot-data provider to compile output array |
180 | 185 | $dotData = new DotData($this->{$field_set_name}); |
@@ -204,14 +209,16 @@ discard block |
||
204 | 209 | $sources = $this->sources(); |
205 | 210 | $types = $this->types(); |
206 | 211 | // validate sources for current field |
207 | - if (array_key_exists($propertyName, $sources)) |
|
208 | - $inputType = Str::lowerCase($sources[$propertyName]); |
|
212 | + if (array_key_exists($propertyName, $sources)) { |
|
213 | + $inputType = Str::lowerCase($sources[$propertyName]); |
|
214 | + } |
|
209 | 215 | |
210 | 216 | |
211 | 217 | // check if field is array-nested element by dots and use first element as general |
212 | 218 | $filterField = $propertyName; |
213 | - if (array_key_exists($filterField, $types)) |
|
214 | - $filterType = Str::lowerCase($types[$filterField]); |
|
219 | + if (array_key_exists($filterField, $types)) { |
|
220 | + $filterType = Str::lowerCase($types[$filterField]); |
|
221 | + } |
|
215 | 222 | |
216 | 223 | // get clear field value |
217 | 224 | $propertyValue = $this->getRequest($propertyName, $inputType); |
@@ -313,8 +320,9 @@ discard block |
||
313 | 320 | */ |
314 | 321 | public function getRequest($param, $method = null) |
315 | 322 | { |
316 | - if ($method === null) |
|
317 | - $method = $this->_sendMethod; |
|
323 | + if ($method === null) { |
|
324 | + $method = $this->_sendMethod; |
|
325 | + } |
|
318 | 326 | |
319 | 327 | $method = Str::lowerCase($method); |
320 | 328 | // get root request as array or string |
@@ -338,8 +346,9 @@ discard block |
||
338 | 346 | if (Str::contains('.', $param)) { |
339 | 347 | $response = $request; |
340 | 348 | foreach (explode('.', $param) as $path) { |
341 | - if (!array_key_exists($path, $response)) |
|
342 | - return null; |
|
349 | + if (!array_key_exists($path, $response)) { |
|
350 | + return null; |
|
351 | + } |
|
343 | 352 | // find deep array nesting offset |
344 | 353 | $response = $response[$path]; |
345 | 354 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function length_min($object, $length): bool |
25 | 25 | { |
26 | - if (!Any::isLine($object)) |
|
27 | - return false; |
|
26 | + if (!Any::isLine($object)) { |
|
27 | + return false; |
|
28 | + } |
|
28 | 29 | |
29 | 30 | return Str::length((string)$object) >= $length; |
30 | 31 | } |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | */ |
38 | 39 | public static function length_max($object, $length): bool |
39 | 40 | { |
40 | - if (!Any::isLine($object)) |
|
41 | - return false; |
|
41 | + if (!Any::isLine($object)) { |
|
42 | + return false; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | return Str::length((string)$object) <= $length; |
44 | 46 | } |
@@ -51,12 +53,14 @@ discard block |
||
51 | 53 | */ |
52 | 54 | public static function in($object, array $handle): bool |
53 | 55 | { |
54 | - if (!Any::isLine($object)) |
|
55 | - return false; |
|
56 | + if (!Any::isLine($object)) { |
|
57 | + return false; |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // allow empty, validate on required rule |
58 | - if (Any::isEmpty($object)) |
|
59 | - return true; |
|
61 | + if (Any::isEmpty($object)) { |
|
62 | + return true; |
|
63 | + } |
|
60 | 64 | |
61 | 65 | $object = Any::guessValueType($object); |
62 | 66 | |
@@ -82,8 +86,9 @@ discard block |
||
82 | 86 | */ |
83 | 87 | public static function checked($object): bool |
84 | 88 | { |
85 | - if (!Any::isBool($object)) |
|
86 | - return false; |
|
89 | + if (!Any::isBool($object)) { |
|
90 | + return false; |
|
91 | + } |
|
87 | 92 | |
88 | 93 | return (bool)$object; |
89 | 94 | } |
@@ -155,11 +160,14 @@ discard block |
||
155 | 160 | */ |
156 | 161 | public static function email($object): bool |
157 | 162 | { |
158 | - if (Any::isEmpty($object)) // allow empty |
|
163 | + if (Any::isEmpty($object)) { |
|
164 | + // allow empty |
|
159 | 165 | return true; |
166 | + } |
|
160 | 167 | |
161 | - if (!Any::isLine($object)) |
|
162 | - return false; |
|
168 | + if (!Any::isLine($object)) { |
|
169 | + return false; |
|
170 | + } |
|
163 | 171 | |
164 | 172 | return Str::isEmail($object); |
165 | 173 | } |
@@ -171,11 +179,14 @@ discard block |
||
171 | 179 | */ |
172 | 180 | public static function phone($object): bool |
173 | 181 | { |
174 | - if (Any::isEmpty($object)) // allow empty |
|
182 | + if (Any::isEmpty($object)) { |
|
183 | + // allow empty |
|
175 | 184 | return true; |
185 | + } |
|
176 | 186 | |
177 | - if (!Any::isLine($object)) |
|
178 | - return false; |
|
187 | + if (!Any::isLine($object)) { |
|
188 | + return false; |
|
189 | + } |
|
179 | 190 | |
180 | 191 | return Str::isPhone($object); |
181 | 192 | } |
@@ -187,11 +198,14 @@ discard block |
||
187 | 198 | */ |
188 | 199 | public static function url($object): bool |
189 | 200 | { |
190 | - if (Any::isEmpty($object)) // allow empty |
|
201 | + if (Any::isEmpty($object)) { |
|
202 | + // allow empty |
|
191 | 203 | return true; |
204 | + } |
|
192 | 205 | |
193 | - if (!Any::isLine($object)) |
|
194 | - return false; |
|
206 | + if (!Any::isLine($object)) { |
|
207 | + return false; |
|
208 | + } |
|
195 | 209 | |
196 | 210 | return Str::isUrl($object); |
197 | 211 | } |
@@ -204,8 +218,9 @@ discard block |
||
204 | 218 | */ |
205 | 219 | public static function equal($object, $value = null): bool |
206 | 220 | { |
207 | - if (!Any::isLine($object)) |
|
208 | - return false; |
|
221 | + if (!Any::isLine($object)) { |
|
222 | + return false; |
|
223 | + } |
|
209 | 224 | |
210 | 225 | return $object === $value; |
211 | 226 | } |
@@ -218,8 +233,9 @@ discard block |
||
218 | 233 | */ |
219 | 234 | public static function notequal($object, $value = null): bool |
220 | 235 | { |
221 | - if (!Any::isLine($object)) |
|
222 | - return false; |
|
236 | + if (!Any::isLine($object)) { |
|
237 | + return false; |
|
238 | + } |
|
223 | 239 | |
224 | 240 | return $object !== $value; |
225 | 241 | } |
@@ -254,11 +270,13 @@ discard block |
||
254 | 270 | */ |
255 | 271 | public static function reg_match($object, $value): bool |
256 | 272 | { |
257 | - if (!Any::isLine($object)) |
|
258 | - return false; |
|
273 | + if (!Any::isLine($object)) { |
|
274 | + return false; |
|
275 | + } |
|
259 | 276 | |
260 | - if (Str::likeEmpty($object)) |
|
261 | - return true; |
|
277 | + if (Str::likeEmpty($object)) { |
|
278 | + return true; |
|
279 | + } |
|
262 | 280 | |
263 | 281 | // what the f*ck? -> return preg_match($value, $object) > 0; |
264 | 282 | return (bool)preg_match($value, $object); |
@@ -272,8 +290,9 @@ discard block |
||
272 | 290 | */ |
273 | 291 | public static function intList($object, $value): bool |
274 | 292 | { |
275 | - if (!Any::isLine($object)) |
|
276 | - return false; |
|
293 | + if (!Any::isLine($object)) { |
|
294 | + return false; |
|
295 | + } |
|
277 | 296 | |
278 | 297 | return !preg_match('/[^0-9\s,]/$', $object); |
279 | 298 | } |
@@ -287,8 +306,9 @@ discard block |
||
287 | 306 | public static function isFile($object, $value): bool |
288 | 307 | { |
289 | 308 | // allow empty fields, "required" option filter that |
290 | - if ($object === null) |
|
291 | - return true; |
|
309 | + if ($object === null) { |
|
310 | + return true; |
|
311 | + } |
|
292 | 312 | |
293 | 313 | $all = false; |
294 | 314 | // if string is given |
@@ -301,13 +321,15 @@ discard block |
||
301 | 321 | } |
302 | 322 | |
303 | 323 | // input file is not object? |
304 | - if ($object === null || !Any::isObj($object)) |
|
305 | - return false; |
|
324 | + if ($object === null || !Any::isObj($object)) { |
|
325 | + return false; |
|
326 | + } |
|
306 | 327 | |
307 | 328 | // get guess file type, based on mime-type |
308 | 329 | $type = $object->guessExtension(); |
309 | - if ($type === null) |
|
310 | - return false; |
|
330 | + if ($type === null) { |
|
331 | + return false; |
|
332 | + } |
|
311 | 333 | |
312 | 334 | return ($all ? true : Arr::in($type, $value)); |
313 | 335 | } |
@@ -321,21 +343,24 @@ discard block |
||
321 | 343 | public static function sizeFile($object, $value): bool |
322 | 344 | { |
323 | 345 | // allow empty field, validate on filter 'required' |
324 | - if ($object === null) |
|
325 | - return true; |
|
346 | + if ($object === null) { |
|
347 | + return true; |
|
348 | + } |
|
326 | 349 | |
327 | 350 | if (!Any::isArray($value)) { |
328 | 351 | $value = [0, $value]; |
329 | 352 | } |
330 | 353 | |
331 | 354 | // input file is not object? |
332 | - if ($object === null || !Any::isObj($object)) |
|
333 | - return false; |
|
355 | + if ($object === null || !Any::isObj($object)) { |
|
356 | + return false; |
|
357 | + } |
|
334 | 358 | |
335 | 359 | // get file upload size in bytes |
336 | 360 | $realSize = $object->getClientSize(); |
337 | - if ($realSize === null) |
|
338 | - return false; |
|
361 | + if ($realSize === null) { |
|
362 | + return false; |
|
363 | + } |
|
339 | 364 | |
340 | 365 | return $realSize > $value[0] && $realSize <= $value[1]; |
341 | 366 | } |
@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | public static function in($needle, ?array $haystack = null, bool $strict = true): bool |
20 | 20 | { |
21 | 21 | // prevent errors |
22 | - if (!Any::isArray($haystack) || $needle === null) |
|
23 | - return false; |
|
22 | + if (!Any::isArray($haystack) || $needle === null) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | 26 | return in_array($needle, $haystack, $strict); |
26 | 27 | } |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | { |
34 | 35 | $arguments = []; |
35 | 36 | foreach (func_get_args() as $key => $val) { |
36 | - if (!Any::isArray($val)) |
|
37 | - $val = []; |
|
37 | + if (!Any::isArray($val)) { |
|
38 | + $val = []; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | $arguments[$key] = $val; |
40 | 42 | } |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | { |
50 | 52 | $arguments = []; |
51 | 53 | foreach (func_get_args() as $key => $val) { |
52 | - if (!Any::isArray($val)) |
|
53 | - $val = []; |
|
54 | + if (!Any::isArray($val)) { |
|
55 | + $val = []; |
|
56 | + } |
|
54 | 57 | |
55 | 58 | $arguments[$key] = $val; |
56 | 59 | } |
@@ -67,18 +70,21 @@ discard block |
||
67 | 70 | public static function getByPath(string $path, ?array $array = null, $delimiter = '.') |
68 | 71 | { |
69 | 72 | // path of nothing? interest |
70 | - if (!Any::isArray($array) || count($array) < 1 || !Any::isStr($path) || Str::likeEmpty($path)) |
|
71 | - return null; |
|
73 | + if (!Any::isArray($array) || count($array) < 1 || !Any::isStr($path) || Str::likeEmpty($path)) { |
|
74 | + return null; |
|
75 | + } |
|
72 | 76 | |
73 | 77 | // c'mon man, what the f*ck are you doing? )) |
74 | - if (!Str::contains($delimiter, $path)) |
|
75 | - return $array[$path]; |
|
78 | + if (!Str::contains($delimiter, $path)) { |
|
79 | + return $array[$path]; |
|
80 | + } |
|
76 | 81 | |
77 | 82 | $output = $array; |
78 | 83 | $pathArray = explode($delimiter, $path); |
79 | 84 | foreach ($pathArray as $key) { |
80 | - if (!Any::isArray($output) || !array_key_exists($key, $output)) |
|
81 | - return null; |
|
85 | + if (!Any::isArray($output) || !array_key_exists($key, $output)) { |
|
86 | + return null; |
|
87 | + } |
|
82 | 88 | |
83 | 89 | $output = $output[$key]; |
84 | 90 | } |
@@ -93,14 +99,16 @@ discard block |
||
93 | 99 | */ |
94 | 100 | public static function pluck(?string $key = null, ?array $array = null): array |
95 | 101 | { |
96 | - if (!Any::isArray($array) || !Any::isStr($key)) |
|
97 | - return []; |
|
102 | + if (!Any::isArray($array) || !Any::isStr($key)) { |
|
103 | + return []; |
|
104 | + } |
|
98 | 105 | |
99 | 106 | $output = []; |
100 | 107 | foreach ($array as $item) { |
101 | 108 | $object = $item[$key]; |
102 | - if (!self::in($object, $output)) |
|
103 | - $output[] = $object; |
|
109 | + if (!self::in($object, $output)) { |
|
110 | + $output[] = $object; |
|
111 | + } |
|
104 | 112 | } |
105 | 113 | return $output; |
106 | 114 | } |
@@ -148,8 +156,9 @@ discard block |
||
148 | 156 | */ |
149 | 157 | public static function onlyNumericValues(?array $array = null) |
150 | 158 | { |
151 | - if (!Any::isArray($array)) |
|
152 | - return false; |
|
159 | + if (!Any::isArray($array)) { |
|
160 | + return false; |
|
161 | + } |
|
153 | 162 | |
154 | 163 | return is_numeric(implode('', $array)); |
155 | 164 | } |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | $this->lang = App::$Request->getLanguage(); |
56 | 56 | // get theme config and build full path |
57 | 57 | $themeConfig = App::$Properties->get('theme'); |
58 | - $this->themePath = root . DIRECTORY_SEPARATOR . 'Apps' . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . env_name; |
|
58 | + $this->themePath = root.DIRECTORY_SEPARATOR.'Apps'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.env_name; |
|
59 | 59 | if (isset($themeConfig[env_name]) && Str::length($themeConfig[env_name]) > 0) { |
60 | - $this->themePath .= DIRECTORY_SEPARATOR . $themeConfig[env_name]; |
|
60 | + $this->themePath .= DIRECTORY_SEPARATOR.$themeConfig[env_name]; |
|
61 | 61 | } else { |
62 | - $this->themePath .= DIRECTORY_SEPARATOR . 'default'; |
|
62 | + $this->themePath .= DIRECTORY_SEPARATOR.'default'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // check if theme is available |
66 | 66 | if (!Directory::exist($this->themePath)) |
67 | - throw new NativeException('Apps theme is not founded: ' . Str::replace(root, null, $this->themePath)); |
|
67 | + throw new NativeException('Apps theme is not founded: '.Str::replace(root, null, $this->themePath)); |
|
68 | 68 | |
69 | 69 | // get input args and build class properties |
70 | 70 | $args = func_get_args(); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | // path still not defined? |
104 | 104 | if (!$path) |
105 | - throw new SyntaxException('View not found: ' . App::$Security->strip_tags($path)); |
|
105 | + throw new SyntaxException('View not found: '.App::$Security->strip_tags($path)); |
|
106 | 106 | |
107 | 107 | // cleanup from slashes on start/end |
108 | 108 | $path = trim($path, '/\\'); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // lets try to get full path for current theme |
131 | 131 | $tmpPath = $path; |
132 | 132 | if (!Str::startsWith($this->themePath, $path)) |
133 | - $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php'); |
|
133 | + $tmpPath = Normalize::diskPath($this->themePath.'/'.$path.'.php'); |
|
134 | 134 | } else { // sounds like a object-depended view call from controller or etc |
135 | 135 | // get stack trace of callbacks |
136 | 136 | $calledLog = @debug_backtrace(); |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | |
145 | 145 | // depended controller is not founded? Let finish |
146 | 146 | if (!$calledController) |
147 | - throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: ' . $path); |
|
147 | + throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: '.$path); |
|
148 | 148 | |
149 | 149 | // get controller name |
150 | - $controllerName = Str::sub($calledController, Str::length('Apps\Controller\\' . env_name . '\\')); |
|
150 | + $controllerName = Str::sub($calledController, Str::length('Apps\Controller\\'.env_name.'\\')); |
|
151 | 151 | $controllerName = Str::lowerCase($controllerName); |
152 | 152 | // get full path |
153 | - $tmpPath = $this->themePath . DIRECTORY_SEPARATOR . $controllerName . DIRECTORY_SEPARATOR . $path . '.php'; |
|
153 | + $tmpPath = $this->themePath.DIRECTORY_SEPARATOR.$controllerName.DIRECTORY_SEPARATOR.$path.'.php'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // check if builded view full path is exist |
@@ -159,18 +159,18 @@ discard block |
||
159 | 159 | |
160 | 160 | // hmm, not founded. Lets try to find in caller directory (for widgets, apps packages and other) |
161 | 161 | if ($source !== null) { |
162 | - $tmpPath = Normalize::diskPath($source . DIRECTORY_SEPARATOR . $path . '.php'); |
|
162 | + $tmpPath = Normalize::diskPath($source.DIRECTORY_SEPARATOR.$path.'.php'); |
|
163 | 163 | if (File::exist($tmpPath)) { |
164 | 164 | // add notify for native views |
165 | 165 | if (App::$Debug) |
166 | - App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info'); |
|
166 | + App::$Debug->addMessage('Render native viewer: '.Str::replace(root, null, $tmpPath), 'info'); |
|
167 | 167 | |
168 | 168 | return $tmpPath; |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | 172 | if (App::$Debug) |
173 | - App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning'); |
|
173 | + App::$Debug->addMessage('Viewer not founded on rendering: '.$path, 'warning'); |
|
174 | 174 | |
175 | 175 | return null; |
176 | 176 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | foreach ($items as $item) { |
263 | 263 | $item = trim($item, '/'); |
264 | 264 | if (!Str::startsWith(App::$Alias->scriptUrl, $item) && !Str::startsWith('http', $item)) { // is local without proto and domain |
265 | - $item = App::$Alias->scriptUrl . '/' . $item; |
|
265 | + $item = App::$Alias->scriptUrl.'/'.$item; |
|
266 | 266 | } |
267 | 267 | $output[] = $item; |
268 | 268 | } |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | $output = null; |
272 | 272 | foreach ($clear as $row) { |
273 | 273 | if ($type === 'css') { |
274 | - $output .= '<link rel="stylesheet" type="text/css" href="' . $row . '">' . "\n"; |
|
274 | + $output .= '<link rel="stylesheet" type="text/css" href="'.$row.'">'."\n"; |
|
275 | 275 | } elseif ($type === 'js') { |
276 | - $output .= '<script src="' . $row . '"></script>' . "\n"; |
|
276 | + $output .= '<script src="'.$row.'"></script>'."\n"; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | $code = null; |
297 | 297 | foreach (App::$Alias->getPlainCode($type) as $row) { |
298 | - $code .= $row . "\n"; |
|
298 | + $code .= $row."\n"; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | return $code; |
@@ -63,8 +63,9 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // check if theme is available |
66 | - if (!Directory::exist($this->themePath)) |
|
67 | - throw new NativeException('Apps theme is not founded: ' . Str::replace(root, null, $this->themePath)); |
|
66 | + if (!Directory::exist($this->themePath)) { |
|
67 | + throw new NativeException('Apps theme is not founded: ' . Str::replace(root, null, $this->themePath)); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | // get input args and build class properties |
70 | 71 | $args = func_get_args(); |
@@ -89,20 +90,24 @@ discard block |
||
89 | 90 | $source = $this->sourcePath; |
90 | 91 | |
91 | 92 | // if path is not defined - try to find it in arguments |
92 | - if (!$path) |
|
93 | - $path = array_shift($arguments); |
|
93 | + if (!$path) { |
|
94 | + $path = array_shift($arguments); |
|
95 | + } |
|
94 | 96 | |
95 | 97 | // if arguments is not define - try to find in arguments |
96 | - if (!$params) |
|
97 | - $params = array_shift($arguments); |
|
98 | + if (!$params) { |
|
99 | + $params = array_shift($arguments); |
|
100 | + } |
|
98 | 101 | |
99 | 102 | // if directory of caller is not defiend - lets find in argument |
100 | - if (!$source) |
|
101 | - $source = array_shift($arguments); |
|
103 | + if (!$source) { |
|
104 | + $source = array_shift($arguments); |
|
105 | + } |
|
102 | 106 | |
103 | 107 | // path still not defined? |
104 | - if (!$path) |
|
105 | - throw new SyntaxException('View not found: ' . App::$Security->strip_tags($path)); |
|
108 | + if (!$path) { |
|
109 | + throw new SyntaxException('View not found: ' . App::$Security->strip_tags($path)); |
|
110 | + } |
|
106 | 111 | |
107 | 112 | // cleanup from slashes on start/end |
108 | 113 | $path = trim($path, '/\\'); |
@@ -129,8 +134,9 @@ discard block |
||
129 | 134 | if (Str::contains('/', $path)) { |
130 | 135 | // lets try to get full path for current theme |
131 | 136 | $tmpPath = $path; |
132 | - if (!Str::startsWith($this->themePath, $path)) |
|
133 | - $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php'); |
|
137 | + if (!Str::startsWith($this->themePath, $path)) { |
|
138 | + $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php'); |
|
139 | + } |
|
134 | 140 | } else { // sounds like a object-depended view call from controller or etc |
135 | 141 | // get stack trace of callbacks |
136 | 142 | $calledLog = @debug_backtrace(); |
@@ -138,13 +144,15 @@ discard block |
||
138 | 144 | |
139 | 145 | // lets try to find controller in backtrace |
140 | 146 | foreach ($calledLog as $caller) { |
141 | - if (isset($caller['class']) && Str::startsWith('Apps\Controller\\', $caller['class'])) |
|
142 | - $calledController = (string)$caller['class']; |
|
147 | + if (isset($caller['class']) && Str::startsWith('Apps\Controller\\', $caller['class'])) { |
|
148 | + $calledController = (string)$caller['class']; |
|
149 | + } |
|
143 | 150 | } |
144 | 151 | |
145 | 152 | // depended controller is not founded? Let finish |
146 | - if (!$calledController) |
|
147 | - throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: ' . $path); |
|
153 | + if (!$calledController) { |
|
154 | + throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: ' . $path); |
|
155 | + } |
|
148 | 156 | |
149 | 157 | // get controller name |
150 | 158 | $controllerName = Str::sub($calledController, Str::length('Apps\Controller\\' . env_name . '\\')); |
@@ -154,23 +162,26 @@ discard block |
||
154 | 162 | } |
155 | 163 | |
156 | 164 | // check if builded view full path is exist |
157 | - if (File::exist($tmpPath)) |
|
158 | - return $tmpPath; |
|
165 | + if (File::exist($tmpPath)) { |
|
166 | + return $tmpPath; |
|
167 | + } |
|
159 | 168 | |
160 | 169 | // hmm, not founded. Lets try to find in caller directory (for widgets, apps packages and other) |
161 | 170 | if ($source !== null) { |
162 | 171 | $tmpPath = Normalize::diskPath($source . DIRECTORY_SEPARATOR . $path . '.php'); |
163 | 172 | if (File::exist($tmpPath)) { |
164 | 173 | // add notify for native views |
165 | - if (App::$Debug) |
|
166 | - App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info'); |
|
174 | + if (App::$Debug) { |
|
175 | + App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info'); |
|
176 | + } |
|
167 | 177 | |
168 | 178 | return $tmpPath; |
169 | 179 | } |
170 | 180 | } |
171 | 181 | |
172 | - if (App::$Debug) |
|
173 | - App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning'); |
|
182 | + if (App::$Debug) { |
|
183 | + App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning'); |
|
184 | + } |
|
174 | 185 | |
175 | 186 | return null; |
176 | 187 | } |
@@ -193,8 +204,9 @@ discard block |
||
193 | 204 | */ |
194 | 205 | protected function renderSandbox($path, $params = null) |
195 | 206 | { |
196 | - if (!$path || !File::exist($path)) |
|
197 | - return null; |
|
207 | + if (!$path || !File::exist($path)) { |
|
208 | + return null; |
|
209 | + } |
|
198 | 210 | |
199 | 211 | // render defaults params as variables |
200 | 212 | if (Any::isArray($params) && count($params) > 0) { |
@@ -218,8 +230,9 @@ discard block |
||
218 | 230 | ob_end_clean(); |
219 | 231 | // prepare output message |
220 | 232 | $msg = $e->getMessage(); |
221 | - if (!Str::likeEmpty($msg)) |
|
222 | - $msg .= '. '; |
|
233 | + if (!Str::likeEmpty($msg)) { |
|
234 | + $msg .= '. '; |
|
235 | + } |
|
223 | 236 | |
224 | 237 | $msg .= __('Native exception catched in view: %path% in line %line%', ['path' => $path, 'line' => $e->getLine()]); |
225 | 238 | exit($e->display($msg)); |
@@ -255,8 +268,9 @@ discard block |
||
255 | 268 | { |
256 | 269 | $items = App::$Alias->getCustomLibraryArray($type); |
257 | 270 | // check if custom library available |
258 | - if (!$items || !Any::isArray($items) || count($items) < 1) |
|
259 | - return null; |
|
271 | + if (!$items || !Any::isArray($items) || count($items) < 1) { |
|
272 | + return null; |
|
273 | + } |
|
260 | 274 | |
261 | 275 | $output = []; |
262 | 276 | foreach ($items as $item) { |
@@ -290,8 +304,9 @@ discard block |
||
290 | 304 | */ |
291 | 305 | public function showPlainCode(?string $type = null): ?string |
292 | 306 | { |
293 | - if (!App::$Alias->getPlainCode($type) || !Any::isArray(App::$Alias->getPlainCode($type))) |
|
294 | - return null; |
|
307 | + if (!App::$Alias->getPlainCode($type) || !Any::isArray(App::$Alias->getPlainCode($type))) { |
|
308 | + return null; |
|
309 | + } |
|
295 | 310 | |
296 | 311 | $code = null; |
297 | 312 | foreach (App::$Alias->getPlainCode($type) as $row) { |
@@ -26,6 +26,6 @@ |
||
26 | 26 | $this->addCollector(new TimeDataCollector()); |
27 | 27 | $this->addCollector(new MemoryCollector()); |
28 | 28 | $this->addCollector(new ExceptionsCollector()); |
29 | - } catch (\Exception $e){} // mute |
|
29 | + } catch (\Exception $e) {} // mute |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |