@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * raised in {@link TApplication}. |
119 | 119 | * The method mainly uses appropriate template to display the error/exception. |
120 | 120 | * It terminates the application immediately after the error is displayed. |
121 | - * @param mixed $sender sender of the event |
|
121 | + * @param null|\Prado\TApplication $sender sender of the event |
|
122 | 122 | * @param mixed $param event parameter (if the event is raised by TApplication, it refers to the exception instance) |
123 | 123 | */ |
124 | 124 | public function handleError($sender, $param) |
@@ -244,6 +244,9 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | + /** |
|
248 | + * @return string |
|
249 | + */ |
|
247 | 250 | protected function hidePrivatePathParts($value) |
248 | 251 | { |
249 | 252 | static $aRpl; |
@@ -401,6 +404,9 @@ discard block |
||
401 | 404 | return $result; |
402 | 405 | } |
403 | 406 | |
407 | + /** |
|
408 | + * @return string |
|
409 | + */ |
|
404 | 410 | private function getExactTraceAsString($exception) |
405 | 411 | { |
406 | 412 | if ($exception instanceof TPhpFatalErrorException && |
@@ -427,6 +433,9 @@ discard block |
||
427 | 433 | return $this->hidePrivatePathParts($exception->getTraceAsString()); |
428 | 434 | } |
429 | 435 | |
436 | + /** |
|
437 | + * @param string $pattern |
|
438 | + */ |
|
430 | 439 | private function getPropertyAccessTrace($trace, $pattern) |
431 | 440 | { |
432 | 441 | $result = null; |
@@ -457,6 +466,9 @@ discard block |
||
457 | 466 | return $source; |
458 | 467 | } |
459 | 468 | |
469 | + /** |
|
470 | + * @param string $message |
|
471 | + */ |
|
460 | 472 | private function addLink($message) |
461 | 473 | { |
462 | 474 | if (null !== ($class = $this->getErrorClassNameSpace($message))) { |
@@ -247,7 +247,7 @@ |
||
247 | 247 | protected function hidePrivatePathParts($value) |
248 | 248 | { |
249 | 249 | static $aRpl; |
250 | - if($aRpl === null) |
|
250 | + if ($aRpl === null) |
|
251 | 251 | { |
252 | 252 | $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
253 | 253 | $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
@@ -117,7 +117,7 @@ |
||
117 | 117 | |
118 | 118 | /** |
119 | 119 | * @param string $token |
120 | - * @return string hash |
|
120 | + * @return integer hash |
|
121 | 121 | */ |
122 | 122 | private function generateTokenHash($token) |
123 | 123 | { |
@@ -109,7 +109,7 @@ |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * @return TControl|null control to be validated. Null if no control is found. |
|
112 | + * @return \Prado\Web\UI\TControl|null control to be validated. Null if no control is found. |
|
113 | 113 | */ |
114 | 114 | public function getValidationTarget() |
115 | 115 | { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | - * @param ITemplate $value the template for repeater items |
|
289 | + * @param \Prado\Web\UI\TTemplate $value the template for repeater items |
|
290 | 290 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
291 | 291 | */ |
292 | 292 | public function setItemTemplate($value) |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * This method invokes {@link createItem} to create a new repeater item. |
464 | 464 | * @param int $itemIndex zero-based item index. |
465 | 465 | * @param TListItemType $itemType item type |
466 | - * @return TControl the created item, null if item is not created |
|
466 | + * @return \Prado\TComponent|null the created item, null if item is not created |
|
467 | 467 | */ |
468 | 468 | private function createItemInternal($itemIndex, $itemType) |
469 | 469 | { |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @param int $itemIndex zero-based item index. |
484 | 484 | * @param TListItemType $itemType item type |
485 | 485 | * @param mixed $dataItem data to be associated with the item |
486 | - * @return TControl the created item, null if item is not created |
|
486 | + * @return \Prado\TComponent|null the created item, null if item is not created |
|
487 | 487 | */ |
488 | 488 | private function createItemWithDataInternal($itemIndex, $itemType, $dataItem) |
489 | 489 | { |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * Creates a repeater item instance based on the item type and index. |
507 | 507 | * @param int $itemIndex zero-based item index |
508 | 508 | * @param TListItemType $itemType item type |
509 | - * @return TControl created repeater item |
|
509 | + * @return null|\Prado\TComponent created repeater item |
|
510 | 510 | */ |
511 | 511 | protected function createItem($itemIndex, $itemType) |
512 | 512 | { |
@@ -78,15 +78,15 @@ |
||
78 | 78 | $data['file'] = $this->hidePrivatePathParts($exception->getFile()); |
79 | 79 | $data['line'] = $exception->getLine(); |
80 | 80 | $data['trace'] = $exception->getTrace(); |
81 | - foreach($data['trace'] as $k => $v) |
|
81 | + foreach ($data['trace'] as $k => $v) |
|
82 | 82 | { |
83 | - if(isset($v['file'])) |
|
83 | + if (isset($v['file'])) |
|
84 | 84 | $data['trace'][$k]['file'] = $this->hidePrivatePathParts($v['file']); |
85 | 85 | |
86 | - if(isset($v['args'])) |
|
86 | + if (isset($v['args'])) |
|
87 | 87 | { |
88 | 88 | $argsout = []; |
89 | - foreach($v['args'] as $kArg => $vArg) |
|
89 | + foreach ($v['args'] as $kArg => $vArg) |
|
90 | 90 | { |
91 | 91 | $data['trace'][$k]['args'][$kArg] = TVarDumper::dump($vArg, 0, false); |
92 | 92 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $first = $logs[0][3]; |
42 | 42 | $even = true; |
43 | 43 | |
44 | - $blocks = [ [ 'info', 'Tot Time', 'Time ', '[Level] [Category] [Message]' ] ]; |
|
44 | + $blocks = [['info', 'Tot Time', 'Time ', '[Level] [Category] [Message]']]; |
|
45 | 45 | for ($i = 0, $n = count($logs); $i < $n; ++$i) { |
46 | 46 | if ($i < $n - 1) { |
47 | 47 | $timing['delta'] = $logs[$i + 1][3] - $logs[$i][3]; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | console.log ("[Tot Time] [Time ] [Level] [Category] [Message]"); |
85 | 85 | |
86 | -EOD; |
|
86 | +eod; |
|
87 | 87 | |
88 | 88 | return $string; |
89 | 89 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | </script> |
124 | 124 | |
125 | -EOD; |
|
125 | +eod; |
|
126 | 126 | |
127 | 127 | return $string; |
128 | 128 | } |
@@ -566,8 +566,9 @@ discard block |
||
566 | 566 | return $obj; |
567 | 567 | } elseif($obj instanceof \ResourceBundle) { |
568 | 568 | $array = array(); |
569 | - foreach($obj as $k => $v) |
|
570 | - $array[$k] = $v; |
|
569 | + foreach($obj as $k => $v) { |
|
570 | + $array[$k] = $v; |
|
571 | + } |
|
571 | 572 | } else { |
572 | 573 | $array = $obj; |
573 | 574 | } |
@@ -603,8 +604,9 @@ discard block |
||
603 | 604 | if($arr === null) |
604 | 605 | { |
605 | 606 | $arr = $this->findInfo('Currencies', true, 'Currencies'); |
606 | - foreach($arr as $k => $v) |
|
607 | - $arr[$k] = $this->simplify($v); |
|
607 | + foreach($arr as $k => $v) { |
|
608 | + $arr[$k] = $this->simplify($v); |
|
609 | + } |
|
608 | 610 | } |
609 | 611 | return $arr; |
610 | 612 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Gets the CultureInfo that for this culture string |
213 | - * @param mixed $culture |
|
213 | + * @param string $culture |
|
214 | 214 | * @return CultureInfo invariant culture info is "en". |
215 | 215 | */ |
216 | 216 | public static function getInstance($culture) |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Load the ICU culture data for the specific culture identifier. |
254 | - * @param string $culture the culture identifier. |
|
254 | + * @param string $cultureName the culture identifier. |
|
255 | 255 | */ |
256 | 256 | protected function loadCultureData($cultureName) |
257 | 257 | { |
@@ -295,6 +295,7 @@ discard block |
||
295 | 295 | * currency for "en_AU", you need to use findInfo("Currencies,true);. |
296 | 296 | * @param string $path the data you want to find. |
297 | 297 | * @param bool $merge merge the data from its parents. |
298 | + * @param string $key |
|
298 | 299 | * @return mixed the specific ICU data. |
299 | 300 | */ |
300 | 301 | public function findInfo($path='/', $merge=false, $key = null) |
@@ -556,7 +557,6 @@ discard block |
||
556 | 557 | * Simplify a single element array into its own value. |
557 | 558 | * E.g. <code>array(0 => array('hello'), 1 => 'world');</code> |
558 | 559 | * becomes <code>array(0 => 'hello', 1 => 'world');</code> |
559 | - * @param array $array with single elements arrays |
|
560 | 560 | * @return array simplified array. |
561 | 561 | */ |
562 | 562 | protected function simplify($obj) |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | |
629 | 629 | /** |
630 | 630 | * Get a list of timezones in the language of the localized version. |
631 | - * @return array list of localized timezones. |
|
631 | + * @return string[] list of localized timezones. |
|
632 | 632 | */ |
633 | 633 | public function getTimeZones() |
634 | 634 | { |
@@ -253,24 +253,24 @@ discard block |
||
253 | 253 | $current_part = $culture_parts[0]; |
254 | 254 | |
255 | 255 | $culturesToLoad = [$current_part]; |
256 | - for($i = 1, $k = count($culture_parts); $i < $k; ++$i) |
|
256 | + for ($i = 1, $k = count($culture_parts); $i < $k; ++$i) |
|
257 | 257 | { |
258 | - $current_part .= '_'.$culture_parts[$i]; |
|
258 | + $current_part .= '_' . $culture_parts[$i]; |
|
259 | 259 | $culturesToLoad[] = $current_part; |
260 | 260 | } |
261 | 261 | |
262 | - foreach(self::$bundleNames as $key => $bundleName) |
|
262 | + foreach (self::$bundleNames as $key => $bundleName) |
|
263 | 263 | { |
264 | - if(!array_key_exists($key, $this->data)) |
|
264 | + if (!array_key_exists($key, $this->data)) |
|
265 | 265 | $this->data[$key] = []; |
266 | 266 | } |
267 | - foreach($culturesToLoad as $culture) |
|
267 | + foreach ($culturesToLoad as $culture) |
|
268 | 268 | { |
269 | - if(in_array($culture, $this->resourceBundles)) |
|
269 | + if (in_array($culture, $this->resourceBundles)) |
|
270 | 270 | continue; |
271 | 271 | |
272 | 272 | array_unshift($this->resourceBundles, $culture); |
273 | - foreach(self::$bundleNames as $key => $bundleName) |
|
273 | + foreach (self::$bundleNames as $key => $bundleName) |
|
274 | 274 | { |
275 | 275 | $this->data[$key][$culture] = \ResourceBundle::create($culture, $bundleName, false); |
276 | 276 | } |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | * @param bool $merge merge the data from its parents. |
292 | 292 | * @return mixed the specific ICU data. |
293 | 293 | */ |
294 | - public function findInfo($path='/', $merge=false, $key = null) |
|
294 | + public function findInfo($path = '/', $merge = false, $key = null) |
|
295 | 295 | { |
296 | 296 | $result = []; |
297 | 297 | |
298 | - if($key === null) |
|
298 | + if ($key === null) |
|
299 | 299 | { |
300 | 300 | // try to guess the bundle from the path. Always defaults to "Core". |
301 | 301 | $key = 'Core'; |
302 | - foreach(self::$bundleNames as $bundleName => $icuBundleName) |
|
302 | + foreach (self::$bundleNames as $bundleName => $icuBundleName) |
|
303 | 303 | { |
304 | - if(strpos($path, $bundleName) === 0) |
|
304 | + if (strpos($path, $bundleName) === 0) |
|
305 | 305 | { |
306 | 306 | $key = $bundleName; |
307 | 307 | break; |
@@ -309,17 +309,17 @@ discard block |
||
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - if(!array_key_exists($key, $this->data)) |
|
312 | + if (!array_key_exists($key, $this->data)) |
|
313 | 313 | return $result; |
314 | - foreach($this->resourceBundles as $culture) |
|
314 | + foreach ($this->resourceBundles as $culture) |
|
315 | 315 | { |
316 | 316 | $res = $this->data[$key][$culture]; |
317 | - if($res === null) |
|
317 | + if ($res === null) |
|
318 | 318 | continue; |
319 | 319 | $info = $this->searchResources($res, $path); |
320 | - if($info) |
|
320 | + if ($info) |
|
321 | 321 | { |
322 | - if($merge) |
|
322 | + if ($merge) |
|
323 | 323 | $result = array_merge($result, $info); |
324 | 324 | else |
325 | 325 | return $info; |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | * @param string $path slash "/" separated array path. |
338 | 338 | * @return mixed the value array using the path |
339 | 339 | */ |
340 | - private function searchResources($info, $path='/') |
|
340 | + private function searchResources($info, $path = '/') |
|
341 | 341 | { |
342 | 342 | $index = explode('/', $path); |
343 | 343 | |
344 | 344 | $resource = $info; |
345 | - for($i = 0, $k = count($index); $i < $k; ++$i) |
|
345 | + for ($i = 0, $k = count($index); $i < $k; ++$i) |
|
346 | 346 | { |
347 | 347 | |
348 | 348 | $resource = $resource->get($index[$i], false); |
349 | - if($resource === null) |
|
349 | + if ($resource === null) |
|
350 | 350 | return null; |
351 | 351 | } |
352 | 352 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function getDateTimeFormat() |
372 | 372 | { |
373 | - if($this->dateTimeFormat === null) |
|
373 | + if ($this->dateTimeFormat === null) |
|
374 | 374 | { |
375 | 375 | $this->setDateTimeFormat(new DateTimeFormatInfo($this)); |
376 | 376 | } |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | $reg = substr($this->culture, 3, 2); |
409 | 409 | $language = $this->findInfo("Languages/{$lang}"); |
410 | 410 | $region = $this->findInfo("Countries/{$reg}"); |
411 | - if($region) |
|
412 | - return $language.' ('.$region.')'; |
|
411 | + if ($region) |
|
412 | + return $language . ' (' . $region . ')'; |
|
413 | 413 | else |
414 | 414 | return $language; |
415 | 415 | } |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | } |
433 | 433 | |
434 | 434 | $region = $culture->findInfo("Countries/{$reg}"); |
435 | - if($region) |
|
436 | - return $language.' ('.$region.')'; |
|
435 | + if ($region) |
|
436 | + return $language . ' (' . $region . ')'; |
|
437 | 437 | else |
438 | 438 | return $language; |
439 | 439 | } |
@@ -489,25 +489,25 @@ discard block |
||
489 | 489 | * or CultureInfo::SPECIFIC. |
490 | 490 | * @return array list of culture information available. |
491 | 491 | */ |
492 | - public static function getCultures($type=CultureInfo::ALL) |
|
492 | + public static function getCultures($type = CultureInfo::ALL) |
|
493 | 493 | { |
494 | 494 | $all = \ResourceBundle::getLocales(''); |
495 | 495 | |
496 | - switch($type) |
|
496 | + switch ($type) |
|
497 | 497 | { |
498 | 498 | case CultureInfo::ALL : |
499 | 499 | return $all; |
500 | 500 | case CultureInfo::NEUTRAL : |
501 | - foreach($all as $key => $culture) |
|
501 | + foreach ($all as $key => $culture) |
|
502 | 502 | { |
503 | - if(strlen($culture) != 2) |
|
503 | + if (strlen($culture) != 2) |
|
504 | 504 | unset($all[$key]); |
505 | 505 | } |
506 | 506 | return $all; |
507 | 507 | case CultureInfo::SPECIFIC : |
508 | - foreach($all as $key => $culture) |
|
508 | + foreach ($all as $key => $culture) |
|
509 | 509 | { |
510 | - if(strlen($culture) == 2) |
|
510 | + if (strlen($culture) == 2) |
|
511 | 511 | unset($all[$key]); |
512 | 512 | } |
513 | 513 | return $all; |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | */ |
524 | 524 | protected function simplify($obj) |
525 | 525 | { |
526 | - if(is_scalar($obj)) { |
|
526 | + if (is_scalar($obj)) { |
|
527 | 527 | return $obj; |
528 | - } elseif($obj instanceof \ResourceBundle) { |
|
528 | + } elseif ($obj instanceof \ResourceBundle) { |
|
529 | 529 | $array = array(); |
530 | - foreach($obj as $k => $v) |
|
530 | + foreach ($obj as $k => $v) |
|
531 | 531 | $array[$k] = $v; |
532 | 532 | } else { |
533 | 533 | $array = $obj; |
534 | 534 | } |
535 | 535 | |
536 | - for($i = 0, $k = count($array); $i<$k; ++$i) |
|
536 | + for ($i = 0, $k = count($array); $i < $k; ++$i) |
|
537 | 537 | { |
538 | 538 | $key = key($array); |
539 | 539 | if (is_array($array[$key]) |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | public function getCurrencies() |
562 | 562 | { |
563 | 563 | static $arr; |
564 | - if($arr === null) |
|
564 | + if ($arr === null) |
|
565 | 565 | { |
566 | 566 | $arr = $this->findInfo('Currencies', true, 'Currencies'); |
567 | - foreach($arr as $k => $v) |
|
567 | + foreach ($arr as $k => $v) |
|
568 | 568 | $arr[$k] = $this->simplify($v); |
569 | 569 | } |
570 | 570 | return $arr; |
@@ -595,15 +595,15 @@ discard block |
||
595 | 595 | public function getTimeZones() |
596 | 596 | { |
597 | 597 | static $arr; |
598 | - if($arr === null) |
|
598 | + if ($arr === null) |
|
599 | 599 | { |
600 | 600 | $validPrefixes = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific'); |
601 | 601 | $tmp = $this->findInfo('zoneStrings', true, 'zoneStrings'); |
602 | - foreach($tmp as $k => $v) |
|
602 | + foreach ($tmp as $k => $v) |
|
603 | 603 | { |
604 | - foreach($validPrefixes as $prefix) |
|
604 | + foreach ($validPrefixes as $prefix) |
|
605 | 605 | { |
606 | - if(strpos($k, $prefix) === 0) |
|
606 | + if (strpos($k, $prefix) === 0) |
|
607 | 607 | { |
608 | 608 | $arr[] = str_replace(':', '/', $k); |
609 | 609 | break; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Returns the DateTimeFormatInfo associated with the specified culture. |
160 | - * @param null|CultureInfo|string $culture the culture that gets the DateTimeFormat property. |
|
160 | + * @param string $culture the culture that gets the DateTimeFormat property. |
|
161 | 161 | * @return DateTimeFormatInfo DateTimeFormatInfo for the specified |
162 | 162 | * culture. |
163 | 163 | */ |
@@ -174,6 +174,9 @@ discard block |
||
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | + /** |
|
178 | + * @param string $path |
|
179 | + */ |
|
177 | 180 | public function getInfoByPath($path) |
178 | 181 | { |
179 | 182 | static $basePath = null; |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function getFormatter($culture, $type) |
200 | 200 | { |
201 | - if(!isset(self::$formatters[$culture])) |
|
201 | + if (!isset(self::$formatters[$culture])) |
|
202 | 202 | self::$formatters[$culture] = []; |
203 | - if(!isset(self::$formatters[$culture][$type])) |
|
203 | + if (!isset(self::$formatters[$culture][$type])) |
|
204 | 204 | self::$formatters[$culture][$type] = new \NumberFormatter($culture, $type); |
205 | 205 | |
206 | 206 | return self::$formatters[$culture][$type]; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $type = $this->getType(); |
225 | 225 | $pattern = $this->getPattern(); |
226 | 226 | |
227 | - if(empty($pattern)) |
|
227 | + if (empty($pattern)) |
|
228 | 228 | { |
229 | 229 | $formatter = $this->getFormatter($culture, $type); |
230 | 230 | } else { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $formatter->setPattern($pattern); |
233 | 233 | } |
234 | 234 | |
235 | - if($type === \NumberFormatter::CURRENCY) |
|
235 | + if ($type === \NumberFormatter::CURRENCY) |
|
236 | 236 | { |
237 | 237 | $result = $formatter->formatCurrency($this->getValue(), $this->getCurrency()); |
238 | 238 | } else { |