Skip to content

Commit b9374b0

Browse files
committed
Fix: Added the suggestions
1 parent 52d1f18 commit b9374b0

File tree

12 files changed

+15
-80
lines changed

12 files changed

+15
-80
lines changed

composer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@
113113
"phpoffice/math": "^0.2"
114114
},
115115
"require-dev": {
116-
"ext-zip": "*",
117-
"ext-gd": "*",
118116
"ext-libxml": "*",
119117
"dompdf/dompdf": "^2.0 || ^3.0",
120118
"friendsofphp/php-cs-fixer": "^3.3",

src/PhpWord/Writer/EPub3/Element/AbstractElement.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ abstract class AbstractElement extends Word2007AbstractElement
3131
* Get class name of writer element based on read element.
3232
*
3333
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
34-
*
35-
* @return string
3634
*/
37-
public static function getElementClass($element)
35+
public static function getElementClass($element): string
3836
{
3937
$elementClass = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($element));
4038
$writerClass = 'PhpOffice\\PhpWord\\Writer\\EPub3\\Element\\' . $elementClass;

src/PhpWord/Writer/EPub3/Element/Text.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace PhpOffice\PhpWord\Writer\EPub3\Element;
44

5-
use PhpOffice\PhpWord\Element\TrackChange;
6-
75
/**
86
* Text element writer for EPub3.
97
*/
@@ -39,9 +37,7 @@ public function write(): void
3937
}
4038
}
4139

42-
$this->writeTrackChanges($element->getTrackChange(), true);
4340
$xmlWriter->text($element->getText());
44-
$this->writeTrackChanges($element->getTrackChange(), false);
4541

4642
if (!empty($fontStyle)) {
4743
$xmlWriter->endElement(); // span
@@ -51,33 +47,4 @@ public function write(): void
5147
$xmlWriter->endElement(); // p
5248
}
5349
}
54-
55-
/**
56-
* Write track changes.
57-
*/
58-
private function writeTrackChanges(?TrackChange $trackChange, bool $isStart): void
59-
{
60-
if ($trackChange === null) {
61-
return;
62-
}
63-
64-
$xmlWriter = $this->getXmlWriter();
65-
if ($trackChange->getChangeType() === TrackChange::INSERTED) {
66-
$xmlWriter->writeRaw("\n ");
67-
$xmlWriter->startElement('ins');
68-
$xmlWriter->writeAttribute('class', 'phpword-change');
69-
$xmlWriter->writeAttribute('data-change-id', $trackChange->getElementId());
70-
if (!$isStart) {
71-
$xmlWriter->endElement();
72-
}
73-
} elseif ($trackChange->getChangeType() === TrackChange::DELETED) {
74-
$xmlWriter->writeRaw("\n ");
75-
$xmlWriter->startElement('del');
76-
$xmlWriter->writeAttribute('class', 'phpword-change');
77-
$xmlWriter->writeAttribute('data-change-id', $trackChange->getElementId());
78-
if (!$isStart) {
79-
$xmlWriter->endElement();
80-
}
81-
}
82-
}
8350
}

src/PhpWord/Writer/EPub3/Part/AbstractPart.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ abstract class AbstractPart
3434

3535
/**
3636
* Set parent writer.
37-
*
38-
* @return self
3937
*/
40-
public function setParentWriter(AbstractWriter $writer)
38+
public function setParentWriter(AbstractWriter $writer): self
4139
{
4240
$this->parentWriter = $writer;
4341

@@ -46,18 +44,14 @@ public function setParentWriter(AbstractWriter $writer)
4644

4745
/**
4846
* Get parent writer.
49-
*
50-
* @return AbstractWriter
5147
*/
52-
public function getParentWriter()
48+
public function getParentWriter(): AbstractWriter
5349
{
5450
return $this->parentWriter;
5551
}
5652

5753
/**
5854
* Write part content.
59-
*
60-
* @return string
6155
*/
62-
abstract public function write();
56+
abstract public function write(): string;
6357
}

