Skip to content

Commit 753456b

Browse files
committed
Type generators and loaders
1 parent ad0ae0d commit 753456b

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

src/Generator/MoGenerator.php

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

99
final class MoGenerator extends Generator
1010
{
11+
/**
12+
* @var bool
13+
*/
1114
private $includeHeaders = false;
1215

1316
public function includeHeaders(bool $includeHeaders = true): self

src/Generator/PoGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public function generateString(Translations $translations): string
102102

103103
/**
104104
* Add one or more lines depending whether the string is multiline or not.
105+
*
106+
* @param array<int, string> $lines
105107
*/
106108
private static function appendLines(array &$lines, string $prefix, string $name, string $value): void
107109
{

src/Loader/MoLoader.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@
1111
*/
1212
final class MoLoader extends Loader
1313
{
14+
/**
15+
* @var string
16+
*/
1417
private $string;
18+
19+
/**
20+
* @var int<0, max>
21+
*/
1522
private $position;
23+
24+
/**
25+
* @var int<0, max>
26+
*/
1627
private $length;
1728

1829
private const MAGIC1 = -1794895138;
@@ -132,6 +143,12 @@ private function readInt(string $byteOrder): int
132143
return (int) array_shift($read);
133144
}
134145

146+
/**
147+
* @param string $byteOrder
148+
* @param int $count
149+
*
150+
* @return array<int, int>
151+
*/
135152
private function readIntArray(string $byteOrder, int $count): array
136153
{
137154
return unpack($byteOrder.$count, $this->read(4 * $count)) ?: [];

src/Loader/PoLoader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public function loadString(string $string, ?Translations $translations = null):
153153
return $translations;
154154
}
155155

156+
/**
157+
* @param string|null $string
158+
*
159+
* @return array<string, string>
160+
*/
156161
private static function parseHeaders(?string $string): array
157162
{
158163
if (empty($string)) {

src/Loader/StrictPoLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private function readCommentString(): string
167167
private function readQuotedString(?string $context = null): string
168168
{
169169
$this->readWhitespace();
170-
for ($data = '', $isNewPart = true, $checkpoint = null;;) {
170+
for ($data = '', $isNewPart = true, $checkpoint = null; ;) {
171171
if ($isNewPart && !$this->readChar('"')) {
172172
// The data is over (e.g. beginning of an identifier) or perhaps there's an error
173173
// Restore the checkpoint and let the next parser handle it
@@ -437,6 +437,8 @@ private function processHeader(): void
437437

438438
/**
439439
* Parses the translation header data into an array
440+
*
441+
* @return array<string, string>
440442
*/
441443
private function readHeaders(string $data): array
442444
{

0 commit comments

Comments
 (0)