Skip to content
Permalink
Browse files

Fix most of the coding standards issues in I18n/

There are a number of whitespace related issues in Multibyte, and
variable name related ones in I18n that cannot be easily changed.
  • Loading branch information...
markstory committed Mar 4, 2012
1 parent 15e6e9d commit c5be343b72b88d11824cdd85854c08901e4b2cc4
Showing with 22 additions and 17 deletions.
  1. +10 −7 lib/Cake/I18n/I18n.php
  2. +1 −0 lib/Cake/I18n/L10n.php
  3. +11 −10 lib/Cake/I18n/Multibyte.php
@@ -97,6 +97,8 @@ class I18n {
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
);
protected $_escape = null;
/**
* Constructor, use I18n::getInstance() to get the i18n translation object.
*
@@ -560,7 +562,7 @@ public static function loadLocaleDefinition($filename) {
$replacements = array_map('crc32', $mustEscape);
$value = str_replace($mustEscape, $replacements, $value);
$value = explode(';', $value);
$_this->__escape = $escape;
$_this->_escape = $escape;
foreach ($value as $i => $val) {
$val = trim($val, '"');
$val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$_this, '_parseLiteralValue'), $val);
@@ -585,16 +587,16 @@ public static function loadLocaleDefinition($filename) {
*/
protected function _parseLiteralValue($string) {
$string = $string[1];
if (substr($string, 0, 2) === $this->__escape . 'x') {
$delimiter = $this->__escape . 'x';
if (substr($string, 0, 2) === $this->_escape . 'x') {
$delimiter = $this->_escape . 'x';
return join('', array_map('chr', array_map('hexdec',array_filter(explode($delimiter, $string)))));
}
if (substr($string, 0, 2) === $this->__escape . 'd') {
$delimiter = $this->__escape . 'd';
if (substr($string, 0, 2) === $this->_escape . 'd') {
$delimiter = $this->_escape . 'd';
return join('', array_map('chr', array_filter(explode($delimiter, $string))));
}
if ($string[0] === $this->__escape && isset($string[1]) && is_numeric($string[1])) {
$delimiter = $this->__escape;
if ($string[0] === $this->_escape && isset($string[1]) && is_numeric($string[1])) {
$delimiter = $this->_escape;
return join('', array_map('chr', array_filter(explode($delimiter, $string))));
}
if (substr($string, 0, 3) === 'U00') {
@@ -622,4 +624,5 @@ protected function _translateTime($format, $domain) {
}
return $format;
}
}
@@ -469,4 +469,5 @@ public function catalog($language = null) {
}
return $this->_l10nCatalog;
}
}
@@ -240,7 +240,7 @@ function mb_substr($string, $start, $length = null, $encoding = null) {
* @return string A converted version of the string represented in ASCII.
*/
if (!function_exists('mb_encode_mimeheader')) {
function mb_encode_mimeheader($str, $charset = 'UTF-8', $transfer_encoding = 'B', $linefeed = "\r\n", $indent = 1) {
function mb_encode_mimeheader($str, $charset = 'UTF-8', $transferEncoding = 'B', $linefeed = "\r\n", $indent = 1) {
return Multibyte::mimeEncode($str, $charset, $linefeed);
}
}
@@ -504,7 +504,7 @@ public static function strrchr($haystack, $needle, $part = false) {
if (isset($needle[0]) && $needle[0] === $check[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $check[$position + $i]) {
if ($needle[$i] === $check[($position + $i) -1]) {
if ($needle[$i] === $check[($position + $i) - 1]) {
$found = true;
}
unset($parts[$position - 1]);
@@ -566,7 +566,7 @@ public static function strrichr($haystack, $needle, $part = false) {
if (isset($needle[0]) && $needle[0] === $check[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $check[$position + $i]) {
if ($needle[$i] === $check[($position + $i) -1]) {
if ($needle[$i] === $check[($position + $i) - 1]) {
$found = true;
}
unset($parts[$position - 1]);
@@ -624,7 +624,7 @@ public static function strripos($haystack, $needle, $offset = 0) {
if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $haystack[$position + $i]) {
if ($needle[$i] === $haystack[($position + $i) -1]) {
if ($needle[$i] === $haystack[($position + $i) - 1]) {
$position--;
$found = true;
continue;
@@ -674,7 +674,7 @@ public static function strrpos($haystack, $needle, $offset = 0) {
if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $haystack[$position + $i]) {
if ($needle[$i] === $haystack[($position + $i) -1]) {
if ($needle[$i] === $haystack[($position + $i) - 1]) {
$position--;
$found = true;
continue;
@@ -767,13 +767,13 @@ public static function strtolower($string) {
$length = count($utf8Map);
$lowerCase = array();
for ($i = 0 ; $i < $length; $i++) {
for ($i = 0; $i < $length; $i++) {
$char = $utf8Map[$i];
if ($char < 128) {
$str = strtolower(chr($char));
$strlen = strlen($str);
for ($ii = 0 ; $ii < $strlen; $ii++) {
for ($ii = 0; $ii < $strlen; $ii++) {
$lower = ord(substr($str, $ii, 1));
}
$lowerCase[] = $lower;
@@ -812,13 +812,13 @@ public static function strtoupper($string) {
$replaced = array();
$upperCase = array();
for ($i = 0 ; $i < $length; $i++) {
for ($i = 0; $i < $length; $i++) {
$char = $utf8Map[$i];
if ($char < 128) {
$str = strtoupper(chr($char));
$strlen = strlen($str);
for ($ii = 0 ; $ii < $strlen; $ii++) {
for ($ii = 0; $ii < $strlen; $ii++) {
$upper = ord(substr($str, $ii, 1));
}
$upperCase[] = $upper;
@@ -1007,7 +1007,7 @@ public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
* @return string
*/
protected static function _codepoint($decimal) {
if ($decimal > 128 && $decimal < 256) {
if ($decimal > 128 && $decimal < 256) {
$return = '0080_00ff'; // Latin-1 Supplement
} elseif ($decimal < 384) {
$return = '0100_017f'; // Latin Extended-A
@@ -1103,4 +1103,5 @@ public static function checkMultibyte($string) {
}
return false;
}
}

0 comments on commit c5be343

Please sign in to comment.
You can’t perform that action at this time.