src/PhpWord/Writer/EPub3/Part/Content.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Content extends AbstractPart
2525
{
2626
/**
2727
* Write part content.
28-
*
29-
* @return string
3028
*/
31-
public function write()
29+
public function write(): string
3230
{
3331
$content = '<?xml version="1.0" encoding="UTF-8"?>';
3432
$content .= '<package xmlns="http://www.idpf.org/2007/opf" version="3.0">';

src/PhpWord/Writer/EPub3/Part/Manifest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Manifest extends AbstractPart
2525
{
2626
/**
2727
* Write part content.
28-
*
29-
* @return string
3028
*/
31-
public function write()
29+
public function write(): string
3230
{
3331
$content = '<?xml version="1.0" encoding="UTF-8"?>';
3432
$content .= '<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">';

src/PhpWord/Writer/EPub3/Part/Meta.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ class Meta extends AbstractPart
2727
{
2828
/**
2929
* Get XML Writer.
30-
*
31-
* @return XMLWriter
3230
*/
33-
protected function getXmlWriter()
31+
protected function getXmlWriter(): XMLWriter
3432
{
3533
$xmlWriter = new XMLWriter();
3634
$xmlWriter->openMemory();

src/PhpWord/Writer/EPub3/Part/Mimetype.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Mimetype extends AbstractPart
2525
{
2626
/**
2727
* Write part content.
28-
*
29-
* @return string
3028
*/
31-
public function write()
29+
public function write(): string
3230
{
3331
return 'application/epub+zip';
3432
}

src/PhpWord/Writer/EPub3/Style/AbstractStyle.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ abstract class AbstractStyle
4242

4343
/**
4444
* Set parent writer.
45-
*
46-
* @return self
4745
*/
48-
public function setParentWriter(AbstractWriter $writer)
46+
public function setParentWriter(AbstractWriter $writer): self
4947
{
5048
$this->parentWriter = $writer;
5149

@@ -54,10 +52,8 @@ public function setParentWriter(AbstractWriter $writer)
5452

5553
/**
5654
* Set XML Writer.
57-
*
58-
* @return self
5955
*/
60-
public function setXmlWriter(XMLWriter $writer)
56+
public function setXmlWriter(XMLWriter $writer): self
6157
{
6258
$this->xmlWriter = $writer;
6359

@@ -66,18 +62,14 @@ public function setXmlWriter(XMLWriter $writer)
6662

6763
/**
6864
* Get parent writer.
69-
*
70-
* @return AbstractWriter
7165
*/
72-
public function getParentWriter()
66+
public function getParentWriter(): AbstractWriter
7367
{
7468
return $this->parentWriter;
7569
}
7670

7771
/**
7872
* Write style content.
79-
*
80-
* @return string
8173
*/
82-
abstract public function write();
74+
abstract public function write(): string;
8375
}

src/PhpWord/Writer/EPub3/Style/Font.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Font extends AbstractStyle
2525
{
2626
/**
2727
* Write style content.
28-
*
29-
* @return string
3028
*/
31-
public function write()
29+
public function write(): string
3230
{
3331
$content = 'body {';
3432
$content .= 'font-family: "Times New Roman", Times, serif;';

src/PhpWord/Writer/EPub3/Style/Paragraph.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Paragraph extends AbstractStyle
2525
{
2626
/**
2727
* Write style content.
28-
*
29-
* @return string
3028
*/
31-
public function write()
29+
public function write(): string
3230
{
3331
$content = 'p {';
3432
$content .= 'margin-top: 0;';

src/PhpWord/Writer/EPub3/Style/Table.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Table extends AbstractStyle
2525
{
2626
/**
2727
* Write style content.
28-
*
29-
* @return string
3028
*/
31-
public function write()
29+
public function write(): string
3230
{
3331
$content = 'table {';
3432
$content .= 'border-collapse: collapse;';

0 commit comments

Comments
 (0)