Skip to content

Commit

Permalink
Update support for php 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderpeuscher committed Nov 16, 2022
1 parent 526d59e commit 6696300
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": "8.0.*",
"php": "8.1.*|8.0.*",
"ext-dom": "*",
"ext-zip": "*",
"ext-libxml": "*"
Expand Down
4 changes: 2 additions & 2 deletions src/Label305/DocxExtractor/Decorated/Sentence.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function toDocxXML(): string
$value .= "<w:tab/>";
}

$value .= '<w:t xml:space="preserve">' . htmlentities($this->text, ENT_XML1) . "</w:t></w:r>";
$value .= '<w:t xml:space="preserve">' . htmlentities($this->text ?? '', ENT_XML1) . "</w:t></w:r>";

if ($this->deletion !== null) {
$value .= '</w:del>';
Expand Down Expand Up @@ -263,7 +263,7 @@ public function toHTML(
$value .= "<font>";
}

$value .= htmlentities($this->text);
$value .= htmlentities($this->text ?? '', ENT_XML1);

if ($this->style !== null && !$this->style->isEmpty() && $lastWrappedInFont) {
$value .= "</font>";
Expand Down
4 changes: 2 additions & 2 deletions src/Label305/DocxExtractor/Decorated/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public function toDocxXML(): string

$value = '';
if ($this->rFonts !== null) {
$rFonts = htmlentities($this->rFonts, ENT_XML1);
$rFonts = htmlentities($this->rFonts ?? '', ENT_XML1);
$value .= '<w:rFonts w:ascii="' . $rFonts . '" w:hAnsi="' . $rFonts . '" w:cs="' . $rFonts . '"/>';
}
if ($this->rStyle !== null) {
$rStyle = htmlentities($this->rStyle, ENT_XML1);
$rStyle = htmlentities($this->rStyle ?? '', ENT_XML1);
$value .= '<w:rStyle w:val="' . $rStyle . '"/>';
}
foreach ($properties as $property) {
Expand Down
8 changes: 4 additions & 4 deletions tests/ExtractionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testTagMappingDecoratedExtractorWithNormalDocumentContainingNbsp
$this->assertEquals("At", $otherMapping[0][0]->text);
$this->assertEquals("The ", $otherMapping[0][1]->text);
$this->assertEquals("Edge", $otherMapping[0][2]->text);
$this->assertEquals("&Atilde;", $otherMapping[0][3]->text);
$this->assertEquals("Ã", $otherMapping[0][3]->text);

unlink(__DIR__.'/fixtures/normal-extracted.docx');
unlink(__DIR__.'/fixtures/normal-injected-extracted.docx');
Expand All @@ -154,7 +154,7 @@ public function testTagMappingDecoratedExtractorWithDocumentContainingHyperlink(

$mapping = $extractor->extractStringsAndCreateMappingFile(__DIR__ . '/fixtures/hyperlink.docx', __DIR__ . '/fixtures/hyperlink-extracted.docx');
$mapping[0][0]->text = Paragraph::paragraphWithHTML("Are you interested in a newly built spacious house from Euro&nbsp;")->toHTML();
$mapping[0][1]->text = Paragraph::paragraphWithHTML(html_entity_decode("69.000,&ndash;"))->toHTML();
$mapping[0][1]->text = Paragraph::paragraphWithHTML("69.000,-")->toHTML();
$mapping[0][2]->text = "? ";
$mapping[0][3]->text = Paragraph::paragraphWithHTML("CLICK ON THIS LINK AND SEE YOUR NEW BUILD HOUSE.")->toHTML();

Expand All @@ -171,7 +171,7 @@ public function testTagMappingDecoratedExtractorWithDocumentContainingHyperlink(
$this->assertNotNull($hyperLinkSenetence->hyperLink, 'Sentence is missing hyperlink property');

$this->assertEquals("Are you interested in a newly built spacious house from Euro ", $otherMapping[0][0]->text);
$this->assertEquals("69.000,&ndash;", $otherMapping[0][1]->text);
$this->assertEquals("69.000,-", $otherMapping[0][1]->text);
$this->assertEquals("? ", $otherMapping[0][2]->text);
$this->assertEquals("CLICK ON THIS LINK AND SEE YOUR NEW BUILD HOUSE.", $otherMapping[0][3]->text);

Expand Down Expand Up @@ -389,7 +389,7 @@ public function testNestedSentencesWithBr() {
$otherExtractor = new DecoratedTextExtractor();
$otherMapping = $otherExtractor->extractStringsAndCreateMappingFile(__DIR__.'/fixtures/nested-injected.docx', __DIR__.'/fixtures/nested-injected-extracted.docx');

$this->assertEquals("Andr&eacute; van Meurs VERTAALD", $otherMapping[0][0]->text);
$this->assertEquals("André van Meurs VERTAALD", $otherMapping[0][0]->text);
$this->assertEquals("Ruimtebaan 201 VERTAALD", $otherMapping[0][2]->text);
$this->assertEquals("2728 MK Zoetermeer VERTAALD", $otherMapping[0][4]->text);
$this->assertEquals("Ken je dat (..) VERTAALD", $otherMapping[5][0]->text);
Expand Down

0 comments on commit 6696300

Please sign in to comment.