Skip to content

Commit 6fddbb3

Browse files
authored
mb_convert_encoding can output false (#115)
1 parent d248274 commit 6fddbb3

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ ignore-hidden = false
77
[default.extend-words]
88
"flate" = "flate"
99
"fo" = "fo"
10+
"hel" = "hel"
1011
"paeth" = "paeth"
1112
"parms" = "parms"

src/Document/Dictionary/DictionaryValue/Date/DateValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function fromValue(string $valueString): ?self {
3535

3636
if (!str_starts_with($valueString, 'D:')) {
3737
$valueString = mb_convert_encoding($valueString, 'UTF-8', 'UTF-16');
38-
if (!str_starts_with($valueString, 'D:')) {
38+
if ($valueString === false || !str_starts_with($valueString, 'D:')) {
3939
return null;
4040
}
4141
}

tests/Unit/Document/Text/ContentStreamParserTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,21 @@ public function testParseWithMultibyteEscapedStringLiteralDelimiterInStringLiter
158158
(new TextObject())
159159
->addContentStreamCommand(new ContentStreamCommand(TextShowingOperator::SHOW, '(Hel' . chr(233) . '\)lo)'))
160160
),
161-
ContentStreamParser::parse('BT (Hel' . chr(233) .'\)lo) Tj ET')
161+
ContentStreamParser::parse('BT (Hel' . chr(233) . '\)lo) Tj ET')
162162
);
163163
static::assertEquals(
164164
new ContentStream(
165165
(new TextObject())
166166
->addContentStreamCommand(new ContentStreamCommand(TextShowingOperator::SHOW, '(Hel' . chr(233) . chr(108) . '\)lo)'))
167167
),
168-
ContentStreamParser::parse('BT (Hel' . chr(233) . chr(108) .'\)lo) Tj ET')
168+
ContentStreamParser::parse('BT (Hel' . chr(233) . chr(108) . '\)lo) Tj ET')
169169
);
170170
static::assertEquals(
171171
new ContentStream(
172172
(new TextObject())
173173
->addContentStreamCommand(new ContentStreamCommand(TextShowingOperator::SHOW, '(Hel' . chr(233) . chr(108) . chr(58) . '\)lo)'))
174174
),
175-
ContentStreamParser::parse('BT (Hel' . chr(233) . chr(108) . chr(58) .'\)lo) Tj ET')
175+
ContentStreamParser::parse('BT (Hel' . chr(233) . chr(108) . chr(58) . '\)lo) Tj ET')
176176
);
177177
}
178178

tests/Unit/Document/Text/Encoding/WinAnsiTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class WinAnsiTest extends TestCase {
1111
public function testToUnicode(): void {
1212
$string = mb_convert_encoding('transakèní', 'Windows-1252');
13+
static::assertNotFalse($string);
1314
static::assertEquals('transakèní', WinAnsi::textToUnicode($string));
1415
}
1516

0 commit comments

Comments
 (0)