Skip to content

Commit

Permalink
added missing thai translations
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyadenny authored and fabpot committed Oct 18, 2021
1 parent 0f8c227 commit 2a50705
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Caster/XmlReaderCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ class XmlReaderCaster

public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $isNested)
{
try {
$properties = [
'LOADDTD' => @$reader->getParserProperty(\XMLReader::LOADDTD),
'DEFAULTATTRS' => @$reader->getParserProperty(\XMLReader::DEFAULTATTRS),
'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE),
'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
];
} catch (\Error $e) {
$properties = [
'LOADDTD' => false,
'DEFAULTATTRS' => false,
'VALIDATE' => false,
'SUBST_ENTITIES' => false,
];
}

$props = Caster::PREFIX_VIRTUAL.'parserProperties';
$info = [
'localName' => $reader->localName,
Expand All @@ -57,12 +73,7 @@ public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $
'value' => $reader->value,
'namespaceURI' => $reader->namespaceURI,
'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI,
$props => [
'LOADDTD' => $reader->getParserProperty(\XMLReader::LOADDTD),
'DEFAULTATTRS' => $reader->getParserProperty(\XMLReader::DEFAULTATTRS),
'VALIDATE' => $reader->getParserProperty(\XMLReader::VALIDATE),
'SUBST_ENTITIES' => $reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
],
$props => $properties,
];

if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) {
Expand Down
14 changes: 14 additions & 0 deletions Tests/Caster/XmlReaderCasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,18 @@ public function provideNodes()
],
];
}

public function testWithUninitializedXMLReader()
{
$this->reader = new \XmlReader();

$expectedDump = <<<'EODUMP'
XMLReader {
+nodeType: NONE
…13
}
EODUMP;

$this->assertDumpMatchesFormat($expectedDump, $this->reader);
}
}

0 comments on commit 2a50705

Please sign in to comment.