Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__DIR__ . '/tests',
])
->withPhpSets()
->withTypeCoverageLevel(1)
->withPreparedSets(typeDeclarations: true)
->withDeadCodeLevel(2)
->withCodeQualityLevel(10)
->withCodingStyleLevel(0)
Expand Down
4 changes: 2 additions & 2 deletions src/Scanner/CodeScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function getFunctionHandler(ParsedFunction $function): ?callable

protected function addComments(ParsedFunction $function, ?Translation $translation): ?Translation
{
if (empty($this->commentsPrefixes) || empty($translation)) {
if (empty($this->commentsPrefixes) || $translation === null) {
return $translation;
}

Expand All @@ -110,7 +110,7 @@ protected function addComments(ParsedFunction $function, ?Translation $translati

protected function addFlags(ParsedFunction $function, ?Translation $translation): ?Translation
{
if (empty($translation)) {
if ($translation === null) {
return $translation;
}

Expand Down
36 changes: 17 additions & 19 deletions tests/BasePoLoaderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class BasePoLoaderTestCase extends TestCase
{
abstract protected function createPoLoader(): Loader;

public function testPoLoader()
public function testPoLoader(): void
{
$loader = $this->createPoLoader();
$translations = $loader->loadFile(__DIR__.'/assets/translations.po');
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testPoLoader()
$this->assertSame('bs', $translations->getLanguage());
}

private function translation1(Translation $translation)
private function translation1(Translation $translation): void
{
$this->assertSame(
'Ensure this value has at least %(limit_value)d character (it has %sd).',
Expand All @@ -87,7 +87,7 @@ private function translation1(Translation $translation)
$this->assertSame(['', ''], $translation->getPluralTranslations());
}

private function translation2(Translation $translation)
private function translation2(Translation $translation): void
{
$this->assertSame(
'Ensure this value has at most %(limit_value)d character (it has %sd).',
Expand All @@ -101,15 +101,15 @@ private function translation2(Translation $translation)
$this->assertSame(['', ''], $translation->getPluralTranslations());
}

private function translation3(Translation $translation)
private function translation3(Translation $translation): void
{
$this->assertSame('%ss must be unique for %ss %ss.', $translation->getOriginal());
$this->assertNull($translation->getPlural());
$this->assertSame('%ss mora da bude jedinstven za %ss %ss.', $translation->getTranslation());
$this->assertCount(0, $translation->getPluralTranslations());
}

private function translation4(Translation $translation)
private function translation4(Translation $translation): void
{
$this->assertSame('and', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -118,7 +118,7 @@ private function translation4(Translation $translation)
$this->assertSame(['c-format'], $translation->getFlags()->toArray());
}

private function translation5(Translation $translation)
private function translation5(Translation $translation): void
{
$this->assertSame('Value %sr is not a valid choice.', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -127,7 +127,7 @@ private function translation5(Translation $translation)
$this->assertSame(['This is a extracted comment'], $translation->getExtractedComments()->toArray());
}

private function translation6(Translation $translation)
private function translation6(Translation $translation): void
{
$this->assertSame('This field cannot be null.', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -137,7 +137,7 @@ private function translation6(Translation $translation)
$this->assertSame(['C:/Users/Me/Documents/foo2.php' => [1]], $translation->getReferences()->toArray());
}

private function translation7(Translation $translation)
private function translation7(Translation $translation): void
{
$this->assertSame('This field cannot be blank.', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -147,7 +147,7 @@ private function translation7(Translation $translation)
$this->assertSame(['C:/Users/Me/Documents/foo1.php' => []], $translation->getReferences()->toArray());
}

private function translation8(Translation $translation)
private function translation8(Translation $translation): void
{
$this->assertSame('Field of type: %ss', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -163,7 +163,7 @@ private function translation8(Translation $translation)
);
}

private function translation9(Translation $translation)
private function translation9(Translation $translation): void
{
$this->assertSame('Integer', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -174,7 +174,7 @@ private function translation9(Translation $translation)
$this->assertSame(['a simple line comment is above'], $translation->getComments()->toArray());
}

private function translation10(Translation $translation)
private function translation10(Translation $translation): void
{
$this->assertSame('{test1}', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -191,7 +191,7 @@ private function translation10(Translation $translation)
);
}

private function translation11(Translation $translation)
private function translation11(Translation $translation): void
{
$this->assertSame('{test2}', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -205,7 +205,7 @@ private function translation11(Translation $translation)
);
}

private function translation12(Translation $translation)
private function translation12(Translation $translation): void
{
$this->assertSame('Multibyte test', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -215,7 +215,7 @@ private function translation12(Translation $translation)
$this->assertCount(0, $translation->getReferences());
}

private function translation13(Translation $translation)
private function translation13(Translation $translation): void
{
$this->assertSame('Tabulation test', $translation->getOriginal());
$this->assertNull($translation->getPlural());
Expand All @@ -225,7 +225,7 @@ private function translation13(Translation $translation)
$this->assertCount(0, $translation->getReferences());
}

private function translation14(Translation $translation)
private function translation14(Translation $translation): void
{
$this->assertSame('%s has been added to your cart.', $translation->getOriginal());
$this->assertSame('%s have been added to your cart.', $translation->getPlural());
Expand Down Expand Up @@ -257,10 +257,8 @@ public function stringDecodeProvider()

/**
* @dataProvider stringDecodeProvider
* @param mixed $source
* @param mixed $decoded
*/
public function testStringDecode($source, $decoded)
public function testStringDecode(string $source, string $decoded): void
{
$po = <<<EOT
msgid "source"
Expand All @@ -270,7 +268,7 @@ public function testStringDecode($source, $decoded)
$this->assertSame($decoded, $translations->find(null, 'source')->getTranslation());
}

public function testMultilineDisabledTranslations()
public function testMultilineDisabledTranslations(): void
{
$po = <<<'EOT'
#~ msgid "Last agent hours-description"
Expand Down
6 changes: 3 additions & 3 deletions tests/CommentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class CommentsTest extends TestCase
{
public function testComments()
public function testComments(): void
{
$comments = new Comments();

Expand Down Expand Up @@ -36,7 +36,7 @@ public function testComments()
$this->assertCount(1, $comments);
}

public function testMergeComments()
public function testMergeComments(): void
{
$comments1 = new Comments('one', 'two', 'three');
$comments2 = new Comments('three', 'four', 'five');
Expand All @@ -50,7 +50,7 @@ public function testMergeComments()
$this->assertNotSame($merged, $comments2);
}

public function testCreateFromState()
public function testCreateFromState(): void
{
$state = ['comments' => ['First comment', 'Second comment']];
$comments = Comments::__set_state($state);
Expand Down
6 changes: 3 additions & 3 deletions tests/FlagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class FlagsTest extends TestCase
{
public function testFlags()
public function testFlags(): void
{
$flags = new Flags();

Expand Down Expand Up @@ -41,7 +41,7 @@ public function testFlags()
$this->assertCount(2, $flags);
}

public function testMergeFlags()
public function testMergeFlags(): void
{
$flags1 = new Flags('one', 'two', 'three');
$flags2 = new Flags('three', 'four', 'five');
Expand All @@ -61,7 +61,7 @@ public function testMergeFlags()
$this->assertNotSame($merged, $flags2);
}

public function testCreateFromState()
public function testCreateFromState(): void
{
$state = ['flags' => ['one', 'two']];
$flags = Flags::__set_state($state);
Expand Down
14 changes: 7 additions & 7 deletions tests/HeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HeadersTest extends TestCase
{
public function testHeaders()
public function testHeaders(): void
{
$headers = new Headers();

Expand Down Expand Up @@ -41,7 +41,7 @@ public function testHeaders()
$this->assertCount(0, $headers);
}

public function testDomain()
public function testDomain(): void
{
$headers = new Headers();
$headers->setDomain('foo');
Expand All @@ -52,7 +52,7 @@ public function testDomain()
$this->assertSame('foo', $headers->getDomain());
}

public function testLanguage()
public function testLanguage(): void
{
$headers = new Headers();
$headers->setLanguage('gl_ES');
Expand All @@ -63,15 +63,15 @@ public function testLanguage()
$this->assertSame('gl_ES', $headers->getLanguage());
}

public function testInvalidLanguage()
public function testInvalidLanguage(): void
{
$this->expectException(InvalidArgumentException::class);

$headers = new Headers();
$headers->setPluralForm(1, 'foo');
}

public function testPluralForm()
public function testPluralForm(): void
{
$headers = new Headers();
$headers->setPluralForm(2, '(n=1)');
Expand All @@ -82,7 +82,7 @@ public function testPluralForm()
$this->assertSame([2, '(n=1)'], $headers->getPluralForm());
}

public function testMergeHeaders()
public function testMergeHeaders(): void
{
$headers1 = new Headers(['X-Domain' => 'foo', 'Language' => 'gl_ES']);
$headers2 = new Headers(['Translator' => 'Oscar Otero', 'Language' => 'ru']);
Expand All @@ -97,7 +97,7 @@ public function testMergeHeaders()
$this->assertNotSame($merged, $headers2);
}

public function testCreateFromState()
public function testCreateFromState(): void
{
$state = ['headers' => ['X-Domain' => 'foo']];
$headers = Headers::__set_state($state);
Expand Down
6 changes: 3 additions & 3 deletions tests/MergeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static function createPO(): Translations
return $translations;
}

public function testNoStrategy()
public function testNoStrategy(): void
{
$pot = self::createPOT();
$po = self::createPO();
Expand All @@ -106,7 +106,7 @@ public function testNoStrategy()
/**
* We want to use the scanner to fetch new entries and complete them with PO files.
*/
public function testScanAndLoadStrategy()
public function testScanAndLoadStrategy(): void
{
$pot = self::createPOT();
$po = self::createPO();
Expand All @@ -126,7 +126,7 @@ public function testScanAndLoadStrategy()
$this->assertSnapshot(__FUNCTION__, $merged);
}

private function assertSnapshot(string $name, Translations $translations, bool $forceCreate = false)
private function assertSnapshot(string $name, Translations $translations, bool $forceCreate = false): void
{
$file = __DIR__."/snapshots/{$name}.php";
$array = $translations->toArray();
Expand Down
2 changes: 1 addition & 1 deletion tests/MoGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class MoGeneratorTest extends TestCase
{
public function testMoGenerator()
public function testMoGenerator(): void
{
$generator = (new MoGenerator())->includeHeaders();
$loader = new MoLoader();
Expand Down
Loading