Skip to content

Commit 04a62f3

Browse files
committed
QA: Code cleanup and some additional tests
1 parent 6ba6ed4 commit 04a62f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+234
-115
lines changed

src/PhpWord/DocumentProperties.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,9 @@ public function getCustomPropertyValue($propertyName)
416416
{
417417
if ($this->isCustomPropertySet($propertyName)) {
418418
return $this->customProperties[$propertyName]['value'];
419+
} else {
420+
return null;
419421
}
420-
421422
}
422423

423424
/**
@@ -430,8 +431,9 @@ public function getCustomPropertyType($propertyName)
430431
{
431432
if ($this->isCustomPropertySet($propertyName)) {
432433
return $this->customProperties[$propertyName]['type'];
434+
} else {
435+
return null;
433436
}
434-
435437
}
436438

437439
/**

src/PhpWord/Element/AbstractContainer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ public function addTextBox($style = null)
313313
*
314314
* @param string $method
315315
* @return bool
316+
* @throws \BadMethodCallException
316317
*/
317318
private function checkValidity($method)
318319
{
@@ -389,6 +390,7 @@ private function getMediaContainer()
389390
*
390391
* @param string $src
391392
* @param mixed $style
393+
* @return \PhpOffice\PhpWord\Element\Image
392394
* @deprecated 0.9.0
393395
* @codeCoverageIgnore
394396
*/
@@ -401,6 +403,7 @@ public function addMemoryImage($src, $style = null)
401403
* Create textrun element
402404
*
403405
* @param mixed $paragraphStyle
406+
* @return \PhpOffice\PhpWord\Element\TextRun
404407
* @deprecated 0.10.0
405408
* @codeCoverageIgnore
406409
*/
@@ -413,6 +416,7 @@ public function createTextRun($paragraphStyle = null)
413416
* Create footnote element
414417
*
415418
* @param mixed $paragraphStyle
419+
* @return \PhpOffice\PhpWord\Element\Footnote
416420
* @deprecated 0.10.0
417421
* @codeCoverageIgnore
418422
*/

src/PhpWord/Element/AbstractElement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public function isInSection()
220220
* @param mixed $styleObject Style object
221221
* @param mixed $styleValue Style value
222222
* @param bool $returnObject Always return object
223+
* @return mixed
223224
*/
224225
protected function setStyle($styleObject, $styleValue = null, $returnObject = false)
225226
{

src/PhpWord/Element/Image.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ public function setMediaIndex($value)
283283
* Check memory image, supported type, image functions, and proportional width/height
284284
*
285285
* @param string $source
286+
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
287+
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
286288
*/
287289
private function checkImage($source)
288290
{

src/PhpWord/Element/Object.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Object extends AbstractElement
5858
*
5959
* @param string $source
6060
* @param mixed $style
61+
* @throws \PhpOffice\PhpWord\Exception\InvalidObjectException
6162
*/
6263
public function __construct($source, $style = null)
6364
{

src/PhpWord/Element/PreserveText.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PreserveText extends AbstractElement
5454
* @param string $text
5555
* @param mixed $fontStyle
5656
* @param mixed $paragraphStyle
57-
* @return $this
57+
* @return self
5858
*/
5959
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
6060
{

src/PhpWord/Element/Section.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
namespace PhpOffice\PhpWord\Element;
1919

2020
use PhpOffice\PhpWord\Exception\Exception;
21-
use PhpOffice\PhpWord\PhpWord;
2221
use PhpOffice\PhpWord\Style\Section as SectionSettings;
2322

2423
/**

src/PhpWord/PhpWord.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,13 @@ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
301301
/**
302302
* Adds a heading style definition to styles.xml
303303
*
304-
* @param int $titleCount
304+
* @param int $depth
305305
* @param mixed $fontStyle
306306
* @param mixed $paragraphStyle
307307
*/
308-
public function addTitleStyle($titleCount, $fontStyle, $paragraphStyle = null)
308+
public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
309309
{
310-
Style::addTitleStyle($titleCount, $fontStyle, $paragraphStyle);
310+
Style::addTitleStyle($depth, $fontStyle, $paragraphStyle);
311311
}
312312

313313
/**

src/PhpWord/Reader/ODText/AbstractPart.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ abstract class AbstractPart extends \PhpOffice\PhpWord\Reader\Word2007\AbstractP
2727
/**
2828
* Read w:r (override)
2929
*
30+
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
31+
* @param \DOMElement $domNode
3032
* @param mixed $parent
3133
* @param string $docPart
3234
* @param mixed $paragraphStyle

src/PhpWord/Reader/Word2007/AbstractPart.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent,
138138
/**
139139
* Read w:pPr
140140
*
141+
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
142+
* @param \DOMElement $domNode
141143
* @return array|null
142144
*/
143145
protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode)
144146
{
145147
if (!$xmlReader->elementExists('w:pPr', $domNode)) {
146-
return;
148+
return '';
147149
}
148150

149151
$style = array();
@@ -200,19 +202,21 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode
200202
/**
201203
* Read w:rPr
202204
*
205+
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
206+
* @param \DOMElement $domNode
203207
* @return array|null
204208
*/
205209
protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
206210
{
207211
if (is_null($domNode)) {
208-
return;
212+
return null;
209213
}
210214
// Hyperlink has an extra w:r child
211215
if ($domNode->nodeName == 'w:hyperlink') {
212216
$domNode = $xmlReader->getElement('w:r', $domNode);
213217
}
214218
if (!$xmlReader->elementExists('w:rPr', $domNode)) {
215-
return;
219+
return null;
216220
}
217221

218222
$style = array();
@@ -272,6 +276,8 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
272276
/**
273277
* Read w:tblPr
274278
*
279+
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
280+
* @param \DOMElement $domNode
275281
* @return string|array|null
276282
* @todo Capture w:tblStylePr w:type="firstRow"
277283
*/

0 commit comments

Comments
 (0)