Skip to content

Commit

Permalink
php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Oct 28, 2015
1 parent b8811ec commit 6162ad2
Show file tree
Hide file tree
Showing 38 changed files with 266 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.* export-ignore

# Set the line ending configuration
* text=lf
* text=lf
3 changes: 2 additions & 1 deletion src/BaseTranslator.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Gettext;

abstract class BaseTranslator
{
public static $current;

/**
* Set a translation instance as global, to use it with the gettext functions
* Set a translation instance as global, to use it with the gettext functions.
*
* @param Translator $translator
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Extractors/Blade.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;
use Illuminate\Filesystem\Filesystem;
use Illuminate\View\Compilers\BladeCompiler;

/**
* Class to get gettext strings from blade.php files returning arrays
* Class to get gettext strings from blade.php files returning arrays.
*/
class Blade extends Extractor implements ExtractorInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand Down
7 changes: 4 additions & 3 deletions src/Extractors/Extractor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Gettext\Extractors;

use Exception;
Expand All @@ -8,7 +9,7 @@
abstract class Extractor
{
/**
* Extract the translations from a file
* Extract the translations from a file.
*
* @param array|string $file A path of a file or files
* @param null|Translations $translations The translations instance to append the new translations.
Expand All @@ -29,7 +30,7 @@ public static function fromFile($file, Translations $translations = null)
}

/**
* Checks and returns all files
* Checks and returns all files.
*
* @param string|array $file The file/s
*
Expand Down Expand Up @@ -67,7 +68,7 @@ protected static function getFiles($file)
}

/**
* Reads and returns the content of a file
* Reads and returns the content of a file.
*
* @param string $file
*
Expand Down
5 changes: 3 additions & 2 deletions src/Extractors/ExtractorInterface.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;

interface ExtractorInterface
{
/**
* Extract the translations from a file
* Extract the translations from a file.
*
* @param array|string $file A path of a file or files
* @param null|Translations $translations The translations instance to append the new translations.
Expand All @@ -16,7 +17,7 @@ interface ExtractorInterface
public static function fromFile($file, Translations $translations = null);

/**
* Parses a string and append the translations found in the Translations instance
* Parses a string and append the translations found in the Translations instance.
*
* @param string $string
* @param Translations|null $translations
Expand Down
5 changes: 3 additions & 2 deletions src/Extractors/Jed.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;

/**
* Class to get gettext strings from json files
* Class to get gettext strings from json files.
*/
class Jed extends PhpArray implements ExtractorInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand Down
5 changes: 3 additions & 2 deletions src/Extractors/JsCode.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;
use Gettext\Utils\JsFunctionsScanner;

/**
* Class to get gettext strings from javascript files
* Class to get gettext strings from javascript files.
*/
class JsCode extends Extractor implements ExtractorInterface
{
Expand All @@ -16,7 +17,7 @@ class JsCode extends Extractor implements ExtractorInterface
);

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand Down
5 changes: 3 additions & 2 deletions src/Extractors/JsonDictionary.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;

/**
* Class to get gettext strings from plain json
* Class to get gettext strings from plain json.
*/
class JsonDictionary extends Extractor implements ExtractorInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand Down
7 changes: 4 additions & 3 deletions src/Extractors/Mo.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;
use Gettext\Utils\StringReader;

/**
* Class to get gettext strings from .mo files
* Class to get gettext strings from .mo files.
*/
class Mo extends Extractor implements ExtractorInterface
{
Expand All @@ -14,7 +15,7 @@ class Mo extends Extractor implements ExtractorInterface
const MAGIC3 = 2500072158;

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public static function fromString($string, Translations $translations = null, $f
$stream->seekto($tran);
$table_translations = self::readIntArray($stream, $byteOrder, $total * 2);

for ($i = 0; $i < $total; $i++) {
for ($i = 0; $i < $total; ++$i) {
$stream->seekto($table_originals[$i * 2 + 2]);
$original = $stream->read($table_originals[$i * 2 + 1]);
$stream->seekto($table_translations[$i * 2 + 2]);
Expand Down
11 changes: 6 additions & 5 deletions src/Extractors/PhpArray.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php

namespace Gettext\Extractors;

use Exception;
use Gettext\Translations;

/**
* Class to get gettext strings from php files returning arrays
* Class to get gettext strings from php files returning arrays.
*/
class PhpArray extends Extractor implements ExtractorInterface
{
/**
* Extract the translations from a file
* Extract the translations from a file.
*
* @param array|string $file A path of a file or files
* @param null|Translations $translations The translations instance to append the new translations.
Expand All @@ -31,15 +32,15 @@ public static function fromFile($file, Translations $translations = null)
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
throw new Exception("PhpArray::fromString() cannot be called. Use PhpArray::fromFile()");
throw new Exception('PhpArray::fromString() cannot be called. Use PhpArray::fromFile()');
}

/**
* Handle an array of translations and append to the Translations instance
* Handle an array of translations and append to the Translations instance.
*
* @param array $content
* @param Translations $translations
Expand Down
5 changes: 3 additions & 2 deletions src/Extractors/PhpCode.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;
use Gettext\Utils\PhpFunctionsScanner;

/**
* Class to get gettext strings from php files returning arrays
* Class to get gettext strings from php files returning arrays.
*/
class PhpCode extends Extractor implements ExtractorInterface
{
Expand All @@ -19,7 +20,7 @@ class PhpCode extends Extractor implements ExtractorInterface
);

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand Down
36 changes: 19 additions & 17 deletions src/Extractors/Po.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php

namespace Gettext\Extractors;

use Gettext\Translations;
use Gettext\Translation;

/**
* Class to get gettext strings from php files returning arrays
* Class to get gettext strings from php files returning arrays.
*/
class Po extends Extractor implements ExtractorInterface
{
/**
* Parses a .po file and append the translations found in the Translations instance
* Parses a .po file and append the translations found in the Translations instance.
*
* {@inheritDoc}
* {@inheritdoc}
*/
public static function fromString($string, Translations $translations = null, $file = '')
{
Expand All @@ -25,7 +26,7 @@ public static function fromString($string, Translations $translations = null, $f

$translation = new Translation('', '');

for ($n = count($lines); $i < $n; $i++) {
for ($n = count($lines); $i < $n; ++$i) {
$line = trim($lines[$i]);

$line = self::fixMultiLines($line, $lines, $i);
Expand Down Expand Up @@ -139,18 +140,19 @@ public static function fromString($string, Translations $translations = null, $f

/**
* Checks if it is a header definition line. Useful for distguishing between header definitions
* and possible continuations of a header entry
* and possible continuations of a header entry.
*
* @param string $line Line to parse
*
* @param string $line Line to parse
* @return boolean
* @return bool
*/
private static function isHeaderDefinition($line)
{
return (bool) preg_match('/^[\w-]+:/', $line);
}

/**
* Parse the po headers
* Parse the po headers.
*
* @param string $headers
* @param Translations $translations
Expand All @@ -175,7 +177,7 @@ private static function parseHeaders($headers, Translations $translations)
}

/**
* Cleans the strings. Removes quotes, "\n", "\t", etc
* Cleans the strings. Removes quotes, "\n", "\t", etc.
*
* @param string $str
*
Expand All @@ -195,22 +197,22 @@ private static function clean($str)
}

/**
* Gets one string from multiline strings
* Gets one string from multiline strings.
*
* @param string $line
* @param array $lines
* @param integer &$i
* @param string $line
* @param array $lines
* @param int &$i
*
* @return string
*/
private static function fixMultiLines($line, array $lines, &$i)
{
for ($j = $i, $t = count($lines); $j < $t; $j++) {
for ($j = $i, $t = count($lines); $j < $t; ++$j) {
if (substr($line, -1, 1) == '"'
&& isset($lines[$j+1])
&& substr(trim($lines[$j+1]), 0, 1) == '"'
&& isset($lines[$j + 1])
&& substr(trim($lines[$j + 1]), 0, 1) == '"'
) {
$line = substr($line, 0, -1).substr(trim($lines[$j+1]), 1);
$line = substr($line, 0, -1).substr(trim($lines[$j + 1]), 1);
} else {
$i = $j;
break;
Expand Down
Loading

0 comments on commit 6162ad2

Please sign in to comment.