Skip to content

Commit

Permalink
fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
troosan committed Jul 14, 2018
1 parent adc1428 commit 3290721
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- vendor/phpstan/phpstan/conf/config.level1.neon
parameters:
memory-limit: 200000
memory-limit: 20000000
autoload_directories:
- tests
autoload_files:
Expand Down
14 changes: 6 additions & 8 deletions src/PhpWord/Element/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ class Title extends AbstractElement
*/
public function __construct($text, $depth = 1)
{
if (isset($text)) {
if (is_string($text)) {
$this->text = CommonText::toUTF8($text);
} elseif ($text instanceof TextRun) {
$this->text = $text;
} else {
throw new \InvalidArgumentException('Invalid text, should be a string or a TextRun');
}
if (is_string($text)) {
$this->text = CommonText::toUTF8($text);
} elseif ($text instanceof TextRun) {
$this->text = $text;
} else {
throw new \InvalidArgumentException('Invalid text, should be a string or a TextRun');
}

$this->depth = $depth;
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Shared/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit
$dom = new \DOMDocument();
$dom->preserveWhiteSpace = $preserveWhiteSpace;
$dom->loadXML($html);
self::$xpath = new \DOMXpath($dom);
self::$xpath = new \DOMXPath($dom);
$node = $dom->getElementsByTagName('body');

self::parseNode($node->item(0), $element);
Expand Down
1 change: 1 addition & 0 deletions src/PhpWord/Writer/Word2007/Element/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function write()
$xmlWriter->endElement();
}

$bookmarkRId = null;
if ($element->getDepth() !== 0) {
$rId = $element->getRelationId();
$bookmarkRId = $element->getPhpWord()->addBookmark();
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Writer/Word2007/Part/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ private function writeAxis(XMLWriter $xmlWriter, $type)
$valueAxisTitle = $style->getValueAxisTitle();

if ($axisType == 'c:catAx') {
if (isset($categoryAxisTitle)) {
if (!is_null($categoryAxisTitle)) {
$this->writeAxisTitle($xmlWriter, $categoryAxisTitle);
}
} elseif ($axisType == 'c:valAx') {
if (isset($valueAxisTitle)) {
if (!is_null($valueAxisTitle)) {
$this->writeAxisTitle($xmlWriter, $valueAxisTitle);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/PhpWord/Writer/HTML/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testWriteTrackChanges()
$text2->setTrackChange(new TrackChange(TrackChange::DELETED, 'another author', new \DateTime()));

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

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

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

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

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

$this->assertTrue($xpath->query('/html/body/table/tr[1]/td')->length == 2);
$this->assertEquals('3', $xpath->query('/html/body/table/tr[1]/td[1]')->item(0)->attributes->getNamedItem('rowspan')->textContent);
Expand Down
6 changes: 3 additions & 3 deletions tests/PhpWord/_includes/XmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class XmlDocument
private $dom;

/**
* DOMXpath object
* DOMXPath object
*
* @var \DOMXpath
* @var \DOMXPath
*/
private $xpath;

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

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

Expand Down

0 comments on commit 3290721

Please sign in to comment.