Skip to content

Commit 2baead9

Browse files
committed
Rector type coverage level 2
1 parent 78d64ef commit 2baead9

14 files changed

+59
-63
lines changed

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__DIR__ . '/tests',
1212
])
1313
->withPhpSets()
14-
->withTypeCoverageLevel(1)
14+
->withPreparedSets(typeDeclarations: true)
1515
->withDeadCodeLevel(2)
1616
->withCodeQualityLevel(10)
1717
->withCodingStyleLevel(0)

src/Scanner/CodeScanner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function getFunctionHandler(ParsedFunction $function): ?callable
9595

9696
protected function addComments(ParsedFunction $function, ?Translation $translation): ?Translation
9797
{
98-
if (empty($this->commentsPrefixes) || empty($translation)) {
98+
if (empty($this->commentsPrefixes) || $translation !== null) {
9999
return $translation;
100100
}
101101

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

111111
protected function addFlags(ParsedFunction $function, ?Translation $translation): ?Translation
112112
{
113-
if (empty($translation)) {
113+
if ($translation === null) {
114114
return $translation;
115115
}
116116

tests/BasePoLoaderTestCase.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class BasePoLoaderTestCase extends TestCase
1111
{
1212
abstract protected function createPoLoader(): Loader;
1313

14-
public function testPoLoader()
14+
public function testPoLoader(): void
1515
{
1616
$loader = $this->createPoLoader();
1717
$translations = $loader->loadFile(__DIR__.'/assets/translations.po');
@@ -73,7 +73,7 @@ public function testPoLoader()
7373
$this->assertSame('bs', $translations->getLanguage());
7474
}
7575

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

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

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

112-
private function translation4(Translation $translation)
112+
private function translation4(Translation $translation): void
113113
{
114114
$this->assertSame('and', $translation->getOriginal());
115115
$this->assertNull($translation->getPlural());
@@ -118,7 +118,7 @@ private function translation4(Translation $translation)
118118
$this->assertSame(['c-format'], $translation->getFlags()->toArray());
119119
}
120120

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

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

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

150-
private function translation8(Translation $translation)
150+
private function translation8(Translation $translation): void
151151
{
152152
$this->assertSame('Field of type: %ss', $translation->getOriginal());
153153
$this->assertNull($translation->getPlural());
@@ -163,7 +163,7 @@ private function translation8(Translation $translation)
163163
);
164164
}
165165

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

177-
private function translation10(Translation $translation)
177+
private function translation10(Translation $translation): void
178178
{
179179
$this->assertSame('{test1}', $translation->getOriginal());
180180
$this->assertNull($translation->getPlural());
@@ -191,7 +191,7 @@ private function translation10(Translation $translation)
191191
);
192192
}
193193

194-
private function translation11(Translation $translation)
194+
private function translation11(Translation $translation): void
195195
{
196196
$this->assertSame('{test2}', $translation->getOriginal());
197197
$this->assertNull($translation->getPlural());
@@ -205,7 +205,7 @@ private function translation11(Translation $translation)
205205
);
206206
}
207207

208-
private function translation12(Translation $translation)
208+
private function translation12(Translation $translation): void
209209
{
210210
$this->assertSame('Multibyte test', $translation->getOriginal());
211211
$this->assertNull($translation->getPlural());
@@ -215,7 +215,7 @@ private function translation12(Translation $translation)
215215
$this->assertCount(0, $translation->getReferences());
216216
}
217217

218-
private function translation13(Translation $translation)
218+
private function translation13(Translation $translation): void
219219
{
220220
$this->assertSame('Tabulation test', $translation->getOriginal());
221221
$this->assertNull($translation->getPlural());
@@ -225,7 +225,7 @@ private function translation13(Translation $translation)
225225
$this->assertCount(0, $translation->getReferences());
226226
}
227227

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

258258
/**
259259
* @dataProvider stringDecodeProvider
260-
* @param mixed $source
261-
* @param mixed $decoded
262260
*/
263-
public function testStringDecode($source, $decoded)
261+
public function testStringDecode(string $source, string $decoded): void
264262
{
265263
$po = <<<EOT
266264
msgid "source"
@@ -270,7 +268,7 @@ public function testStringDecode($source, $decoded)
270268
$this->assertSame($decoded, $translations->find(null, 'source')->getTranslation());
271269
}
272270

273-
public function testMultilineDisabledTranslations()
271+
public function testMultilineDisabledTranslations(): void
274272
{
275273
$po = <<<'EOT'
276274
#~ msgid "Last agent hours-description"

tests/CommentsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class CommentsTest extends TestCase
1010
{
11-
public function testComments()
11+
public function testComments(): void
1212
{
1313
$comments = new Comments();
1414

@@ -36,7 +36,7 @@ public function testComments()
3636
$this->assertCount(1, $comments);
3737
}
3838

39-
public function testMergeComments()
39+
public function testMergeComments(): void
4040
{
4141
$comments1 = new Comments('one', 'two', 'three');
4242
$comments2 = new Comments('three', 'four', 'five');
@@ -50,7 +50,7 @@ public function testMergeComments()
5050
$this->assertNotSame($merged, $comments2);
5151
}
5252

53-
public function testCreateFromState()
53+
public function testCreateFromState(): void
5454
{
5555
$state = ['comments' => ['First comment', 'Second comment']];
5656
$comments = Comments::__set_state($state);

tests/FlagsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class FlagsTest extends TestCase
1010
{
11-
public function testFlags()
11+
public function testFlags(): void
1212
{
1313
$flags = new Flags();
1414

@@ -41,7 +41,7 @@ public function testFlags()
4141
$this->assertCount(2, $flags);
4242
}
4343

44-
public function testMergeFlags()
44+
public function testMergeFlags(): void
4545
{
4646
$flags1 = new Flags('one', 'two', 'three');
4747
$flags2 = new Flags('three', 'four', 'five');
@@ -61,7 +61,7 @@ public function testMergeFlags()
6161
$this->assertNotSame($merged, $flags2);
6262
}
6363

64-
public function testCreateFromState()
64+
public function testCreateFromState(): void
6565
{
6666
$state = ['flags' => ['one', 'two']];
6767
$flags = Flags::__set_state($state);

tests/HeadersTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HeadersTest extends TestCase
1111
{
12-
public function testHeaders()
12+
public function testHeaders(): void
1313
{
1414
$headers = new Headers();
1515

@@ -41,7 +41,7 @@ public function testHeaders()
4141
$this->assertCount(0, $headers);
4242
}
4343

44-
public function testDomain()
44+
public function testDomain(): void
4545
{
4646
$headers = new Headers();
4747
$headers->setDomain('foo');
@@ -52,7 +52,7 @@ public function testDomain()
5252
$this->assertSame('foo', $headers->getDomain());
5353
}
5454

55-
public function testLanguage()
55+
public function testLanguage(): void
5656
{
5757
$headers = new Headers();
5858
$headers->setLanguage('gl_ES');
@@ -63,15 +63,15 @@ public function testLanguage()
6363
$this->assertSame('gl_ES', $headers->getLanguage());
6464
}
6565

66-
public function testInvalidLanguage()
66+
public function testInvalidLanguage(): void
6767
{
6868
$this->expectException(InvalidArgumentException::class);
6969

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

74-
public function testPluralForm()
74+
public function testPluralForm(): void
7575
{
7676
$headers = new Headers();
7777
$headers->setPluralForm(2, '(n=1)');
@@ -82,7 +82,7 @@ public function testPluralForm()
8282
$this->assertSame([2, '(n=1)'], $headers->getPluralForm());
8383
}
8484

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

100-
public function testCreateFromState()
100+
public function testCreateFromState(): void
101101
{
102102
$state = ['headers' => ['X-Domain' => 'foo']];
103103
$headers = Headers::__set_state($state);

tests/MergeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private static function createPO(): Translations
9393
return $translations;
9494
}
9595

96-
public function testNoStrategy()
96+
public function testNoStrategy(): void
9797
{
9898
$pot = self::createPOT();
9999
$po = self::createPO();
@@ -106,7 +106,7 @@ public function testNoStrategy()
106106
/**
107107
* We want to use the scanner to fetch new entries and complete them with PO files.
108108
*/
109-
public function testScanAndLoadStrategy()
109+
public function testScanAndLoadStrategy(): void
110110
{
111111
$pot = self::createPOT();
112112
$po = self::createPO();
@@ -126,7 +126,7 @@ public function testScanAndLoadStrategy()
126126
$this->assertSnapshot(__FUNCTION__, $merged);
127127
}
128128

129-
private function assertSnapshot(string $name, Translations $translations, bool $forceCreate = false)
129+
private function assertSnapshot(string $name, Translations $translations, bool $forceCreate = false): void
130130
{
131131
$file = __DIR__."/snapshots/{$name}.php";
132132
$array = $translations->toArray();

tests/MoGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class MoGeneratorTest extends TestCase
1313
{
14-
public function testMoGenerator()
14+
public function testMoGenerator(): void
1515
{
1616
$generator = (new MoGenerator())->includeHeaders();
1717
$loader = new MoLoader();

0 commit comments

Comments
 (0)