Completed
Push — develop ( a51f26...2ecf95 )
by Zack
15:32
created
vendor/gettext/gettext/src/Extractors/YamlDictionary.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
  */
12 12
 class YamlDictionary extends Extractor implements ExtractorInterface
13 13
 {
14
-    use DictionaryTrait;
14
+	use DictionaryTrait;
15 15
 
16
-    /**
17
-     * {@inheritdoc}
18
-     */
19
-    public static function fromString($string, Translations $translations, array $options = [])
20
-    {
21
-        $messages = YamlParser::parse($string);
16
+	/**
17
+	 * {@inheritdoc}
18
+	 */
19
+	public static function fromString($string, Translations $translations, array $options = [])
20
+	{
21
+		$messages = YamlParser::parse($string);
22 22
 
23
-        if (is_array($messages)) {
24
-            static::fromArray($messages, $translations);
25
-        }
26
-    }
23
+		if (is_array($messages)) {
24
+			static::fromArray($messages, $translations);
25
+		}
26
+	}
27 27
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@
 block discarded – undo
16 16
     /**
17 17
      * {@inheritdoc}
18 18
      */
19
-    public static function fromString($string, Translations $translations, array $options = [])
19
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
20 20
     {
21
-        $messages = YamlParser::parse($string);
21
+        $messages = YamlParser::parse( $string );
22 22
 
23
-        if (is_array($messages)) {
24
-            static::fromArray($messages, $translations);
23
+        if ( is_array( $messages ) ) {
24
+            static::fromArray( $messages, $translations );
25 25
         }
26 26
     }
27 27
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,15 +9,13 @@
 block discarded – undo
9 9
 /**
10 10
  * Class to get gettext strings from yaml.
11 11
  */
12
-class YamlDictionary extends Extractor implements ExtractorInterface
13
-{
12
+class YamlDictionary extends Extractor implements ExtractorInterface {
14 13
     use DictionaryTrait;
15 14
 
16 15
     /**
17 16
      * {@inheritdoc}
18 17
      */
19
-    public static function fromString($string, Translations $translations, array $options = [])
20
-    {
18
+    public static function fromString($string, Translations $translations, array $options = []) {
21 19
         $messages = YamlParser::parse($string);
22 20
 
23 21
         if (is_array($messages)) {
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/Twig.php 3 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@
 block discarded – undo
13 13
  */
14 14
 class Twig extends Extractor implements ExtractorInterface
15 15
 {
16
-    public static $options = [
17
-        'extractComments' => 'notes:',
18
-        'twig' => null,
19
-    ];
20
-
21
-    /**
22
-     * {@inheritdoc}
23
-     */
24
-    public static function fromString($string, Translations $translations, array $options = [])
25
-    {
26
-        $options += static::$options;
27
-
28
-        $twig = $options['twig'] ?: static::createTwig();
29
-
30
-        PhpCode::fromString($twig->compileSource(new Twig_Source($string, '')), $translations, $options);
31
-    }
32
-
33
-    /**
34
-     * Returns a Twig instance.
35
-     *
36
-     * @return Twig_Environment
37
-     */
38
-    protected static function createTwig()
39
-    {
40
-        $twig = new Twig_Environment(new Twig_Loader_Array(['' => '']));
41
-        $twig->addExtension(new Twig_Extensions_Extension_I18n());
42
-
43
-        return static::$options['twig'] = $twig;
44
-    }
16
+	public static $options = [
17
+		'extractComments' => 'notes:',
18
+		'twig' => null,
19
+	];
20
+
21
+	/**
22
+	 * {@inheritdoc}
23
+	 */
24
+	public static function fromString($string, Translations $translations, array $options = [])
25
+	{
26
+		$options += static::$options;
27
+
28
+		$twig = $options['twig'] ?: static::createTwig();
29
+
30
+		PhpCode::fromString($twig->compileSource(new Twig_Source($string, '')), $translations, $options);
31
+	}
32
+
33
+	/**
34
+	 * Returns a Twig instance.
35
+	 *
36
+	 * @return Twig_Environment
37
+	 */
38
+	protected static function createTwig()
39
+	{
40
+		$twig = new Twig_Environment(new Twig_Loader_Array(['' => '']));
41
+		$twig->addExtension(new Twig_Extensions_Extension_I18n());
42
+
43
+		return static::$options['twig'] = $twig;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * {@inheritdoc}
23 23
      */
24
-    public static function fromString($string, Translations $translations, array $options = [])
24
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
25 25
     {
26 26
         $options += static::$options;
27 27
 
28
-        $twig = $options['twig'] ?: static::createTwig();
28
+        $twig = $options[ 'twig' ] ?: static::createTwig();
29 29
 
30
-        PhpCode::fromString($twig->compileSource(new Twig_Source($string, '')), $translations, $options);
30
+        PhpCode::fromString( $twig->compileSource( new Twig_Source( $string, '' ) ), $translations, $options );
31 31
     }
32 32
 
33 33
     /**
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected static function createTwig()
39 39
     {
40
-        $twig = new Twig_Environment(new Twig_Loader_Array(['' => '']));
41
-        $twig->addExtension(new Twig_Extensions_Extension_I18n());
40
+        $twig = new Twig_Environment( new Twig_Loader_Array( [ '' => '' ] ) );
41
+        $twig->addExtension( new Twig_Extensions_Extension_I18n() );
42 42
 
43
-        return static::$options['twig'] = $twig;
43
+        return static::$options[ 'twig' ] = $twig;
44 44
     }
45 45
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 /**
12 12
  * Class to get gettext strings from twig files returning arrays.
13 13
  */
14
-class Twig extends Extractor implements ExtractorInterface
15
-{
14
+class Twig extends Extractor implements ExtractorInterface {
16 15
     public static $options = [
17 16
         'extractComments' => 'notes:',
18 17
         'twig' => null,
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
     /**
22 21
      * {@inheritdoc}
23 22
      */
24
-    public static function fromString($string, Translations $translations, array $options = [])
25
-    {
23
+    public static function fromString($string, Translations $translations, array $options = []) {
26 24
         $options += static::$options;
27 25
 
28 26
         $twig = $options['twig'] ?: static::createTwig();
@@ -35,8 +33,7 @@  discard block
 block discarded – undo
35 33
      *
36 34
      * @return Twig_Environment
37 35
      */
38
-    protected static function createTwig()
39
-    {
36
+    protected static function createTwig() {
40 37
         $twig = new Twig_Environment(new Twig_Loader_Array(['' => '']));
41 38
         $twig->addExtension(new Twig_Extensions_Extension_I18n());
42 39
 
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/Blade.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@
 block discarded – undo
11 11
  */
12 12
 class Blade extends Extractor implements ExtractorInterface
13 13
 {
14
-    /**
15
-     * {@inheritdoc}
16
-     */
17
-    public static function fromString($string, Translations $translations, array $options = [])
18
-    {
19
-        if (empty($options['facade'])) {
20
-            $cachePath = empty($options['cachePath']) ? sys_get_temp_dir() : $options['cachePath'];
21
-            $bladeCompiler = new BladeCompiler(new Filesystem(), $cachePath);
14
+	/**
15
+	 * {@inheritdoc}
16
+	 */
17
+	public static function fromString($string, Translations $translations, array $options = [])
18
+	{
19
+		if (empty($options['facade'])) {
20
+			$cachePath = empty($options['cachePath']) ? sys_get_temp_dir() : $options['cachePath'];
21
+			$bladeCompiler = new BladeCompiler(new Filesystem(), $cachePath);
22 22
 
23
-            if (method_exists($bladeCompiler, 'withoutComponentTags')) {
24
-                $bladeCompiler->withoutComponentTags();
25
-            }
23
+			if (method_exists($bladeCompiler, 'withoutComponentTags')) {
24
+				$bladeCompiler->withoutComponentTags();
25
+			}
26 26
 
27
-            $string = $bladeCompiler->compileString($string);
28
-        } else {
29
-            $string = $options['facade']::compileString($string);
30
-        }
27
+			$string = $bladeCompiler->compileString($string);
28
+		} else {
29
+			$string = $options['facade']::compileString($string);
30
+		}
31 31
 
32
-        PhpCode::fromString($string, $translations, $options);
33
-    }
32
+		PhpCode::fromString($string, $translations, $options);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
     /**
15 15
      * {@inheritdoc}
16 16
      */
17
-    public static function fromString($string, Translations $translations, array $options = [])
17
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
18 18
     {
19
-        if (empty($options['facade'])) {
20
-            $cachePath = empty($options['cachePath']) ? sys_get_temp_dir() : $options['cachePath'];
21
-            $bladeCompiler = new BladeCompiler(new Filesystem(), $cachePath);
19
+        if ( empty( $options[ 'facade' ] ) ) {
20
+            $cachePath = empty( $options[ 'cachePath' ] ) ? sys_get_temp_dir() : $options[ 'cachePath' ];
21
+            $bladeCompiler = new BladeCompiler( new Filesystem(), $cachePath );
22 22
 
23
-            if (method_exists($bladeCompiler, 'withoutComponentTags')) {
23
+            if ( method_exists( $bladeCompiler, 'withoutComponentTags' ) ) {
24 24
                 $bladeCompiler->withoutComponentTags();
25 25
             }
26 26
 
27
-            $string = $bladeCompiler->compileString($string);
27
+            $string = $bladeCompiler->compileString( $string );
28 28
         } else {
29
-            $string = $options['facade']::compileString($string);
29
+            $string = $options[ 'facade' ]::compileString( $string );
30 30
         }
31 31
 
32
-        PhpCode::fromString($string, $translations, $options);
32
+        PhpCode::fromString( $string, $translations, $options );
33 33
     }
34 34
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,13 +9,11 @@
 block discarded – undo
9 9
 /**
10 10
  * Class to get gettext strings from blade.php files returning arrays.
11 11
  */
12
-class Blade extends Extractor implements ExtractorInterface
13
-{
12
+class Blade extends Extractor implements ExtractorInterface {
14 13
     /**
15 14
      * {@inheritdoc}
16 15
      */
17
-    public static function fromString($string, Translations $translations, array $options = [])
18
-    {
16
+    public static function fromString($string, Translations $translations, array $options = []) {
19 17
         if (empty($options['facade'])) {
20 18
             $cachePath = empty($options['cachePath']) ? sys_get_temp_dir() : $options['cachePath'];
21 19
             $bladeCompiler = new BladeCompiler(new Filesystem(), $cachePath);
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/ExtractorInterface.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@
 block discarded – undo
6 6
 
7 7
 interface ExtractorInterface
8 8
 {
9
-    /**
10
-     * Extract the translations from a file.
11
-     *
12
-     * @param array|string $file         A path of a file or files
13
-     * @param Translations $translations The translations instance to append the new translations.
14
-     * @param array        $options
15
-     */
16
-    public static function fromFile($file, Translations $translations, array $options = []);
9
+	/**
10
+	 * Extract the translations from a file.
11
+	 *
12
+	 * @param array|string $file         A path of a file or files
13
+	 * @param Translations $translations The translations instance to append the new translations.
14
+	 * @param array        $options
15
+	 */
16
+	public static function fromFile($file, Translations $translations, array $options = []);
17 17
 
18
-    /**
19
-     * Parses a string and append the translations found in the Translations instance.
20
-     *
21
-     * @param string       $string
22
-     * @param Translations $translations
23
-     * @param array        $options
24
-     */
25
-    public static function fromString($string, Translations $translations, array $options = []);
18
+	/**
19
+	 * Parses a string and append the translations found in the Translations instance.
20
+	 *
21
+	 * @param string       $string
22
+	 * @param Translations $translations
23
+	 * @param array        $options
24
+	 */
25
+	public static function fromString($string, Translations $translations, array $options = []);
26 26
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * @param Translations $translations The translations instance to append the new translations.
14 14
      * @param array        $options
15 15
      */
16
-    public static function fromFile($file, Translations $translations, array $options = []);
16
+    public static function fromFile( $file, Translations $translations, array $options = [ ] );
17 17
 
18 18
     /**
19 19
      * Parses a string and append the translations found in the Translations instance.
@@ -22,5 +22,5 @@  discard block
 block discarded – undo
22 22
      * @param Translations $translations
23 23
      * @param array        $options
24 24
      */
25
-    public static function fromString($string, Translations $translations, array $options = []);
25
+    public static function fromString( $string, Translations $translations, array $options = [ ] );
26 26
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use Gettext\Translations;
6 6
 
7
-interface ExtractorInterface
8
-{
7
+interface ExtractorInterface {
9 8
     /**
10 9
      * Extract the translations from a file.
11 10
      *
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/Csv.php 3 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -11,43 +11,43 @@
 block discarded – undo
11 11
  */
12 12
 class Csv extends Extractor implements ExtractorInterface
13 13
 {
14
-    use HeadersExtractorTrait;
15
-    use CsvTrait;
16
-
17
-    public static $options = [
18
-        'delimiter' => ",",
19
-        'enclosure' => '"',
20
-        'escape_char' => "\\"
21
-    ];
22
-
23
-    /**
24
-     * {@inheritdoc}
25
-     */
26
-    public static function fromString($string, Translations $translations, array $options = [])
27
-    {
28
-        $options += static::$options;
29
-        $handle = fopen('php://memory', 'w');
30
-
31
-        fputs($handle, $string);
32
-        rewind($handle);
33
-
34
-        while ($row = static::fgetcsv($handle, $options)) {
35
-            $context = array_shift($row);
36
-            $original = array_shift($row);
37
-
38
-            if ($context === '' && $original === '') {
39
-                static::extractHeaders(array_shift($row), $translations);
40
-                continue;
41
-            }
42
-
43
-            $translation = $translations->insert($context, $original);
44
-
45
-            if (!empty($row)) {
46
-                $translation->setTranslation(array_shift($row));
47
-                $translation->setPluralTranslations($row);
48
-            }
49
-        }
50
-
51
-        fclose($handle);
52
-    }
14
+	use HeadersExtractorTrait;
15
+	use CsvTrait;
16
+
17
+	public static $options = [
18
+		'delimiter' => ",",
19
+		'enclosure' => '"',
20
+		'escape_char' => "\\"
21
+	];
22
+
23
+	/**
24
+	 * {@inheritdoc}
25
+	 */
26
+	public static function fromString($string, Translations $translations, array $options = [])
27
+	{
28
+		$options += static::$options;
29
+		$handle = fopen('php://memory', 'w');
30
+
31
+		fputs($handle, $string);
32
+		rewind($handle);
33
+
34
+		while ($row = static::fgetcsv($handle, $options)) {
35
+			$context = array_shift($row);
36
+			$original = array_shift($row);
37
+
38
+			if ($context === '' && $original === '') {
39
+				static::extractHeaders(array_shift($row), $translations);
40
+				continue;
41
+			}
42
+
43
+			$translation = $translations->insert($context, $original);
44
+
45
+			if (!empty($row)) {
46
+				$translation->setTranslation(array_shift($row));
47
+				$translation->setPluralTranslations($row);
48
+			}
49
+		}
50
+
51
+		fclose($handle);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,31 +23,31 @@
 block discarded – undo
23 23
     /**
24 24
      * {@inheritdoc}
25 25
      */
26
-    public static function fromString($string, Translations $translations, array $options = [])
26
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
27 27
     {
28 28
         $options += static::$options;
29
-        $handle = fopen('php://memory', 'w');
29
+        $handle = fopen( 'php://memory', 'w' );
30 30
 
31
-        fputs($handle, $string);
32
-        rewind($handle);
31
+        fputs( $handle, $string );
32
+        rewind( $handle );
33 33
 
34
-        while ($row = static::fgetcsv($handle, $options)) {
35
-            $context = array_shift($row);
36
-            $original = array_shift($row);
34
+        while ( $row = static::fgetcsv( $handle, $options ) ) {
35
+            $context = array_shift( $row );
36
+            $original = array_shift( $row );
37 37
 
38
-            if ($context === '' && $original === '') {
39
-                static::extractHeaders(array_shift($row), $translations);
38
+            if ( $context === '' && $original === '' ) {
39
+                static::extractHeaders( array_shift( $row ), $translations );
40 40
                 continue;
41 41
             }
42 42
 
43
-            $translation = $translations->insert($context, $original);
43
+            $translation = $translations->insert( $context, $original );
44 44
 
45
-            if (!empty($row)) {
46
-                $translation->setTranslation(array_shift($row));
47
-                $translation->setPluralTranslations($row);
45
+            if ( ! empty( $row ) ) {
46
+                $translation->setTranslation( array_shift( $row ) );
47
+                $translation->setPluralTranslations( $row );
48 48
             }
49 49
         }
50 50
 
51
-        fclose($handle);
51
+        fclose( $handle );
52 52
     }
53 53
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
 /**
10 10
  * Class to get gettext strings from csv.
11 11
  */
12
-class Csv extends Extractor implements ExtractorInterface
13
-{
12
+class Csv extends Extractor implements ExtractorInterface {
14 13
     use HeadersExtractorTrait;
15 14
     use CsvTrait;
16 15
 
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
     /**
24 23
      * {@inheritdoc}
25 24
      */
26
-    public static function fromString($string, Translations $translations, array $options = [])
27
-    {
25
+    public static function fromString($string, Translations $translations, array $options = []) {
28 26
         $options += static::$options;
29 27
         $handle = fopen('php://memory', 'w');
30 28
 
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/PhpCode.php 3 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -11,160 +11,160 @@
 block discarded – undo
11 11
  */
12 12
 class PhpCode extends Extractor implements ExtractorInterface, ExtractorMultiInterface
13 13
 {
14
-    public static $options = [
15
-        // - false: to not extract comments
16
-        // - empty string: to extract all comments
17
-        // - non-empty string: to extract comments that start with that string
18
-        // - array with strings to extract comments format.
19
-        'extractComments' => false,
20
-
21
-        'constants' => [],
22
-
23
-        'functions' => [
24
-            'gettext' => 'gettext',
25
-            '__' => 'gettext',
26
-            'ngettext' => 'ngettext',
27
-            'n__' => 'ngettext',
28
-            'pgettext' => 'pgettext',
29
-            'p__' => 'pgettext',
30
-            'dgettext' => 'dgettext',
31
-            'd__' => 'dgettext',
32
-            'dngettext' => 'dngettext',
33
-            'dn__' => 'dngettext',
34
-            'dpgettext' => 'dpgettext',
35
-            'dp__' => 'dpgettext',
36
-            'npgettext' => 'npgettext',
37
-            'np__' => 'npgettext',
38
-            'dnpgettext' => 'dnpgettext',
39
-            'dnp__' => 'dnpgettext',
40
-            'noop' => 'noop',
41
-            'noop__' => 'noop',
42
-        ],
43
-    ];
44
-
45
-    protected static $functionsScannerClass = 'Gettext\Utils\PhpFunctionsScanner';
46
-
47
-    /**
48
-     * {@inheritdoc}
49
-     * @throws Exception
50
-     */
51
-    public static function fromString($string, Translations $translations, array $options = [])
52
-    {
53
-        static::fromStringMultiple($string, [$translations], $options);
54
-    }
55
-
56
-    /**
57
-     * @inheritDoc
58
-     * @throws Exception
59
-     */
60
-    public static function fromStringMultiple($string, array $translations, array $options = [])
61
-    {
62
-        $options += static::$options;
63
-
64
-        /** @var FunctionsScanner $functions */
65
-        $functions = new static::$functionsScannerClass($string);
66
-
67
-        if ($options['extractComments'] !== false) {
68
-            $functions->enableCommentsExtraction($options['extractComments']);
69
-        }
70
-
71
-        $functions->saveGettextFunctions($translations, $options);
72
-    }
73
-
74
-    /**
75
-     * @inheritDoc
76
-     */
77
-    public static function fromFileMultiple($file, array $translations, array $options = [])
78
-    {
79
-        foreach (static::getFiles($file) as $file) {
80
-            $options['file'] = $file;
81
-            static::fromStringMultiple(static::readFile($file), $translations, $options);
82
-        }
83
-    }
84
-
85
-
86
-    /**
87
-     * Decodes a T_CONSTANT_ENCAPSED_STRING string.
88
-     *
89
-     * @param string $value
90
-     *
91
-     * @return string
92
-     */
93
-    public static function convertString($value)
94
-    {
95
-        if (strpos($value, '\\') === false) {
96
-            return substr($value, 1, -1);
97
-        }
98
-
99
-        if ($value[0] === "'") {
100
-            return strtr(substr($value, 1, -1), ['\\\\' => '\\', '\\\'' => '\'']);
101
-        }
102
-
103
-        $value = substr($value, 1, -1);
104
-
105
-        return preg_replace_callback(
106
-            '/\\\(n|r|t|v|e|f|\$|"|\\\|x[0-9A-Fa-f]{1,2}|u{[0-9a-f]{1,6}}|[0-7]{1,3})/',
107
-            function ($match) {
108
-                switch ($match[1][0]) {
109
-                    case 'n':
110
-                        return "\n";
111
-                    case 'r':
112
-                        return "\r";
113
-                    case 't':
114
-                        return "\t";
115
-                    case 'v':
116
-                        return "\v";
117
-                    case 'e':
118
-                        return "\e";
119
-                    case 'f':
120
-                        return "\f";
121
-                    case '$':
122
-                        return '$';
123
-                    case '"':
124
-                        return '"';
125
-                    case '\\':
126
-                        return '\\';
127
-                    case 'x':
128
-                        return chr(hexdec(substr($match[1], 1)));
129
-                    case 'u':
130
-                        return static::unicodeChar(hexdec(substr($match[1], 1)));
131
-                    default:
132
-                        return chr(octdec($match[1]));
133
-                }
134
-            },
135
-            $value
136
-        );
137
-    }
138
-
139
-    /**
140
-     * @param $dec
141
-     * @return string|null
142
-     * @see http://php.net/manual/en/function.chr.php#118804
143
-     */
144
-    protected static function unicodeChar($dec)
145
-    {
146
-        if ($dec < 0x80) {
147
-            return chr($dec);
148
-        }
149
-
150
-        if ($dec < 0x0800) {
151
-            return chr(0xC0 + ($dec >> 6))
152
-                . chr(0x80 + ($dec & 0x3f));
153
-        }
154
-
155
-        if ($dec < 0x010000) {
156
-            return chr(0xE0 + ($dec >> 12))
157
-                . chr(0x80 + (($dec >> 6) & 0x3f))
158
-                . chr(0x80 + ($dec & 0x3f));
159
-        }
160
-
161
-        if ($dec < 0x200000) {
162
-            return chr(0xF0 + ($dec >> 18))
163
-                . chr(0x80 + (($dec >> 12) & 0x3f))
164
-                . chr(0x80 + (($dec >> 6) & 0x3f))
165
-                . chr(0x80 + ($dec & 0x3f));
166
-        }
167
-
168
-        return null;
169
-    }
14
+	public static $options = [
15
+		// - false: to not extract comments
16
+		// - empty string: to extract all comments
17
+		// - non-empty string: to extract comments that start with that string
18
+		// - array with strings to extract comments format.
19
+		'extractComments' => false,
20
+
21
+		'constants' => [],
22
+
23
+		'functions' => [
24
+			'gettext' => 'gettext',
25
+			'__' => 'gettext',
26
+			'ngettext' => 'ngettext',
27
+			'n__' => 'ngettext',
28
+			'pgettext' => 'pgettext',
29
+			'p__' => 'pgettext',
30
+			'dgettext' => 'dgettext',
31
+			'd__' => 'dgettext',
32
+			'dngettext' => 'dngettext',
33
+			'dn__' => 'dngettext',
34
+			'dpgettext' => 'dpgettext',
35
+			'dp__' => 'dpgettext',
36
+			'npgettext' => 'npgettext',
37
+			'np__' => 'npgettext',
38
+			'dnpgettext' => 'dnpgettext',
39
+			'dnp__' => 'dnpgettext',
40
+			'noop' => 'noop',
41
+			'noop__' => 'noop',
42
+		],
43
+	];
44
+
45
+	protected static $functionsScannerClass = 'Gettext\Utils\PhpFunctionsScanner';
46
+
47
+	/**
48
+	 * {@inheritdoc}
49
+	 * @throws Exception
50
+	 */
51
+	public static function fromString($string, Translations $translations, array $options = [])
52
+	{
53
+		static::fromStringMultiple($string, [$translations], $options);
54
+	}
55
+
56
+	/**
57
+	 * @inheritDoc
58
+	 * @throws Exception
59
+	 */
60
+	public static function fromStringMultiple($string, array $translations, array $options = [])
61
+	{
62
+		$options += static::$options;
63
+
64
+		/** @var FunctionsScanner $functions */
65
+		$functions = new static::$functionsScannerClass($string);
66
+
67
+		if ($options['extractComments'] !== false) {
68
+			$functions->enableCommentsExtraction($options['extractComments']);
69
+		}
70
+
71
+		$functions->saveGettextFunctions($translations, $options);
72
+	}
73
+
74
+	/**
75
+	 * @inheritDoc
76
+	 */
77
+	public static function fromFileMultiple($file, array $translations, array $options = [])
78
+	{
79
+		foreach (static::getFiles($file) as $file) {
80
+			$options['file'] = $file;
81
+			static::fromStringMultiple(static::readFile($file), $translations, $options);
82
+		}
83
+	}
84
+
85
+
86
+	/**
87
+	 * Decodes a T_CONSTANT_ENCAPSED_STRING string.
88
+	 *
89
+	 * @param string $value
90
+	 *
91
+	 * @return string
92
+	 */
93
+	public static function convertString($value)
94
+	{
95
+		if (strpos($value, '\\') === false) {
96
+			return substr($value, 1, -1);
97
+		}
98
+
99
+		if ($value[0] === "'") {
100
+			return strtr(substr($value, 1, -1), ['\\\\' => '\\', '\\\'' => '\'']);
101
+		}
102
+
103
+		$value = substr($value, 1, -1);
104
+
105
+		return preg_replace_callback(
106
+			'/\\\(n|r|t|v|e|f|\$|"|\\\|x[0-9A-Fa-f]{1,2}|u{[0-9a-f]{1,6}}|[0-7]{1,3})/',
107
+			function ($match) {
108
+				switch ($match[1][0]) {
109
+					case 'n':
110
+						return "\n";
111
+					case 'r':
112
+						return "\r";
113
+					case 't':
114
+						return "\t";
115
+					case 'v':
116
+						return "\v";
117
+					case 'e':
118
+						return "\e";
119
+					case 'f':
120
+						return "\f";
121
+					case '$':
122
+						return '$';
123
+					case '"':
124
+						return '"';
125
+					case '\\':
126
+						return '\\';
127
+					case 'x':
128
+						return chr(hexdec(substr($match[1], 1)));
129
+					case 'u':
130
+						return static::unicodeChar(hexdec(substr($match[1], 1)));
131
+					default:
132
+						return chr(octdec($match[1]));
133
+				}
134
+			},
135
+			$value
136
+		);
137
+	}
138
+
139
+	/**
140
+	 * @param $dec
141
+	 * @return string|null
142
+	 * @see http://php.net/manual/en/function.chr.php#118804
143
+	 */
144
+	protected static function unicodeChar($dec)
145
+	{
146
+		if ($dec < 0x80) {
147
+			return chr($dec);
148
+		}
149
+
150
+		if ($dec < 0x0800) {
151
+			return chr(0xC0 + ($dec >> 6))
152
+				. chr(0x80 + ($dec & 0x3f));
153
+		}
154
+
155
+		if ($dec < 0x010000) {
156
+			return chr(0xE0 + ($dec >> 12))
157
+				. chr(0x80 + (($dec >> 6) & 0x3f))
158
+				. chr(0x80 + ($dec & 0x3f));
159
+		}
160
+
161
+		if ($dec < 0x200000) {
162
+			return chr(0xF0 + ($dec >> 18))
163
+				. chr(0x80 + (($dec >> 12) & 0x3f))
164
+				. chr(0x80 + (($dec >> 6) & 0x3f))
165
+				. chr(0x80 + ($dec & 0x3f));
166
+		}
167
+
168
+		return null;
169
+	}
170 170
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         // - array with strings to extract comments format.
19 19
         'extractComments' => false,
20 20
 
21
-        'constants' => [],
21
+        'constants' => [ ],
22 22
 
23 23
         'functions' => [
24 24
             'gettext' => 'gettext',
@@ -48,37 +48,37 @@  discard block
 block discarded – undo
48 48
      * {@inheritdoc}
49 49
      * @throws Exception
50 50
      */
51
-    public static function fromString($string, Translations $translations, array $options = [])
51
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
52 52
     {
53
-        static::fromStringMultiple($string, [$translations], $options);
53
+        static::fromStringMultiple( $string, [ $translations ], $options );
54 54
     }
55 55
 
56 56
     /**
57 57
      * @inheritDoc
58 58
      * @throws Exception
59 59
      */
60
-    public static function fromStringMultiple($string, array $translations, array $options = [])
60
+    public static function fromStringMultiple( $string, array $translations, array $options = [ ] )
61 61
     {
62 62
         $options += static::$options;
63 63
 
64 64
         /** @var FunctionsScanner $functions */
65
-        $functions = new static::$functionsScannerClass($string);
65
+        $functions = new static::$functionsScannerClass( $string );
66 66
 
67
-        if ($options['extractComments'] !== false) {
68
-            $functions->enableCommentsExtraction($options['extractComments']);
67
+        if ( $options[ 'extractComments' ] !== false ) {
68
+            $functions->enableCommentsExtraction( $options[ 'extractComments' ] );
69 69
         }
70 70
 
71
-        $functions->saveGettextFunctions($translations, $options);
71
+        $functions->saveGettextFunctions( $translations, $options );
72 72
     }
73 73
 
74 74
     /**
75 75
      * @inheritDoc
76 76
      */
77
-    public static function fromFileMultiple($file, array $translations, array $options = [])
77
+    public static function fromFileMultiple( $file, array $translations, array $options = [ ] )
78 78
     {
79
-        foreach (static::getFiles($file) as $file) {
80
-            $options['file'] = $file;
81
-            static::fromStringMultiple(static::readFile($file), $translations, $options);
79
+        foreach ( static::getFiles( $file ) as $file ) {
80
+            $options[ 'file' ] = $file;
81
+            static::fromStringMultiple( static::readFile( $file ), $translations, $options );
82 82
         }
83 83
     }
84 84
 
@@ -90,22 +90,22 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return string
92 92
      */
93
-    public static function convertString($value)
93
+    public static function convertString( $value )
94 94
     {
95
-        if (strpos($value, '\\') === false) {
96
-            return substr($value, 1, -1);
95
+        if ( strpos( $value, '\\' ) === false ) {
96
+            return substr( $value, 1, -1 );
97 97
         }
98 98
 
99
-        if ($value[0] === "'") {
100
-            return strtr(substr($value, 1, -1), ['\\\\' => '\\', '\\\'' => '\'']);
99
+        if ( $value[ 0 ] === "'" ) {
100
+            return strtr( substr( $value, 1, -1 ), [ '\\\\' => '\\', '\\\'' => '\'' ] );
101 101
         }
102 102
 
103
-        $value = substr($value, 1, -1);
103
+        $value = substr( $value, 1, -1 );
104 104
 
105 105
         return preg_replace_callback(
106 106
             '/\\\(n|r|t|v|e|f|\$|"|\\\|x[0-9A-Fa-f]{1,2}|u{[0-9a-f]{1,6}}|[0-7]{1,3})/',
107
-            function ($match) {
108
-                switch ($match[1][0]) {
107
+            function( $match ) {
108
+                switch ( $match[ 1 ][ 0 ] ) {
109 109
                     case 'n':
110 110
                         return "\n";
111 111
                     case 'r':
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
                     case '\\':
126 126
                         return '\\';
127 127
                     case 'x':
128
-                        return chr(hexdec(substr($match[1], 1)));
128
+                        return chr( hexdec( substr( $match[ 1 ], 1 ) ) );
129 129
                     case 'u':
130
-                        return static::unicodeChar(hexdec(substr($match[1], 1)));
130
+                        return static::unicodeChar( hexdec( substr( $match[ 1 ], 1 ) ) );
131 131
                     default:
132
-                        return chr(octdec($match[1]));
132
+                        return chr( octdec( $match[ 1 ] ) );
133 133
                 }
134 134
             },
135 135
             $value
@@ -141,28 +141,28 @@  discard block
 block discarded – undo
141 141
      * @return string|null
142 142
      * @see http://php.net/manual/en/function.chr.php#118804
143 143
      */
144
-    protected static function unicodeChar($dec)
144
+    protected static function unicodeChar( $dec )
145 145
     {
146
-        if ($dec < 0x80) {
147
-            return chr($dec);
146
+        if ( $dec < 0x80 ) {
147
+            return chr( $dec );
148 148
         }
149 149
 
150
-        if ($dec < 0x0800) {
151
-            return chr(0xC0 + ($dec >> 6))
152
-                . chr(0x80 + ($dec & 0x3f));
150
+        if ( $dec < 0x0800 ) {
151
+            return chr( 0xC0 + ( $dec >> 6 ) )
152
+                . chr( 0x80 + ( $dec & 0x3f ) );
153 153
         }
154 154
 
155
-        if ($dec < 0x010000) {
156
-            return chr(0xE0 + ($dec >> 12))
157
-                . chr(0x80 + (($dec >> 6) & 0x3f))
158
-                . chr(0x80 + ($dec & 0x3f));
155
+        if ( $dec < 0x010000 ) {
156
+            return chr( 0xE0 + ( $dec >> 12 ) )
157
+                . chr( 0x80 + ( ( $dec >> 6 ) & 0x3f ) )
158
+                . chr( 0x80 + ( $dec & 0x3f ) );
159 159
         }
160 160
 
161
-        if ($dec < 0x200000) {
162
-            return chr(0xF0 + ($dec >> 18))
163
-                . chr(0x80 + (($dec >> 12) & 0x3f))
164
-                . chr(0x80 + (($dec >> 6) & 0x3f))
165
-                . chr(0x80 + ($dec & 0x3f));
161
+        if ( $dec < 0x200000 ) {
162
+            return chr( 0xF0 + ( $dec >> 18 ) )
163
+                . chr( 0x80 + ( ( $dec >> 12 ) & 0x3f ) )
164
+                . chr( 0x80 + ( ( $dec >> 6 ) & 0x3f ) )
165
+                . chr( 0x80 + ( $dec & 0x3f ) );
166 166
         }
167 167
 
168 168
         return null;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
48 48
      * {@inheritdoc}
49 49
      * @throws Exception
50 50
      */
51
-    public static function fromString($string, Translations $translations, array $options = [])
52
-    {
51
+    public static function fromString($string, Translations $translations, array $options = []) {
53 52
         static::fromStringMultiple($string, [$translations], $options);
54 53
     }
55 54
 
@@ -57,8 +56,7 @@  discard block
 block discarded – undo
57 56
      * @inheritDoc
58 57
      * @throws Exception
59 58
      */
60
-    public static function fromStringMultiple($string, array $translations, array $options = [])
61
-    {
59
+    public static function fromStringMultiple($string, array $translations, array $options = []) {
62 60
         $options += static::$options;
63 61
 
64 62
         /** @var FunctionsScanner $functions */
@@ -74,8 +72,7 @@  discard block
 block discarded – undo
74 72
     /**
75 73
      * @inheritDoc
76 74
      */
77
-    public static function fromFileMultiple($file, array $translations, array $options = [])
78
-    {
75
+    public static function fromFileMultiple($file, array $translations, array $options = []) {
79 76
         foreach (static::getFiles($file) as $file) {
80 77
             $options['file'] = $file;
81 78
             static::fromStringMultiple(static::readFile($file), $translations, $options);
@@ -90,8 +87,7 @@  discard block
 block discarded – undo
90 87
      *
91 88
      * @return string
92 89
      */
93
-    public static function convertString($value)
94
-    {
90
+    public static function convertString($value) {
95 91
         if (strpos($value, '\\') === false) {
96 92
             return substr($value, 1, -1);
97 93
         }
@@ -141,8 +137,7 @@  discard block
 block discarded – undo
141 137
      * @return string|null
142 138
      * @see http://php.net/manual/en/function.chr.php#118804
143 139
      */
144
-    protected static function unicodeChar($dec)
145
-    {
140
+    protected static function unicodeChar($dec) {
146 141
         if ($dec < 0x80) {
147 142
             return chr($dec);
148 143
         }
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/JsonDictionary.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
  */
11 11
 class JsonDictionary extends Extractor implements ExtractorInterface
12 12
 {
13
-    use DictionaryTrait;
13
+	use DictionaryTrait;
14 14
 
15
-    /**
16
-     * {@inheritdoc}
17
-     */
18
-    public static function fromString($string, Translations $translations, array $options = [])
19
-    {
20
-        $messages = json_decode($string, true);
15
+	/**
16
+	 * {@inheritdoc}
17
+	 */
18
+	public static function fromString($string, Translations $translations, array $options = [])
19
+	{
20
+		$messages = json_decode($string, true);
21 21
 
22
-        if (is_array($messages)) {
23
-            static::fromArray($messages, $translations);
24
-        }
25
-    }
22
+		if (is_array($messages)) {
23
+			static::fromArray($messages, $translations);
24
+		}
25
+	}
26 26
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
     /**
16 16
      * {@inheritdoc}
17 17
      */
18
-    public static function fromString($string, Translations $translations, array $options = [])
18
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
19 19
     {
20
-        $messages = json_decode($string, true);
20
+        $messages = json_decode( $string, true );
21 21
 
22
-        if (is_array($messages)) {
23
-            static::fromArray($messages, $translations);
22
+        if ( is_array( $messages ) ) {
23
+            static::fromArray( $messages, $translations );
24 24
         }
25 25
     }
26 26
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,15 +8,13 @@
 block discarded – undo
8 8
 /**
9 9
  * Class to get gettext strings from plain json.
10 10
  */
11
-class JsonDictionary extends Extractor implements ExtractorInterface
12
-{
11
+class JsonDictionary extends Extractor implements ExtractorInterface {
13 12
     use DictionaryTrait;
14 13
 
15 14
     /**
16 15
      * {@inheritdoc}
17 16
      */
18
-    public static function fromString($string, Translations $translations, array $options = [])
19
-    {
17
+    public static function fromString($string, Translations $translations, array $options = []) {
20 18
         $messages = json_decode($string, true);
21 19
 
22 20
         if (is_array($messages)) {
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/Mo.php 3 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -11,121 +11,121 @@
 block discarded – undo
11 11
  */
12 12
 class Mo extends Extractor implements ExtractorInterface
13 13
 {
14
-    const MAGIC1 = -1794895138;
15
-    const MAGIC2 = -569244523;
16
-    const MAGIC3 = 2500072158;
17
-
18
-    protected static $stringReaderClass = 'Gettext\Utils\StringReader';
19
-
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    public static function fromString($string, Translations $translations, array $options = [])
24
-    {
25
-        /** @var StringReader $stream */
26
-        $stream = new static::$stringReaderClass($string);
27
-        $magic = static::readInt($stream, 'V');
28
-
29
-        if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) { //to make sure it works for 64-bit platforms
30
-            $byteOrder = 'V'; //low endian
31
-        } elseif ($magic === (static::MAGIC2 & 0xFFFFFFFF)) {
32
-            $byteOrder = 'N'; //big endian
33
-        } else {
34
-            throw new Exception('Not MO file');
35
-        }
36
-
37
-        static::readInt($stream, $byteOrder);
38
-
39
-        $total = static::readInt($stream, $byteOrder); //total string count
40
-        $originals = static::readInt($stream, $byteOrder); //offset of original table
41
-        $tran = static::readInt($stream, $byteOrder); //offset of translation table
42
-
43
-        $stream->seekto($originals);
44
-        $table_originals = static::readIntArray($stream, $byteOrder, $total * 2);
45
-
46
-        $stream->seekto($tran);
47
-        $table_translations = static::readIntArray($stream, $byteOrder, $total * 2);
48
-
49
-        for ($i = 0; $i < $total; ++$i) {
50
-            $next = $i * 2;
51
-
52
-            $stream->seekto($table_originals[$next + 2]);
53
-            $original = $stream->read($table_originals[$next + 1]);
54
-
55
-            $stream->seekto($table_translations[$next + 2]);
56
-            $translated = $stream->read($table_translations[$next + 1]);
57
-
58
-            if ($original === '') {
59
-                // Headers
60
-                foreach (explode("\n", $translated) as $headerLine) {
61
-                    if ($headerLine === '') {
62
-                        continue;
63
-                    }
64
-
65
-                    $headerChunks = preg_split('/:\s*/', $headerLine, 2);
66
-                    $translations->setHeader($headerChunks[0], isset($headerChunks[1]) ? $headerChunks[1] : '');
67
-                }
68
-
69
-                continue;
70
-            }
71
-
72
-            $chunks = explode("\x04", $original, 2);
73
-
74
-            if (isset($chunks[1])) {
75
-                $context = $chunks[0];
76
-                $original = $chunks[1];
77
-            } else {
78
-                $context = '';
79
-            }
80
-
81
-            $chunks = explode("\x00", $original, 2);
82
-
83
-            if (isset($chunks[1])) {
84
-                $original = $chunks[0];
85
-                $plural = $chunks[1];
86
-            } else {
87
-                $plural = '';
88
-            }
89
-
90
-            $translation = $translations->insert($context, $original, $plural);
91
-
92
-            if ($translated === '') {
93
-                continue;
94
-            }
95
-
96
-            if ($plural === '') {
97
-                $translation->setTranslation($translated);
98
-                continue;
99
-            }
100
-
101
-            $v = explode("\x00", $translated);
102
-            $translation->setTranslation(array_shift($v));
103
-            $translation->setPluralTranslations($v);
104
-        }
105
-    }
106
-
107
-    /**
108
-     * @param StringReader $stream
109
-     * @param string       $byteOrder
110
-     */
111
-    protected static function readInt(StringReader $stream, $byteOrder)
112
-    {
113
-        if (($read = $stream->read(4)) === false) {
114
-            return false;
115
-        }
116
-
117
-        $read = unpack($byteOrder, $read);
118
-
119
-        return array_shift($read);
120
-    }
121
-
122
-    /**
123
-     * @param StringReader $stream
124
-     * @param string       $byteOrder
125
-     * @param int          $count
126
-     */
127
-    protected static function readIntArray(StringReader $stream, $byteOrder, $count)
128
-    {
129
-        return unpack($byteOrder.$count, $stream->read(4 * $count));
130
-    }
14
+	const MAGIC1 = -1794895138;
15
+	const MAGIC2 = -569244523;
16
+	const MAGIC3 = 2500072158;
17
+
18
+	protected static $stringReaderClass = 'Gettext\Utils\StringReader';
19
+
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	public static function fromString($string, Translations $translations, array $options = [])
24
+	{
25
+		/** @var StringReader $stream */
26
+		$stream = new static::$stringReaderClass($string);
27
+		$magic = static::readInt($stream, 'V');
28
+
29
+		if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) { //to make sure it works for 64-bit platforms
30
+			$byteOrder = 'V'; //low endian
31
+		} elseif ($magic === (static::MAGIC2 & 0xFFFFFFFF)) {
32
+			$byteOrder = 'N'; //big endian
33
+		} else {
34
+			throw new Exception('Not MO file');
35
+		}
36
+
37
+		static::readInt($stream, $byteOrder);
38
+
39
+		$total = static::readInt($stream, $byteOrder); //total string count
40
+		$originals = static::readInt($stream, $byteOrder); //offset of original table
41
+		$tran = static::readInt($stream, $byteOrder); //offset of translation table
42
+
43
+		$stream->seekto($originals);
44
+		$table_originals = static::readIntArray($stream, $byteOrder, $total * 2);
45
+
46
+		$stream->seekto($tran);
47
+		$table_translations = static::readIntArray($stream, $byteOrder, $total * 2);
48
+
49
+		for ($i = 0; $i < $total; ++$i) {
50
+			$next = $i * 2;
51
+
52
+			$stream->seekto($table_originals[$next + 2]);
53
+			$original = $stream->read($table_originals[$next + 1]);
54
+
55
+			$stream->seekto($table_translations[$next + 2]);
56
+			$translated = $stream->read($table_translations[$next + 1]);
57
+
58
+			if ($original === '') {
59
+				// Headers
60
+				foreach (explode("\n", $translated) as $headerLine) {
61
+					if ($headerLine === '') {
62
+						continue;
63
+					}
64
+
65
+					$headerChunks = preg_split('/:\s*/', $headerLine, 2);
66
+					$translations->setHeader($headerChunks[0], isset($headerChunks[1]) ? $headerChunks[1] : '');
67
+				}
68
+
69
+				continue;
70
+			}
71
+
72
+			$chunks = explode("\x04", $original, 2);
73
+
74
+			if (isset($chunks[1])) {
75
+				$context = $chunks[0];
76
+				$original = $chunks[1];
77
+			} else {
78
+				$context = '';
79
+			}
80
+
81
+			$chunks = explode("\x00", $original, 2);
82
+
83
+			if (isset($chunks[1])) {
84
+				$original = $chunks[0];
85
+				$plural = $chunks[1];
86
+			} else {
87
+				$plural = '';
88
+			}
89
+
90
+			$translation = $translations->insert($context, $original, $plural);
91
+
92
+			if ($translated === '') {
93
+				continue;
94
+			}
95
+
96
+			if ($plural === '') {
97
+				$translation->setTranslation($translated);
98
+				continue;
99
+			}
100
+
101
+			$v = explode("\x00", $translated);
102
+			$translation->setTranslation(array_shift($v));
103
+			$translation->setPluralTranslations($v);
104
+		}
105
+	}
106
+
107
+	/**
108
+	 * @param StringReader $stream
109
+	 * @param string       $byteOrder
110
+	 */
111
+	protected static function readInt(StringReader $stream, $byteOrder)
112
+	{
113
+		if (($read = $stream->read(4)) === false) {
114
+			return false;
115
+		}
116
+
117
+		$read = unpack($byteOrder, $read);
118
+
119
+		return array_shift($read);
120
+	}
121
+
122
+	/**
123
+	 * @param StringReader $stream
124
+	 * @param string       $byteOrder
125
+	 * @param int          $count
126
+	 */
127
+	protected static function readIntArray(StringReader $stream, $byteOrder, $count)
128
+	{
129
+		return unpack($byteOrder.$count, $stream->read(4 * $count));
130
+	}
131 131
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,87 +20,87 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * {@inheritdoc}
22 22
      */
23
-    public static function fromString($string, Translations $translations, array $options = [])
23
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
24 24
     {
25 25
         /** @var StringReader $stream */
26
-        $stream = new static::$stringReaderClass($string);
27
-        $magic = static::readInt($stream, 'V');
26
+        $stream = new static::$stringReaderClass( $string );
27
+        $magic = static::readInt( $stream, 'V' );
28 28
 
29
-        if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) { //to make sure it works for 64-bit platforms
29
+        if ( ( $magic === static::MAGIC1 ) || ( $magic === static::MAGIC3 ) ) { //to make sure it works for 64-bit platforms
30 30
             $byteOrder = 'V'; //low endian
31
-        } elseif ($magic === (static::MAGIC2 & 0xFFFFFFFF)) {
31
+        } elseif ( $magic === ( static::MAGIC2 & 0xFFFFFFFF ) ) {
32 32
             $byteOrder = 'N'; //big endian
33 33
         } else {
34
-            throw new Exception('Not MO file');
34
+            throw new Exception( 'Not MO file' );
35 35
         }
36 36
 
37
-        static::readInt($stream, $byteOrder);
37
+        static::readInt( $stream, $byteOrder );
38 38
 
39
-        $total = static::readInt($stream, $byteOrder); //total string count
40
-        $originals = static::readInt($stream, $byteOrder); //offset of original table
41
-        $tran = static::readInt($stream, $byteOrder); //offset of translation table
39
+        $total = static::readInt( $stream, $byteOrder ); //total string count
40
+        $originals = static::readInt( $stream, $byteOrder ); //offset of original table
41
+        $tran = static::readInt( $stream, $byteOrder ); //offset of translation table
42 42
 
43
-        $stream->seekto($originals);
44
-        $table_originals = static::readIntArray($stream, $byteOrder, $total * 2);
43
+        $stream->seekto( $originals );
44
+        $table_originals = static::readIntArray( $stream, $byteOrder, $total * 2 );
45 45
 
46
-        $stream->seekto($tran);
47
-        $table_translations = static::readIntArray($stream, $byteOrder, $total * 2);
46
+        $stream->seekto( $tran );
47
+        $table_translations = static::readIntArray( $stream, $byteOrder, $total * 2 );
48 48
 
49
-        for ($i = 0; $i < $total; ++$i) {
49
+        for ( $i = 0; $i < $total; ++$i ) {
50 50
             $next = $i * 2;
51 51
 
52
-            $stream->seekto($table_originals[$next + 2]);
53
-            $original = $stream->read($table_originals[$next + 1]);
52
+            $stream->seekto( $table_originals[ $next + 2 ] );
53
+            $original = $stream->read( $table_originals[ $next + 1 ] );
54 54
 
55
-            $stream->seekto($table_translations[$next + 2]);
56
-            $translated = $stream->read($table_translations[$next + 1]);
55
+            $stream->seekto( $table_translations[ $next + 2 ] );
56
+            $translated = $stream->read( $table_translations[ $next + 1 ] );
57 57
 
58
-            if ($original === '') {
58
+            if ( $original === '' ) {
59 59
                 // Headers
60
-                foreach (explode("\n", $translated) as $headerLine) {
61
-                    if ($headerLine === '') {
60
+                foreach ( explode( "\n", $translated ) as $headerLine ) {
61
+                    if ( $headerLine === '' ) {
62 62
                         continue;
63 63
                     }
64 64
 
65
-                    $headerChunks = preg_split('/:\s*/', $headerLine, 2);
66
-                    $translations->setHeader($headerChunks[0], isset($headerChunks[1]) ? $headerChunks[1] : '');
65
+                    $headerChunks = preg_split( '/:\s*/', $headerLine, 2 );
66
+                    $translations->setHeader( $headerChunks[ 0 ], isset( $headerChunks[ 1 ] ) ? $headerChunks[ 1 ] : '' );
67 67
                 }
68 68
 
69 69
                 continue;
70 70
             }
71 71
 
72
-            $chunks = explode("\x04", $original, 2);
72
+            $chunks = explode( "\x04", $original, 2 );
73 73
 
74
-            if (isset($chunks[1])) {
75
-                $context = $chunks[0];
76
-                $original = $chunks[1];
74
+            if ( isset( $chunks[ 1 ] ) ) {
75
+                $context = $chunks[ 0 ];
76
+                $original = $chunks[ 1 ];
77 77
             } else {
78 78
                 $context = '';
79 79
             }
80 80
 
81
-            $chunks = explode("\x00", $original, 2);
81
+            $chunks = explode( "\x00", $original, 2 );
82 82
 
83
-            if (isset($chunks[1])) {
84
-                $original = $chunks[0];
85
-                $plural = $chunks[1];
83
+            if ( isset( $chunks[ 1 ] ) ) {
84
+                $original = $chunks[ 0 ];
85
+                $plural = $chunks[ 1 ];
86 86
             } else {
87 87
                 $plural = '';
88 88
             }
89 89
 
90
-            $translation = $translations->insert($context, $original, $plural);
90
+            $translation = $translations->insert( $context, $original, $plural );
91 91
 
92
-            if ($translated === '') {
92
+            if ( $translated === '' ) {
93 93
                 continue;
94 94
             }
95 95
 
96
-            if ($plural === '') {
97
-                $translation->setTranslation($translated);
96
+            if ( $plural === '' ) {
97
+                $translation->setTranslation( $translated );
98 98
                 continue;
99 99
             }
100 100
 
101
-            $v = explode("\x00", $translated);
102
-            $translation->setTranslation(array_shift($v));
103
-            $translation->setPluralTranslations($v);
101
+            $v = explode( "\x00", $translated );
102
+            $translation->setTranslation( array_shift( $v ) );
103
+            $translation->setPluralTranslations( $v );
104 104
         }
105 105
     }
106 106
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
      * @param StringReader $stream
109 109
      * @param string       $byteOrder
110 110
      */
111
-    protected static function readInt(StringReader $stream, $byteOrder)
111
+    protected static function readInt( StringReader $stream, $byteOrder )
112 112
     {
113
-        if (($read = $stream->read(4)) === false) {
113
+        if ( ( $read = $stream->read( 4 ) ) === false ) {
114 114
             return false;
115 115
         }
116 116
 
117
-        $read = unpack($byteOrder, $read);
117
+        $read = unpack( $byteOrder, $read );
118 118
 
119
-        return array_shift($read);
119
+        return array_shift( $read );
120 120
     }
121 121
 
122 122
     /**
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
      * @param string       $byteOrder
125 125
      * @param int          $count
126 126
      */
127
-    protected static function readIntArray(StringReader $stream, $byteOrder, $count)
127
+    protected static function readIntArray( StringReader $stream, $byteOrder, $count )
128 128
     {
129
-        return unpack($byteOrder.$count, $stream->read(4 * $count));
129
+        return unpack( $byteOrder . $count, $stream->read( 4 * $count ) );
130 130
     }
131 131
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
 /**
10 10
  * Class to get gettext strings from .mo files.
11 11
  */
12
-class Mo extends Extractor implements ExtractorInterface
13
-{
12
+class Mo extends Extractor implements ExtractorInterface {
14 13
     const MAGIC1 = -1794895138;
15 14
     const MAGIC2 = -569244523;
16 15
     const MAGIC3 = 2500072158;
@@ -20,13 +19,13 @@  discard block
 block discarded – undo
20 19
     /**
21 20
      * {@inheritdoc}
22 21
      */
23
-    public static function fromString($string, Translations $translations, array $options = [])
24
-    {
22
+    public static function fromString($string, Translations $translations, array $options = []) {
25 23
         /** @var StringReader $stream */
26 24
         $stream = new static::$stringReaderClass($string);
27 25
         $magic = static::readInt($stream, 'V');
28 26
 
29
-        if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) { //to make sure it works for 64-bit platforms
27
+        if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) {
28
+//to make sure it works for 64-bit platforms
30 29
             $byteOrder = 'V'; //low endian
31 30
         } elseif ($magic === (static::MAGIC2 & 0xFFFFFFFF)) {
32 31
             $byteOrder = 'N'; //big endian
@@ -108,8 +107,7 @@  discard block
 block discarded – undo
108 107
      * @param StringReader $stream
109 108
      * @param string       $byteOrder
110 109
      */
111
-    protected static function readInt(StringReader $stream, $byteOrder)
112
-    {
110
+    protected static function readInt(StringReader $stream, $byteOrder) {
113 111
         if (($read = $stream->read(4)) === false) {
114 112
             return false;
115 113
         }
@@ -124,8 +122,7 @@  discard block
 block discarded – undo
124 122
      * @param string       $byteOrder
125 123
      * @param int          $count
126 124
      */
127
-    protected static function readIntArray(StringReader $stream, $byteOrder, $count)
128
-    {
125
+    protected static function readIntArray(StringReader $stream, $byteOrder, $count) {
129 126
         return unpack($byteOrder.$count, $stream->read(4 * $count));
130 127
     }
131 128
 }
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/Jed.php 3 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -9,47 +9,47 @@
 block discarded – undo
9 9
  */
10 10
 class Jed extends Extractor implements ExtractorInterface
11 11
 {
12
-    /**
13
-     * {@inheritdoc}
14
-     */
15
-    public static function fromString($string, Translations $translations, array $options = [])
16
-    {
17
-        static::extract(json_decode($string, true), $translations);
18
-    }
19
-
20
-    /**
21
-     * Handle an array of translations and append to the Translations instance.
22
-     *
23
-     * @param array        $content
24
-     * @param Translations $translations
25
-     */
26
-    public static function extract(array $content, Translations $translations)
27
-    {
28
-        $messages = current($content);
29
-        $headers = isset($messages['']) ? $messages[''] : null;
30
-        unset($messages['']);
31
-
32
-        if (!empty($headers['domain'])) {
33
-            $translations->setDomain($headers['domain']);
34
-        }
35
-
36
-        if (!empty($headers['lang'])) {
37
-            $translations->setLanguage($headers['lang']);
38
-        }
39
-
40
-        if (!empty($headers['plural-forms'])) {
41
-            $translations->setHeader(Translations::HEADER_PLURAL, $headers['plural-forms']);
42
-        }
43
-
44
-        $context_glue = '\u0004';
45
-
46
-        foreach ($messages as $key => $translation) {
47
-            $key = explode($context_glue, $key);
48
-            $context = isset($key[1]) ? array_shift($key) : '';
49
-
50
-            $translations->insert($context, array_shift($key))
51
-                ->setTranslation(array_shift($translation))
52
-                ->setPluralTranslations($translation);
53
-        }
54
-    }
12
+	/**
13
+	 * {@inheritdoc}
14
+	 */
15
+	public static function fromString($string, Translations $translations, array $options = [])
16
+	{
17
+		static::extract(json_decode($string, true), $translations);
18
+	}
19
+
20
+	/**
21
+	 * Handle an array of translations and append to the Translations instance.
22
+	 *
23
+	 * @param array        $content
24
+	 * @param Translations $translations
25
+	 */
26
+	public static function extract(array $content, Translations $translations)
27
+	{
28
+		$messages = current($content);
29
+		$headers = isset($messages['']) ? $messages[''] : null;
30
+		unset($messages['']);
31
+
32
+		if (!empty($headers['domain'])) {
33
+			$translations->setDomain($headers['domain']);
34
+		}
35
+
36
+		if (!empty($headers['lang'])) {
37
+			$translations->setLanguage($headers['lang']);
38
+		}
39
+
40
+		if (!empty($headers['plural-forms'])) {
41
+			$translations->setHeader(Translations::HEADER_PLURAL, $headers['plural-forms']);
42
+		}
43
+
44
+		$context_glue = '\u0004';
45
+
46
+		foreach ($messages as $key => $translation) {
47
+			$key = explode($context_glue, $key);
48
+			$context = isset($key[1]) ? array_shift($key) : '';
49
+
50
+			$translations->insert($context, array_shift($key))
51
+				->setTranslation(array_shift($translation))
52
+				->setPluralTranslations($translation);
53
+		}
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * {@inheritdoc}
14 14
      */
15
-    public static function fromString($string, Translations $translations, array $options = [])
15
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
16 16
     {
17
-        static::extract(json_decode($string, true), $translations);
17
+        static::extract( json_decode( $string, true ), $translations );
18 18
     }
19 19
 
20 20
     /**
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
      * @param array        $content
24 24
      * @param Translations $translations
25 25
      */
26
-    public static function extract(array $content, Translations $translations)
26
+    public static function extract( array $content, Translations $translations )
27 27
     {
28
-        $messages = current($content);
29
-        $headers = isset($messages['']) ? $messages[''] : null;
30
-        unset($messages['']);
28
+        $messages = current( $content );
29
+        $headers = isset( $messages[ '' ] ) ? $messages[ '' ] : null;
30
+        unset( $messages[ '' ] );
31 31
 
32
-        if (!empty($headers['domain'])) {
33
-            $translations->setDomain($headers['domain']);
32
+        if ( ! empty( $headers[ 'domain' ] ) ) {
33
+            $translations->setDomain( $headers[ 'domain' ] );
34 34
         }
35 35
 
36
-        if (!empty($headers['lang'])) {
37
-            $translations->setLanguage($headers['lang']);
36
+        if ( ! empty( $headers[ 'lang' ] ) ) {
37
+            $translations->setLanguage( $headers[ 'lang' ] );
38 38
         }
39 39
 
40
-        if (!empty($headers['plural-forms'])) {
41
-            $translations->setHeader(Translations::HEADER_PLURAL, $headers['plural-forms']);
40
+        if ( ! empty( $headers[ 'plural-forms' ] ) ) {
41
+            $translations->setHeader( Translations::HEADER_PLURAL, $headers[ 'plural-forms' ] );
42 42
         }
43 43
 
44 44
         $context_glue = '\u0004';
45 45
 
46
-        foreach ($messages as $key => $translation) {
47
-            $key = explode($context_glue, $key);
48
-            $context = isset($key[1]) ? array_shift($key) : '';
46
+        foreach ( $messages as $key => $translation ) {
47
+            $key = explode( $context_glue, $key );
48
+            $context = isset( $key[ 1 ] ) ? array_shift( $key ) : '';
49 49
 
50
-            $translations->insert($context, array_shift($key))
51
-                ->setTranslation(array_shift($translation))
52
-                ->setPluralTranslations($translation);
50
+            $translations->insert( $context, array_shift( $key ) )
51
+                ->setTranslation( array_shift( $translation ) )
52
+                ->setPluralTranslations( $translation );
53 53
         }
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,11 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class to get gettext strings from json files.
9 9
  */
10
-class Jed extends Extractor implements ExtractorInterface
11
-{
10
+class Jed extends Extractor implements ExtractorInterface {
12 11
     /**
13 12
      * {@inheritdoc}
14 13
      */
15
-    public static function fromString($string, Translations $translations, array $options = [])
16
-    {
14
+    public static function fromString($string, Translations $translations, array $options = []) {
17 15
         static::extract(json_decode($string, true), $translations);
18 16
     }
19 17
 
@@ -23,8 +21,7 @@  discard block
 block discarded – undo
23 21
      * @param array        $content
24 22
      * @param Translations $translations
25 23
      */
26
-    public static function extract(array $content, Translations $translations)
27
-    {
24
+    public static function extract(array $content, Translations $translations) {
28 25
         $messages = current($content);
29 26
         $headers = isset($messages['']) ? $messages[''] : null;
30 27
         unset($messages['']);
Please login to merge, or discard this patch.