@@ -43,6 +43,7 @@ public function loadString(string $string, Translations $translations = null): T
4343 $ this ->saveEntry ();
4444 }
4545 $ this ->processHeader ();
46+
4647 return $ this ->translations ;
4748 }
4849
@@ -88,6 +89,7 @@ private function readWhiteSpace(): bool
8889 while ((ctype_space ($ this ->getChar () ?? '' ) && $ this ->nextChar ())
8990 || $ this ->readDisabledComment ()
9091 || $ this ->readPreviousTranslationComment ());
92+
9193 return $ position !== $ this ->position ;
9294 }
9395
@@ -97,7 +99,7 @@ private function readWhiteSpace(): bool
9799 private function readString (string $ word ): bool
98100 {
99101 return substr ($ this ->data , $ this ->position , strlen ($ word )) === $ word
100- ? !! ($ this ->position += strlen ($ word ))
102+ ? ( bool ) ($ this ->position += strlen ($ word ))
101103 : false ;
102104 }
103105
@@ -106,7 +108,7 @@ private function readString(string $word): bool
106108 */
107109 private function readChar (string $ char ): bool
108110 {
109- return $ this ->getChar () === $ char ? !! ++$ this ->position : false ;
111+ return $ this ->getChar () === $ char ? ( bool ) ++$ this ->position : false ;
110112 }
111113
112114 /**
@@ -118,6 +120,7 @@ private function nextChar(): ?string
118120 if ($ char !== null ) {
119121 ++$ this ->position ;
120122 }
123+
121124 return $ char ;
122125 }
123126
@@ -135,6 +138,7 @@ private function getChar(): ?string
135138 private function readNumber (): string
136139 {
137140 for ($ data = '' ; ctype_digit ($ this ->getChar () ?? '' ); $ data .= $ this ->nextChar ());
141+
138142 return $ data ;
139143 }
140144
@@ -143,10 +147,13 @@ private function readNumber(): string
143147 */
144148 private function readCharset (string $ charset , int $ maxLength ): string
145149 {
146- for ($ data = '' ; ($ char = $ this ->getChar ()) !== null && is_int (strpos ($ charset , $ char )) && --$ maxLength >= 0 ; $ data .= $ this ->nextChar ());
150+ for ($ data = '' ; ($ char = $ this ->getChar ()) !== null
151+ && is_int (strpos ($ charset , $ char ))
152+ && --$ maxLength >= 0 ; $ data .= $ this ->nextChar ());
147153 if ($ data === '' ) {
148- throw new Exception ("Expected at least one occurrence of the characters \"{$ charset }\" at byte {$ this ->position }" );
154+ throw new Exception ("Expected at least one occurrence of \"{$ charset }\" at byte {$ this ->position }" );
149155 }
156+
150157 return $ data ;
151158 }
152159
@@ -156,6 +163,7 @@ private function readCharset(string $charset, int $maxLength): string
156163 private function readCommentString (): string
157164 {
158165 for ($ data = '' ; ($ char = $ this ->getChar () ?? "\n" ) !== "\n" && $ char !== "\r" ; $ data .= $ this ->nextChar ());
166+
159167 return $ data ;
160168 }
161169
@@ -221,6 +229,7 @@ private function readQuotedString(): string
221229 }
222230 $ this ->readWhiteSpace ();
223231 }
232+
224233 return $ data ;
225234 }
226235
@@ -278,6 +287,7 @@ private function readComment(): bool
278287 $ this ->translation ->getExtractedComments ()->add ($ data );
279288 break ;
280289 }
290+
281291 return true ;
282292 }
283293
@@ -291,9 +301,11 @@ private function readIdentifier(string $identifier, bool $throwIfNotFound = fals
291301 if ($ throwIfNotFound ) {
292302 throw new Exception ("Expected identifier $ identifier at byte {$ this ->position }" );
293303 }
304+
294305 return null ;
295306 }
296307 $ this ->readWhiteSpace ();
308+
297309 return $ this ->readQuotedString ();
298310 }
299311
@@ -306,6 +318,7 @@ private function readContext(): bool
306318 return false ;
307319 }
308320 $ this ->translation = $ this ->translation ->withContext ($ data );
321+
309322 return true ;
310323 }
311324
@@ -327,6 +340,7 @@ private function readPlural(): bool
327340 return false ;
328341 }
329342 $ this ->translation ->setPlural ($ data );
343+
330344 return true ;
331345 }
332346
@@ -354,6 +368,7 @@ private function readPluralTranslation(bool $throwIfNotFound = false): bool
354368 if ($ throwIfNotFound ) {
355369 throw new Exception ("Expected indexed msgstr at byte {$ this ->position }" );
356370 }
371+
357372 return false ;
358373 }
359374 $ this ->readWhiteSpace ();
@@ -379,6 +394,7 @@ private function readPluralTranslation(bool $throwIfNotFound = false): bool
379394 $ translations [] = $ data ;
380395 $ this ->translation ->translate (array_shift ($ translations ));
381396 $ this ->translation ->translatePlural (...$ translations );
397+
382398 return true ;
383399 }
384400
@@ -433,6 +449,7 @@ private function readHeaders(?string $string): array
433449 }
434450 $ headers [$ name ] .= $ line ;
435451 }
452+
436453 return $ headers ;
437454 }
438455}
0 commit comments