Skip to content
This repository
Browse code

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...
commit c5be343b72b88d11824cdd85854c08901e4b2cc4 1 parent 15e6e9d
Mark Story authored
17  lib/Cake/I18n/I18n.php
@@ -97,6 +97,8 @@ class I18n {
97 97
 		'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
98 98
 	);
99 99
 
  100
+	protected $_escape = null;
  101
+
100 102
 /**
101 103
  * Constructor, use I18n::getInstance() to get the i18n translation object.
102 104
  *
@@ -560,7 +562,7 @@ public static function loadLocaleDefinition($filename) {
560 562
 			$replacements = array_map('crc32', $mustEscape);
561 563
 			$value = str_replace($mustEscape, $replacements, $value);
562 564
 			$value = explode(';', $value);
563  
-			$_this->__escape = $escape;
  565
+			$_this->_escape = $escape;
564 566
 			foreach ($value as $i => $val) {
565 567
 				$val = trim($val, '"');
566 568
 				$val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$_this, '_parseLiteralValue'), $val);
@@ -585,16 +587,16 @@ public static function loadLocaleDefinition($filename) {
585 587
  */
586 588
 	protected function _parseLiteralValue($string) {
587 589
 		$string = $string[1];
588  
-		if (substr($string, 0, 2) === $this->__escape . 'x') {
589  
-			$delimiter = $this->__escape . 'x';
  590
+		if (substr($string, 0, 2) === $this->_escape . 'x') {
  591
+			$delimiter = $this->_escape . 'x';
590 592
 			return join('', array_map('chr', array_map('hexdec',array_filter(explode($delimiter, $string)))));
591 593
 		}
592  
-		if (substr($string, 0, 2) === $this->__escape . 'd') {
593  
-			$delimiter = $this->__escape . 'd';
  594
+		if (substr($string, 0, 2) === $this->_escape . 'd') {
  595
+			$delimiter = $this->_escape . 'd';
594 596
 			return join('', array_map('chr', array_filter(explode($delimiter, $string))));
595 597
 		}
596  
-		if ($string[0] === $this->__escape && isset($string[1]) && is_numeric($string[1])) {
597  
-			$delimiter = $this->__escape;
  598
+		if ($string[0] === $this->_escape && isset($string[1]) && is_numeric($string[1])) {
  599
+			$delimiter = $this->_escape;
598 600
 			return join('', array_map('chr', array_filter(explode($delimiter, $string))));
599 601
 		}
600 602
 		if (substr($string, 0, 3) === 'U00') {
@@ -622,4 +624,5 @@ protected function _translateTime($format, $domain) {
622 624
 		}
623 625
 		return $format;
624 626
 	}
  627
+
625 628
 }
1  lib/Cake/I18n/L10n.php
@@ -469,4 +469,5 @@ public function catalog($language = null) {
469 469
 		}
470 470
 		return $this->_l10nCatalog;
471 471
 	}
  472
+
472 473
 }
21  lib/Cake/I18n/Multibyte.php
@@ -240,7 +240,7 @@ function mb_substr($string, $start, $length = null, $encoding = null) {
240 240
  * @return string A converted version of the string represented in ASCII.
241 241
  */
242 242
 if (!function_exists('mb_encode_mimeheader')) {
243  
-	function mb_encode_mimeheader($str, $charset = 'UTF-8', $transfer_encoding = 'B', $linefeed = "\r\n", $indent = 1) {
  243
+	function mb_encode_mimeheader($str, $charset = 'UTF-8', $transferEncoding = 'B', $linefeed = "\r\n", $indent = 1) {
244 244
 		return Multibyte::mimeEncode($str, $charset, $linefeed);
245 245
 	}
246 246
 }
@@ -504,7 +504,7 @@ public static function strrchr($haystack, $needle, $part = false) {
504 504
 			if (isset($needle[0]) && $needle[0] === $check[$position]) {
505 505
 				for ($i = 1; $i < $needleCount; $i++) {
506 506
 					if ($needle[$i] !== $check[$position + $i]) {
507  
-						if ($needle[$i] === $check[($position + $i) -1]) {
  507
+						if ($needle[$i] === $check[($position + $i) - 1]) {
508 508
 							$found = true;
509 509
 						}
510 510
 						unset($parts[$position - 1]);
@@ -566,7 +566,7 @@ public static function strrichr($haystack, $needle, $part = false) {
566 566
 			if (isset($needle[0]) && $needle[0] === $check[$position]) {
567 567
 				for ($i = 1; $i < $needleCount; $i++) {
568 568
 					if ($needle[$i] !== $check[$position + $i]) {
569  
-						if ($needle[$i] === $check[($position + $i) -1]) {
  569
+						if ($needle[$i] === $check[($position + $i) - 1]) {
570 570
 							$found = true;
571 571
 						}
572 572
 						unset($parts[$position - 1]);
@@ -624,7 +624,7 @@ public static function strripos($haystack, $needle, $offset = 0) {
624 624
 				if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
625 625
 					for ($i = 1; $i < $needleCount; $i++) {
626 626
 						if ($needle[$i] !== $haystack[$position + $i]) {
627  
-							if ($needle[$i] === $haystack[($position + $i) -1]) {
  627
+							if ($needle[$i] === $haystack[($position + $i) - 1]) {
628 628
 								$position--;
629 629
 								$found = true;
630 630
 								continue;
@@ -674,7 +674,7 @@ public static function strrpos($haystack, $needle, $offset = 0) {
674 674
 				if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
675 675
 					for ($i = 1; $i < $needleCount; $i++) {
676 676
 						if ($needle[$i] !== $haystack[$position + $i]) {
677  
-							if ($needle[$i] === $haystack[($position + $i) -1]) {
  677
+							if ($needle[$i] === $haystack[($position + $i) - 1]) {
678 678
 								$position--;
679 679
 								$found = true;
680 680
 								continue;
@@ -767,13 +767,13 @@ public static function strtolower($string) {
767 767
 		$length = count($utf8Map);
768 768
 		$lowerCase = array();
769 769
 
770  
-		for ($i = 0 ; $i < $length; $i++) {
  770
+		for ($i = 0; $i < $length; $i++) {
771 771
 			$char = $utf8Map[$i];
772 772
 
773 773
 			if ($char < 128) {
774 774
 				$str = strtolower(chr($char));
775 775
 				$strlen = strlen($str);
776  
-				for ($ii = 0 ; $ii < $strlen; $ii++) {
  776
+				for ($ii = 0; $ii < $strlen; $ii++) {
777 777
 					$lower = ord(substr($str, $ii, 1));
778 778
 				}
779 779
 				$lowerCase[] = $lower;
@@ -812,13 +812,13 @@ public static function strtoupper($string) {
812 812
 		$replaced = array();
813 813
 		$upperCase = array();
814 814
 
815  
-		for ($i = 0 ; $i < $length; $i++) {
  815
+		for ($i = 0; $i < $length; $i++) {
816 816
 			$char = $utf8Map[$i];
817 817
 
818 818
 			if ($char < 128) {
819 819
 				$str = strtoupper(chr($char));
820 820
 				$strlen = strlen($str);
821  
-				for ($ii = 0 ; $ii < $strlen; $ii++) {
  821
+				for ($ii = 0; $ii < $strlen; $ii++) {
822 822
 					$upper = ord(substr($str, $ii, 1));
823 823
 				}
824 824
 				$upperCase[] = $upper;
@@ -1007,7 +1007,7 @@ public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
1007 1007
  * @return string
1008 1008
  */
1009 1009
 	protected static function _codepoint($decimal) {
1010  
-		if ($decimal > 128 && $decimal < 256)  {
  1010
+		if ($decimal > 128 && $decimal < 256) {
1011 1011
 			$return = '0080_00ff'; // Latin-1 Supplement
1012 1012
 		} elseif ($decimal < 384) {
1013 1013
 			$return = '0100_017f'; // Latin Extended-A
@@ -1103,4 +1103,5 @@ public static function checkMultibyte($string) {
1103 1103
 		}
1104 1104
 		return false;
1105 1105
 	}
  1106
+
1106 1107
 }

0 notes on commit c5be343

Please sign in to comment.
Something went wrong with that request. Please try again.