Skip to content

Commit 2a50705

Browse files
shreyadennyfabpot
authored andcommitted
added missing thai translations
1 parent 0f8c227 commit 2a50705

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

Caster/XmlReaderCaster.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ class XmlReaderCaster
4444

4545
public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $isNested)
4646
{
47+
try {
48+
$properties = [
49+
'LOADDTD' => @$reader->getParserProperty(\XMLReader::LOADDTD),
50+
'DEFAULTATTRS' => @$reader->getParserProperty(\XMLReader::DEFAULTATTRS),
51+
'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE),
52+
'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
53+
];
54+
} catch (\Error $e) {
55+
$properties = [
56+
'LOADDTD' => false,
57+
'DEFAULTATTRS' => false,
58+
'VALIDATE' => false,
59+
'SUBST_ENTITIES' => false,
60+
];
61+
}
62+
4763
$props = Caster::PREFIX_VIRTUAL.'parserProperties';
4864
$info = [
4965
'localName' => $reader->localName,
@@ -57,12 +73,7 @@ public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $
5773
'value' => $reader->value,
5874
'namespaceURI' => $reader->namespaceURI,
5975
'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI,
60-
$props => [
61-
'LOADDTD' => $reader->getParserProperty(\XMLReader::LOADDTD),
62-
'DEFAULTATTRS' => $reader->getParserProperty(\XMLReader::DEFAULTATTRS),
63-
'VALIDATE' => $reader->getParserProperty(\XMLReader::VALIDATE),
64-
'SUBST_ENTITIES' => $reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
65-
],
76+
$props => $properties,
6677
];
6778

6879
if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) {

Tests/Caster/XmlReaderCasterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,18 @@ public function provideNodes()
245245
],
246246
];
247247
}
248+
249+
public function testWithUninitializedXMLReader()
250+
{
251+
$this->reader = new \XmlReader();
252+
253+
$expectedDump = <<<'EODUMP'
254+
XMLReader {
255+
+nodeType: NONE
256+
…13
257+
}
258+
EODUMP;
259+
260+
$this->assertDumpMatchesFormat($expectedDump, $this->reader);
261+
}
248262
}

0 commit comments

Comments
 (0)