Browse Source

Fixing docblocks and some CS errors

Jose Lorenzo Rodriguez 11 years ago
parent
commit
73381b5df5

+ 1 - 0
src/I18n/ChainMessagesLoader.php

@@ -45,6 +45,7 @@ class ChainMessagesLoader {
  * the chain.
  *
  * @return \Aura\Intl\Package
+ * @throws \RuntimeException if any of the loaders in the chain is not a valid callable
  */
 	public function __invoke() {
 		foreach ($this->_loaders as $k => $loader) {

+ 2 - 0
src/I18n/Formatter/IcuFormatter.php

@@ -34,6 +34,7 @@ class IcuFormatter implements FormatterInterface {
  *
  * @param string $locale The locale in which the message is presented.
  * @param string|array $message The message to be translated
+ * @param array $vars The list of values to interpolate in the message
  * @return string The formatted message
  */
 	public function format($locale, $message, array $vars) {
@@ -73,6 +74,7 @@ class IcuFormatter implements FormatterInterface {
  *
  * @param string $locale The locale in which the message is presented.
  * @param string|array $message The message to be translated
+ * @param array $vars The list of values to interpolate in the message
  * @return string The formatted message
  * @throws Aura\Intl\Exception\CannotInstantiateFormatter if any error occurred
  * while parsing the message

+ 1 - 0
src/I18n/Formatter/SprintfFormatter.php

@@ -33,6 +33,7 @@ class SprintfFormatter implements FormatterInterface {
  *
  * @param string $locale The locale in which the message is presented.
  * @param string|array $message The message to be translated
+ * @param array $vars The list of values to interpolate in the message
  * @return string The formatted message
  */
 	public function format($locale, $message, array $vars) {

+ 1 - 1
src/I18n/I18n.php

@@ -176,7 +176,7 @@ class I18n {
  *	});
  * }}}
  *
- * @param string $locale The name of the translator to create a loader for
+ * @param string $name The name of the translator to create a loader for
  * @param callable $loader A callable object that should return a Package
  * instance to be used for assembling a new translator.
  * @return void

+ 5 - 6
src/I18n/Parser/MoFileParser.php

@@ -49,10 +49,10 @@ class MoFileParser {
  * Parses machine object (MO) format, independent of the machine's endian it
  * was created on. Both 32bit and 64bit systems are supported.
  *
- * @param resource $resource
+ * @param resource $resource The file to be parsed.
  *
- * @return array
- * @throws RuntimeException If stream content has an invalid format.
+ * @return array List of messages extrated from the file
+ * @throws \RuntimeException If stream content has an invalid format.
  */
 	public function parse($resource) {
 		$stream = fopen($resource, 'r');
@@ -107,7 +107,6 @@ class MoFileParser {
 			fseek($stream, $offsetTranslated + $i * 8);
 			$length = $this->_readLong($stream, $isBigEndian);
 			$offset = $this->_readLong($stream, $isBigEndian);
-		
 			fseek($stream, $offset);
 			$translated = fread($stream, $length);
 
@@ -130,8 +129,8 @@ class MoFileParser {
 /**
  * Reads an unsigned long from stream respecting endianess.
  *
- * @param resource $stream
- * @param boolean $isBigEndian
+ * @param resource $stream The File being read.
+ * @param boolean $isBigEndian Whether or not the current platfomr is Big Endian
  * @return int
  */
 	protected function _readLong($stream, $isBigEndian) {

+ 4 - 4
src/I18n/Parser/PoFileParser.php

@@ -21,7 +21,7 @@ namespace Cake\I18n\Parser;
  * @copyright Copyright (c) 2012, Clemens Tolboom
  * @copyright Copyright (c) 2014, Fabien Potencier https://github.com/symfony/Translation/blob/master/LICENSE
  */
-class PoFileParser  {
+class PoFileParser {
 
 /**
  * Parses portable object (PO) format.
@@ -64,7 +64,7 @@ class PoFileParser  {
  *
  * Items with an empty id are ignored.
  *
- * @param string $resource
+ * @param string $resource The file name to parse
  *
  * @return array
  */
@@ -120,8 +120,8 @@ class PoFileParser  {
 /**
  * Saves a translation item to the messages.
  *
- * @param array $messages
- * @param array $item
+ * @param array &$messages The messages array being collected from the file
+ * @param array $item The current item being inspected
  * @return void
  */
 	protected function _addMessage(array &$messages, array $item) {

+ 3 - 3
src/I18n/PluralRules.php

@@ -158,10 +158,10 @@ class PluralRules {
 				return $n == 1 ? 0 :
 					($n >= 2 && $n <= 4 ? 1 : 2);
 			case 5:
-				return $n==1 ? 0 :
+				return $n == 1 ? 0 :
 					($n == 2 ? 1 : ($n < 7 ? 2 : ($n < 11 ? 3 : 4)));
 			case 6:
-				return $n %10 == 1 && $n % 100 != 11 ? 0 :
+				return $n % 10 == 1 && $n % 100 != 11 ? 0 :
 					($n % 10 >= 2 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
 			case 7:
 				return $n % 100 == 1 ? 1 :
@@ -187,7 +187,7 @@ class PluralRules {
 					($n % 100 >= 3 && $n % 100 <= 10 ? 3 :
 					($n % 100 >= 11 ? 4 : 5))));
 			case 14:
-				return $n ==1  ? 0 :
+				return $n == 1 ? 0 :
 					($n == 2 ? 1 :
 					($n != 8 && $n != 11 ? 2 : 3));
 		}

+ 2 - 1
src/I18n/TranslatorRegistry.php

@@ -40,6 +40,8 @@ class TranslatorRegistry extends TranslatorLocator {
  * @param string $locale The locale to use; if empty, uses the default
  * locale.
  * @return \Aura\Intl\TranslatorInterface A translator object.
+ * @throws \Aura\Intl\Exception If no translattor with that name could be found
+ * for the given locale.
  */
 	public function get($name, $locale = null) {
 		if ($locale === null) {
@@ -57,7 +59,6 @@ class TranslatorRegistry extends TranslatorLocator {
 					}
 					return $this->_getFromLoader($name, $locale);
 				}
-				
 			}, '_cake_core_');
 		}
 

+ 3 - 3
src/View/Helper/NumberHelper.php

@@ -136,7 +136,7 @@ class NumberHelper extends Helper {
  * - `after` - The string to place after decimal numbers, e.g. ']'
  * - `escape` - Whether or not to escape html in resulting string
  *
- * @param float $value A floating point number.
+ * @param float $number A floating point number.
  * @param array $options An array with options.
  * @return string Formatted number
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::format
@@ -166,7 +166,7 @@ class NumberHelper extends Helper {
  *   currency code.
  * - `escape` - Whether or not to escape html in resulting string
  *
- * @param float $value Value to format.
+ * @param float $number Value to format.
  * @param string $currency International currency name such as 'USD', 'EUR', 'JPY', 'CAD'
  * @param array $options Options list.
  * @return string Number formatted as a currency.
@@ -193,7 +193,7 @@ class NumberHelper extends Helper {
  * @param array $options Options list.
  * @return string formatted delta
  */
-	public static function formatDelta($value, array $options = array()) {
+	public function formatDelta($value, array $options = array()) {
 		$formatted = $this->_engine->formatDelta($value, $options);
 		$options += ['escape' => true];
 		return $options['escape'] ? h($formatted): $formatted;

+ 5 - 5
tests/TestCase/I18n/Formatter/IcuFormatterTest.php

@@ -66,11 +66,11 @@ class IcuFormatterTest extends TestCase {
 	public function testNativePluralSelection() {
 		$formatter = new IcuFormatter();
 		$locale = 'en_US';
-		$string = '{0,plural,'
-			. '=0{No fruits.}'
-			. '=1{We have one fruit}'
-			. 'other{We have {1} fruits}'
-			. '}';
+		$string = '{0,plural,' .
+			'=0{No fruits.}' .
+			'=1{We have one fruit}' .
+			'other{We have {1} fruits}' .
+			'}';
 
 		$params = [0, 0];
 		$expect = 'No fruits.';

+ 1 - 1
tests/TestCase/I18n/I18nTest.php

@@ -321,7 +321,7 @@ class I18nTest extends TestCase {
 					]
 				]);
 			}
-			
+
 			if ($locale === 'es_ES') {
 				$package->setMessages([
 				'Cow' => 'El Moo',

+ 1 - 27
tests/TestCase/Utility/NumberTest.php

@@ -16,9 +16,9 @@
  */
 namespace Cake\Test\TestCase\Utility;
 
+use Cake\I18n\I18n;
 use Cake\TestSuite\TestCase;
 use Cake\Utility\Number;
-use Cake\I18n\I18n;
 
 /**
  * NumberTest class
@@ -258,32 +258,6 @@ class NumberTest extends TestCase {
 	}
 
 /**
- * Test adding currency format options to the number helper
- *
- * @return void
- */
-	public function _testCurrencyAddFormat() {
-		$this->Number->addFormat('NOK', array('before' => 'Kr. '));
-		$result = $this->Number->currency(1000, 'NOK');
-		$expected = 'Kr. 1,000.00';
-		$this->assertEquals($expected, $result);
-
-		$this->Number->addFormat('Other', array('before' => '$$ ', 'after' => 'c!'));
-		$result = $this->Number->currency(0.22, 'Other');
-		$expected = '22c!';
-		$this->assertEquals($expected, $result);
-
-		$result = $this->Number->currency(-10, 'Other');
-		$expected = '($$ 10.00)';
-		$this->assertEquals($expected, $result);
-
-		$this->Number->addFormat('Other2', array('before' => '$ ', 'after' => false));
-		$result = $this->Number->currency(0.22, 'Other2');
-		$expected = '$ 0.22';
-		$this->assertEquals($expected, $result);
-	}
-
-/**
  * Test default currency
  *
  * @return void