@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | 218 | * Load the ICU culture data for the specific culture identifier. |
| 219 | - * @param string $culture the culture identifier. |
|
| 219 | + * @param string $cultureName the culture identifier. |
|
| 220 | 220 | */ |
| 221 | 221 | protected function loadCultureData($cultureName) |
| 222 | 222 | { |
@@ -468,7 +468,6 @@ discard block |
||
| 468 | 468 | * Simplify a single element array into its own value. |
| 469 | 469 | * E.g. <code>array(0 => array('hello'), 1 => 'world');</code> |
| 470 | 470 | * becomes <code>array(0 => 'hello', 1 => 'world');</code> |
| 471 | - * @param array $array with single elements arrays |
|
| 472 | 471 | * @return array simplified array. |
| 473 | 472 | */ |
| 474 | 473 | protected function simplify($obj) |
@@ -541,7 +540,7 @@ discard block |
||
| 541 | 540 | |
| 542 | 541 | /** |
| 543 | 542 | * Get a list of timezones in the language of the localized version. |
| 544 | - * @return array list of localized timezones. |
|
| 543 | + * @return string[] list of localized timezones. |
|
| 545 | 544 | */ |
| 546 | 545 | public function getTimeZones() |
| 547 | 546 | { |
@@ -224,24 +224,24 @@ discard block |
||
| 224 | 224 | $current_part = $culture_parts[0]; |
| 225 | 225 | |
| 226 | 226 | $culturesToLoad = [$current_part]; |
| 227 | - for($i = 1, $k = count($culture_parts); $i < $k; ++$i) |
|
| 227 | + for ($i = 1, $k = count($culture_parts); $i < $k; ++$i) |
|
| 228 | 228 | { |
| 229 | - $current_part .= '_'.$culture_parts[$i]; |
|
| 229 | + $current_part .= '_' . $culture_parts[$i]; |
|
| 230 | 230 | $culturesToLoad[] = $current_part; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - foreach(self::$bundleNames as $key => $bundleName) |
|
| 233 | + foreach (self::$bundleNames as $key => $bundleName) |
|
| 234 | 234 | { |
| 235 | - if(!array_key_exists($key, $this->data)) |
|
| 235 | + if (!array_key_exists($key, $this->data)) |
|
| 236 | 236 | $this->data[$key] = []; |
| 237 | 237 | } |
| 238 | - foreach($culturesToLoad as $culture) |
|
| 238 | + foreach ($culturesToLoad as $culture) |
|
| 239 | 239 | { |
| 240 | - if(in_array($culture, $this->resourceBundles)) |
|
| 240 | + if (in_array($culture, $this->resourceBundles)) |
|
| 241 | 241 | continue; |
| 242 | 242 | |
| 243 | 243 | array_unshift($this->resourceBundles, $culture); |
| 244 | - foreach(self::$bundleNames as $key => $bundleName) |
|
| 244 | + foreach (self::$bundleNames as $key => $bundleName) |
|
| 245 | 245 | { |
| 246 | 246 | $this->data[$key][$culture] = \ResourceBundle::create($culture, $bundleName, false); |
| 247 | 247 | } |
@@ -263,17 +263,17 @@ discard block |
||
| 263 | 263 | * @param string $key bundle name. |
| 264 | 264 | * @return mixed the specific ICU data. |
| 265 | 265 | */ |
| 266 | - public function findInfo($path='/', $merge=false, $key = null) |
|
| 266 | + public function findInfo($path = '/', $merge = false, $key = null) |
|
| 267 | 267 | { |
| 268 | 268 | $result = []; |
| 269 | 269 | |
| 270 | - if($key === null) |
|
| 270 | + if ($key === null) |
|
| 271 | 271 | { |
| 272 | 272 | // try to guess the bundle from the path. Always defaults to "Core". |
| 273 | 273 | $key = 'Core'; |
| 274 | - foreach(self::$bundleNames as $bundleName => $icuBundleName) |
|
| 274 | + foreach (self::$bundleNames as $bundleName => $icuBundleName) |
|
| 275 | 275 | { |
| 276 | - if(strpos($path, $bundleName) === 0) |
|
| 276 | + if (strpos($path, $bundleName) === 0) |
|
| 277 | 277 | { |
| 278 | 278 | $key = $bundleName; |
| 279 | 279 | break; |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if(!array_key_exists($key, $this->data)) |
|
| 284 | + if (!array_key_exists($key, $this->data)) |
|
| 285 | 285 | return $result; |
| 286 | - foreach($this->resourceBundles as $culture) |
|
| 286 | + foreach ($this->resourceBundles as $culture) |
|
| 287 | 287 | { |
| 288 | 288 | $res = $this->data[$key][$culture]; |
| 289 | - if($res === null) |
|
| 289 | + if ($res === null) |
|
| 290 | 290 | continue; |
| 291 | 291 | $info = $this->searchResources($res, $path); |
| 292 | - if($info) |
|
| 292 | + if ($info) |
|
| 293 | 293 | { |
| 294 | - if($merge) |
|
| 294 | + if ($merge) |
|
| 295 | 295 | $result = array_merge($result, $info); |
| 296 | 296 | else |
| 297 | 297 | return $info; |
@@ -309,18 +309,18 @@ discard block |
||
| 309 | 309 | * @param string $path slash "/" separated array path. |
| 310 | 310 | * @return mixed the value array using the path |
| 311 | 311 | */ |
| 312 | - private function searchResources($info, $path='/') |
|
| 312 | + private function searchResources($info, $path = '/') |
|
| 313 | 313 | { |
| 314 | 314 | $index = explode('/', $path); |
| 315 | 315 | |
| 316 | 316 | $resource = $info; |
| 317 | - for($i = 0, $k = count($index); $i < $k; ++$i) |
|
| 317 | + for ($i = 0, $k = count($index); $i < $k; ++$i) |
|
| 318 | 318 | { |
| 319 | - if($resource === null) |
|
| 319 | + if ($resource === null) |
|
| 320 | 320 | return null; |
| 321 | - elseif(is_string($resource)) |
|
| 321 | + elseif (is_string($resource)) |
|
| 322 | 322 | return [$resource]; |
| 323 | - elseif(is_object($resource)) |
|
| 323 | + elseif (is_object($resource)) |
|
| 324 | 324 | $resource = $resource->get($index[$i], false); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -358,8 +358,8 @@ discard block |
||
| 358 | 358 | $reg = substr($this->culture, 3, 2); |
| 359 | 359 | $language = $this->findInfo("Languages/{$lang}"); |
| 360 | 360 | $region = $this->findInfo("Countries/{$reg}"); |
| 361 | - if($region) |
|
| 362 | - return $language.' ('.$region.')'; |
|
| 361 | + if ($region) |
|
| 362 | + return $language . ' (' . $region . ')'; |
|
| 363 | 363 | else |
| 364 | 364 | return $language; |
| 365 | 365 | } |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | $region = $culture->findInfo("Countries/{$reg}"); |
| 385 | - if($region) |
|
| 386 | - return $language.' ('.$region.')'; |
|
| 385 | + if ($region) |
|
| 386 | + return $language . ' (' . $region . ')'; |
|
| 387 | 387 | else |
| 388 | 388 | return $language; |
| 389 | 389 | } |
@@ -439,25 +439,25 @@ discard block |
||
| 439 | 439 | * or CultureInfo::SPECIFIC. |
| 440 | 440 | * @return array list of culture information available. |
| 441 | 441 | */ |
| 442 | - public static function getCultures($type=CultureInfo::ALL) |
|
| 442 | + public static function getCultures($type = CultureInfo::ALL) |
|
| 443 | 443 | { |
| 444 | 444 | $all = \ResourceBundle::getLocales(''); |
| 445 | 445 | |
| 446 | - switch($type) |
|
| 446 | + switch ($type) |
|
| 447 | 447 | { |
| 448 | 448 | case CultureInfo::ALL : |
| 449 | 449 | return $all; |
| 450 | 450 | case CultureInfo::NEUTRAL : |
| 451 | - foreach($all as $key => $culture) |
|
| 451 | + foreach ($all as $key => $culture) |
|
| 452 | 452 | { |
| 453 | - if(strlen($culture) != 2) |
|
| 453 | + if (strlen($culture) != 2) |
|
| 454 | 454 | unset($all[$key]); |
| 455 | 455 | } |
| 456 | 456 | return $all; |
| 457 | 457 | case CultureInfo::SPECIFIC : |
| 458 | - foreach($all as $key => $culture) |
|
| 458 | + foreach ($all as $key => $culture) |
|
| 459 | 459 | { |
| 460 | - if(strlen($culture) == 2) |
|
| 460 | + if (strlen($culture) == 2) |
|
| 461 | 461 | unset($all[$key]); |
| 462 | 462 | } |
| 463 | 463 | return $all; |
@@ -473,17 +473,17 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | protected function simplify($obj) |
| 475 | 475 | { |
| 476 | - if(is_scalar($obj)) { |
|
| 476 | + if (is_scalar($obj)) { |
|
| 477 | 477 | return $obj; |
| 478 | - } elseif($obj instanceof \ResourceBundle) { |
|
| 478 | + } elseif ($obj instanceof \ResourceBundle) { |
|
| 479 | 479 | $array = array(); |
| 480 | - foreach($obj as $k => $v) |
|
| 480 | + foreach ($obj as $k => $v) |
|
| 481 | 481 | $array[$k] = $v; |
| 482 | 482 | } else { |
| 483 | 483 | $array = $obj; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - for($i = 0, $k = count($array); $i<$k; ++$i) |
|
| 486 | + for ($i = 0, $k = count($array); $i < $k; ++$i) |
|
| 487 | 487 | { |
| 488 | 488 | $key = key($array); |
| 489 | 489 | if ($key !== null |
@@ -512,10 +512,10 @@ discard block |
||
| 512 | 512 | public function getCurrencies() |
| 513 | 513 | { |
| 514 | 514 | static $arr; |
| 515 | - if($arr === null) |
|
| 515 | + if ($arr === null) |
|
| 516 | 516 | { |
| 517 | 517 | $arr = $this->findInfo('Currencies', false, 'Currencies'); |
| 518 | - foreach($arr as $k => $v) |
|
| 518 | + foreach ($arr as $k => $v) |
|
| 519 | 519 | $arr[$k] = $this->simplify($v); |
| 520 | 520 | } |
| 521 | 521 | return $arr; |
@@ -546,15 +546,15 @@ discard block |
||
| 546 | 546 | public function getTimeZones() |
| 547 | 547 | { |
| 548 | 548 | static $arr; |
| 549 | - if($arr === null) |
|
| 549 | + if ($arr === null) |
|
| 550 | 550 | { |
| 551 | 551 | $validPrefixes = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific'); |
| 552 | 552 | $tmp = $this->findInfo('zoneStrings', false, 'zoneStrings'); |
| 553 | - foreach($tmp as $k => $v) |
|
| 553 | + foreach ($tmp as $k => $v) |
|
| 554 | 554 | { |
| 555 | - foreach($validPrefixes as $prefix) |
|
| 555 | + foreach ($validPrefixes as $prefix) |
|
| 556 | 556 | { |
| 557 | - if(strpos($k, $prefix) === 0) |
|
| 557 | + if (strpos($k, $prefix) === 0) |
|
| 558 | 558 | { |
| 559 | 559 | $arr[] = str_replace(':', '/', $k); |
| 560 | 560 | break; |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * Loads date from drop down list data. |
| 484 | 484 | * @param string $key the key that can be used to retrieve data from the input data collection |
| 485 | 485 | * @param array $values the input data collection |
| 486 | - * @return array the date selected |
|
| 486 | + * @return string the date selected |
|
| 487 | 487 | */ |
| 488 | 488 | protected function getDateFromPostData($key, $values) |
| 489 | 489 | { |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
| 598 | - * @return DateTimeFormatInfo date time format information for the current culture. |
|
| 598 | + * @return CultureInfo date time format information for the current culture. |
|
| 599 | 599 | */ |
| 600 | 600 | protected function getLocalizedCalendarInfo() |
| 601 | 601 | { |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | /** |
| 648 | 648 | * Renders the calendar drop down list depending on the DateFormat pattern. |
| 649 | 649 | * @param THtmlWriter $writer the Html writer to render the drop down lists. |
| 650 | - * @param array $date the current selected date |
|
| 650 | + * @param \DateTime $date the current selected date |
|
| 651 | 651 | */ |
| 652 | 652 | protected function renderCalendarSelections($writer, $date) |
| 653 | 653 | { |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | * Returns the localized month names that depends on the month format pattern. |
| 756 | 756 | * "MMMM" will return the month names, "MM" or "MMM" return abbr. month names |
| 757 | 757 | * and "M" return month digits. |
| 758 | - * @param DateTimeFormatInfo $info localized date format information. |
|
| 758 | + * @param CultureInfo $info localized date format information. |
|
| 759 | 759 | * @return array localized month names. |
| 760 | 760 | */ |
| 761 | 761 | protected function getLocalizedMonthNames($info) |