Skip to content

Commit 8054949

Browse files
committed
Responding to Scrutinizer Comments
Mostly docblock changes, specifying that members can be null if so.
1 parent 53feb99 commit 8054949

File tree

7 files changed

+35
-29
lines changed

7 files changed

+35
-29
lines changed

src/PhpWord/Style/Font.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class Font extends AbstractStyle
248248
/**
249249
* Languages
250250
*
251-
* @var \PhpOffice\PhpWord\Style\Language
251+
* @var \PhpOffice\PhpWord\Style\Language|null
252252
*/
253253
private $lang;
254254

@@ -856,7 +856,7 @@ public function setShading($value = null)
856856
/**
857857
* Get language
858858
*
859-
* @return \PhpOffice\PhpWord\Style\Language
859+
* @return \PhpOffice\PhpWord\Style\Language|null
860860
*/
861861
public function getLang()
862862
{

src/PhpWord/Style/Paragraph.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Paragraph extends Border
8585
/**
8686
* Indentation
8787
*
88-
* @var \PhpOffice\PhpWord\Style\Indentation
88+
* @var \PhpOffice\PhpWord\Style\Indentation|null
8989
*/
9090
private $indentation;
9191

@@ -99,7 +99,7 @@ class Paragraph extends Border
9999
/**
100100
* Text line height
101101
*
102-
* @var int
102+
* @var int|float|null
103103
*/
104104
private $lineHeight;
105105

@@ -343,9 +343,9 @@ public function setNext($value = null)
343343
}
344344

345345
/**
346-
* Get shading
346+
* Get indentation
347347
*
348-
* @return \PhpOffice\PhpWord\Style\Indentation
348+
* @return \PhpOffice\PhpWord\Style\Indentation|null
349349
*/
350350
public function getIndentation()
351351
{
@@ -519,7 +519,7 @@ public function setSpacingLineRule($value)
519519
/**
520520
* Get line height
521521
*
522-
* @return int|float
522+
* @return int|float|null
523523
*/
524524
public function getLineHeight()
525525
{

src/PhpWord/Writer/HTML.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,17 @@ public function getContent()
8686
$content .= '<!-- Generated by PHPWord -->' . PHP_EOL;
8787
$langtext = '';
8888
$phpWord = $this->getPhpWord();
89-
if ($phpWord) {
90-
$lang = $phpWord->getSettings()->getThemeFontLang();
91-
if ($lang) {
92-
$lang2 = $lang->getLatin();
93-
if (!$lang2) {
94-
$lang2 = $lang->getEastAsia();
95-
}
96-
if (!$lang2) {
97-
$lang2 = $lang->getBidirectional();
98-
}
99-
if ($lang2) {
100-
$langtext = " lang='" . $lang2 . "'";
101-
}
89+
$lang = $phpWord->getSettings()->getThemeFontLang();
90+
if (!empty($lang)) {
91+
$lang2 = $lang->getLatin();
92+
if (!$lang2) {
93+
$lang2 = $lang->getEastAsia();
94+
}
95+
if (!$lang2) {
96+
$lang2 = $lang->getBidirectional();
97+
}
98+
if ($lang2) {
99+
$langtext = " lang='" . $lang2 . "'";
102100
}
103101
}
104102
$content .= "<html$langtext>" . PHP_EOL;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public function write()
7676
$content .= $this->openingText;
7777
$content .= $this->openingTags;
7878
if (Settings::isOutputEscapingEnabled()) {
79+
// Scrutinizer notes that escapeHTML does not exist on AbstractEscaper.
80+
// Nevertheless, it does exist for HTML writer.
81+
/** @scrutinizer ignore-call */
7982
$contenx = $this->escaper->escapeHtml($element->getText());
8083
} else {
8184
$contenx = $element->getText();
@@ -264,10 +267,13 @@ private function getFontStyle()
264267
$style = " style=\"$styl2\"";
265268
}
266269
$lang = $fontStyle->getLang();
267-
} elseif (is_string($fontStyle)) {
270+
} elseif (!empty($fontStyle)) {
268271
$style = " class=\"$fontStyle\"";
269272
$styl2 = Style::getStyle($fontStyle);
270-
if ($styl2) {
273+
if (!empty($styl2)) {
274+
// Scrutinizer notes that getLang does not exist on Abstract Style.
275+
// Nevertheless, it does exist for Font Style.
276+
/** @scrutinizer ignore-call */
271277
$lang = $styl2->getLang();
272278
}
273279
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace PhpOffice\PhpWord\Writer\HTML\Part;
1919

2020
use PhpOffice\PhpWord\Exception\Exception;
21-
use PhpOffice\PhpWord\Writer\AbstractWriter;
21+
use PhpOffice\PhpWord\Writer\HTML;
2222
use Zend\Escaper\Escaper;
2323

2424
/**
@@ -27,7 +27,7 @@
2727
abstract class AbstractPart
2828
{
2929
/**
30-
* @var \PhpOffice\PhpWord\Writer\AbstractWriter
30+
* @var \PhpOffice\PhpWord\Writer\HTML
3131
*/
3232
private $parentWriter;
3333

@@ -47,17 +47,17 @@ public function __construct()
4747
abstract public function write();
4848

4949
/**
50-
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
50+
* @param \PhpOffice\PhpWord\Writer\HTML $writer
5151
*/
52-
public function setParentWriter(AbstractWriter $writer = null)
52+
public function setParentWriter(HTML $writer = null)
5353
{
5454
$this->parentWriter = $writer;
5555
}
5656

5757
/**
5858
* @throws \PhpOffice\PhpWord\Exception\Exception
5959
*
60-
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
60+
* @return \PhpOffice\PhpWord\Writer\HTML
6161
*/
6262
public function getParentWriter()
6363
{

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public function write()
6363
$css['display'] = $this->getValueIf($style->isHidden(), 'none');
6464

6565
$whitespace = $style->getHtmlWhiteSpace();
66-
$css['white-space'] = $this->getValueIf($whitespace, $whitespace);
66+
if ($whitespace) {
67+
$css['white-space'] = $whitespace;
68+
}
6769

6870
$spacing = $style->getSpacing();
6971
$css['letter-spacing'] = $this->getValueIf(!is_null($spacing), ($spacing / 20) . 'pt');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function write()
9494
$css['margin-right'] = ((string) $inches) . 'in';
9595
}
9696
}
97-
if ($style->getPageBreakBefore()) {
97+
if ($style->hasPageBreakBefore()) {
9898
$css['page-break-before'] = 'always';
9999
}
100100

0 commit comments

Comments
 (0)