Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit 3290721

Browse files
committed
fix phpstan issues
1 parent adc1428 commit 3290721

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
includes:
22
- vendor/phpstan/phpstan/conf/config.level1.neon
33
parameters:
4-
memory-limit: 200000
4+
memory-limit: 20000000
55
autoload_directories:
66
- tests
77
autoload_files:

src/PhpWord/Element/Title.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ class Title extends AbstractElement
6161
*/
6262
public function __construct($text, $depth = 1)
6363
{
64-
if (isset($text)) {
65-
if (is_string($text)) {
66-
$this->text = CommonText::toUTF8($text);
67-
} elseif ($text instanceof TextRun) {
68-
$this->text = $text;
69-
} else {
70-
throw new \InvalidArgumentException('Invalid text, should be a string or a TextRun');
71-
}
64+
if (is_string($text)) {
65+
$this->text = CommonText::toUTF8($text);
66+
} elseif ($text instanceof TextRun) {
67+
$this->text = $text;
68+
} else {
69+
throw new \InvalidArgumentException('Invalid text, should be a string or a TextRun');
7270
}
7371

7472
$this->depth = $depth;

src/PhpWord/Shared/Html.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit
7575
$dom = new \DOMDocument();
7676
$dom->preserveWhiteSpace = $preserveWhiteSpace;
7777
$dom->loadXML($html);
78-
self::$xpath = new \DOMXpath($dom);
78+
self::$xpath = new \DOMXPath($dom);
7979
$node = $dom->getElementsByTagName('body');
8080

8181
self::parseNode($node->item(0), $element);

src/PhpWord/Writer/Word2007/Element/Title.php

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function write()
4747
$xmlWriter->endElement();
4848
}
4949

50+
$bookmarkRId = null;
5051
if ($element->getDepth() !== 0) {
5152
$rId = $element->getRelationId();
5253
$bookmarkRId = $element->getPhpWord()->addBookmark();

src/PhpWord/Writer/Word2007/Part/Chart.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ private function writeAxis(XMLWriter $xmlWriter, $type)
330330
$valueAxisTitle = $style->getValueAxisTitle();
331331

332332
if ($axisType == 'c:catAx') {
333-
if (isset($categoryAxisTitle)) {
333+
if (!is_null($categoryAxisTitle)) {
334334
$this->writeAxisTitle($xmlWriter, $categoryAxisTitle);
335335
}
336336
} elseif ($axisType == 'c:valAx') {
337-
if (isset($valueAxisTitle)) {
337+
if (!is_null($valueAxisTitle)) {
338338
$this->writeAxisTitle($xmlWriter, $valueAxisTitle);
339339
}
340340
}

tests/PhpWord/Writer/HTML/ElementTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testWriteTrackChanges()
7070
$text2->setTrackChange(new TrackChange(TrackChange::DELETED, 'another author', new \DateTime()));
7171

7272
$dom = $this->getAsHTML($phpWord);
73-
$xpath = new \DOMXpath($dom);
73+
$xpath = new \DOMXPath($dom);
7474

7575
$this->assertTrue($xpath->query('/html/body/p[1]/ins')->length == 1);
7676
$this->assertTrue($xpath->query('/html/body/p[2]/del')->length == 1);
@@ -94,7 +94,7 @@ public function testWriteColSpan()
9494
$cell22->addText('second cell');
9595

9696
$dom = $this->getAsHTML($phpWord);
97-
$xpath = new \DOMXpath($dom);
97+
$xpath = new \DOMXPath($dom);
9898

9999
$this->assertTrue($xpath->query('/html/body/table/tr[1]/td')->length == 1);
100100
$this->assertEquals('2', $xpath->query('/html/body/table/tr/td[1]')->item(0)->attributes->getNamedItem('colspan')->textContent);
@@ -123,7 +123,7 @@ public function testWriteRowSpan()
123123
$row3->addCell(500)->addText('third cell being spanned');
124124

125125
$dom = $this->getAsHTML($phpWord);
126-
$xpath = new \DOMXpath($dom);
126+
$xpath = new \DOMXPath($dom);
127127

128128
$this->assertTrue($xpath->query('/html/body/table/tr[1]/td')->length == 2);
129129
$this->assertEquals('3', $xpath->query('/html/body/table/tr[1]/td[1]')->item(0)->attributes->getNamedItem('rowspan')->textContent);

tests/PhpWord/_includes/XmlDocument.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class XmlDocument
3737
private $dom;
3838

3939
/**
40-
* DOMXpath object
40+
* DOMXPath object
4141
*
42-
* @var \DOMXpath
42+
* @var \DOMXPath
4343
*/
4444
private $xpath;
4545

@@ -98,7 +98,7 @@ public function getNodeList($path, $file = 'word/document.xml')
9898
}
9999

100100
if (null === $this->xpath) {
101-
$this->xpath = new \DOMXpath($this->dom);
101+
$this->xpath = new \DOMXPath($this->dom);
102102
$this->xpath->registerNamespace('w14', 'http://schemas.microsoft.com/office/word/2010/wordml');
103103
}
104104

0 commit comments

Comments
 (0)