diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0ada7257..62cfe1a9 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -72,6 +72,7 @@ This release marked heavy refactorings on internal code structure with the creat
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59
+- Refactor: Remove Style\Tabs
## 0.9.1 - 27 Mar 2014
diff --git a/phpmd.xml b/phpmd.xml
new file mode 100644
index 00000000..29542881
--- /dev/null
+++ b/phpmd.xml
@@ -0,0 +1,19 @@
+
+
+ PHPPowerPoint ruleset
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php
index 56984754..1fa729e1 100644
--- a/src/PhpWord/Element/Table.php
+++ b/src/PhpWord/Element/Table.php
@@ -73,8 +73,8 @@ class Table extends AbstractElement
*/
public function addCell($width = null, $style = null)
{
- $i = count($this->rows) - 1;
- $cell = $this->rows[$i]->addCell($width, $style);
+ $index = count($this->rows) - 1;
+ $cell = $this->rows[$index]->addCell($width, $style);
return $cell;
}
diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php
index a4cd4912..7d129b86 100755
--- a/src/PhpWord/Media.php
+++ b/src/PhpWord/Media.php
@@ -113,7 +113,7 @@ class Media
$mediaCount = 0;
if (array_key_exists($container, self::$elements)) {
- foreach (self::$elements[$container] as $mediaKey => $mediaData) {
+ foreach (self::$elements[$container] as $mediaData) {
if (!is_null($mediaType)) {
if ($mediaType == $mediaData['type']) {
$mediaCount++;
diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php
index 64a7f35a..015ccc86 100644
--- a/src/PhpWord/Style/Cell.php
+++ b/src/PhpWord/Style/Cell.php
@@ -229,12 +229,12 @@ class Cell extends AbstractStyle
*/
public function getBorderSize()
{
- $t = $this->getBorderTopSize();
- $l = $this->getBorderLeftSize();
- $r = $this->getBorderRightSize();
- $b = $this->getBorderBottomSize();
+ $top = $this->getBorderTopSize();
+ $left = $this->getBorderLeftSize();
+ $right = $this->getBorderRightSize();
+ $bottom = $this->getBorderBottomSize();
- return array($t, $l, $r, $b);
+ return array($top, $left, $right, $bottom);
}
/**
@@ -255,12 +255,12 @@ class Cell extends AbstractStyle
*/
public function getBorderColor()
{
- $t = $this->getBorderTopColor();
- $l = $this->getBorderLeftColor();
- $r = $this->getBorderRightColor();
- $b = $this->getBorderBottomColor();
+ $top = $this->getBorderTopColor();
+ $left = $this->getBorderLeftColor();
+ $right = $this->getBorderRightColor();
+ $bottom = $this->getBorderBottomColor();
- return array($t, $l, $r, $b);
+ return array($top, $left, $right, $bottom);
}
/**
diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php
index 57ad4405..9e5f58ed 100755
--- a/src/PhpWord/Style/Paragraph.php
+++ b/src/PhpWord/Style/Paragraph.php
@@ -57,9 +57,9 @@ class Paragraph extends AbstractStyle
/**
* Set of Custom Tab Stops
*
- * @var array
+ * @var \PhpOffice\PhpWord\Style\Tab[]
*/
- private $tabs;
+ private $tabs = array();
/**
* Indent by how much
@@ -172,7 +172,7 @@ class Paragraph extends AbstractStyle
* Set Paragraph Alignment
*
* @param string $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setAlign($pValue = null)
{
@@ -198,7 +198,7 @@ class Paragraph extends AbstractStyle
* Set Space before Paragraph
*
* @param int $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setSpaceBefore($pValue = null)
{
@@ -220,7 +220,7 @@ class Paragraph extends AbstractStyle
* Set Space after Paragraph
*
* @param int $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setSpaceAfter($pValue = null)
{
@@ -242,7 +242,7 @@ class Paragraph extends AbstractStyle
* Set Spacing between breaks
*
* @param int $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setSpacing($pValue = null)
{
@@ -264,7 +264,7 @@ class Paragraph extends AbstractStyle
* Set indentation
*
* @param int $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setIndent($pValue = null)
{
@@ -286,7 +286,7 @@ class Paragraph extends AbstractStyle
* Set hanging
*
* @param int $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setHanging($pValue = null)
{
@@ -297,7 +297,7 @@ class Paragraph extends AbstractStyle
/**
* Get tabs
*
- * @return \PhpOffice\PhpWord\Style\Tabs
+ * @return \PhpOffice\PhpWord\Style\Tab[]
*/
public function getTabs()
{
@@ -308,13 +308,14 @@ class Paragraph extends AbstractStyle
* Set tabs
*
* @param array $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setTabs($pValue = null)
{
if (is_array($pValue)) {
- $this->tabs = new Tabs($pValue);
+ $this->tabs = $pValue;
}
+
return $this;
}
@@ -332,7 +333,7 @@ class Paragraph extends AbstractStyle
* Set parent style ID
*
* @param string $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setBasedOn($pValue = 'Normal')
{
@@ -354,7 +355,7 @@ class Paragraph extends AbstractStyle
* Set style for next paragraph
*
* @param string $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setNext($pValue = null)
{
@@ -376,7 +377,7 @@ class Paragraph extends AbstractStyle
* Set keep paragraph with next paragraph setting
*
* @param bool $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setWidowControl($pValue = true)
{
@@ -401,7 +402,7 @@ class Paragraph extends AbstractStyle
* Set keep paragraph with next paragraph setting
*
* @param bool $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setKeepNext($pValue = false)
{
@@ -426,7 +427,7 @@ class Paragraph extends AbstractStyle
* Set keep all lines on one page setting
*
* @param bool $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setKeepLines($pValue = false)
{
@@ -451,7 +452,7 @@ class Paragraph extends AbstractStyle
* Set start paragraph on next page setting
*
* @param bool $pValue
- * @return \PhpOffice\PhpWord\Style\Paragraph
+ * @return self
*/
public function setPageBreakBefore($pValue = false)
{
diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php
index 717fdaf7..91ce6c4a 100644
--- a/src/PhpWord/Style/Section.php
+++ b/src/PhpWord/Style/Section.php
@@ -390,12 +390,12 @@ class Section extends AbstractStyle
*/
public function getBorderSize()
{
- $t = $this->getBorderTopSize();
- $l = $this->getBorderLeftSize();
- $r = $this->getBorderRightSize();
- $b = $this->getBorderBottomSize();
+ $top = $this->getBorderTopSize();
+ $left = $this->getBorderLeftSize();
+ $right = $this->getBorderRightSize();
+ $bottom = $this->getBorderBottomSize();
- return array($t, $l, $r, $b);
+ return array($top, $left, $right, $bottom);
}
/**
@@ -418,12 +418,12 @@ class Section extends AbstractStyle
*/
public function getBorderColor()
{
- $t = $this->getBorderTopColor();
- $l = $this->getBorderLeftColor();
- $r = $this->getBorderRightColor();
- $b = $this->getBorderBottomColor();
+ $top = $this->getBorderTopColor();
+ $left = $this->getBorderLeftColor();
+ $right = $this->getBorderRightColor();
+ $bottom = $this->getBorderBottomColor();
- return array($t, $l, $r, $b);
+ return array($top, $left, $right, $bottom);
}
/**
diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php
index e9c044f1..7d17b01c 100644
--- a/src/PhpWord/Style/Tab.php
+++ b/src/PhpWord/Style/Tab.php
@@ -90,21 +90,33 @@ class Tab extends AbstractStyle
}
/**
- * Creates the XML DOM for the instance of Tab.
+ * Get stop type
*
- * @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
+ * @return string
*/
- public function toXml(XMLWriter &$xmlWriter = null)
+ public function getStopType()
{
- if (isset($xmlWriter)) {
- $xmlWriter->startElement("w:tab");
- $xmlWriter->writeAttribute("w:val", $this->val);
- if (!is_null($this->leader)) {
- $xmlWriter->writeAttribute("w:leader", $this->leader);
- }
- $xmlWriter->writeAttribute("w:pos", $this->position);
- $xmlWriter->endElement();
- }
+ return $this->val;
+ }
+
+ /**
+ * Get leader
+ *
+ * @return string
+ */
+ public function getLeader()
+ {
+ return $this->leader;
+ }
+
+ /**
+ * Get position
+ *
+ * @return integer
+ */
+ public function getPosition()
+ {
+ return $this->position;
}
/**
diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php
index 000ecff7..51885c8b 100755
--- a/src/PhpWord/Style/Table.php
+++ b/src/PhpWord/Style/Table.php
@@ -247,14 +247,14 @@ class Table extends AbstractStyle
*/
public function getBorderSize()
{
- $t = $this->getBorderTopSize();
- $l = $this->getBorderLeftSize();
- $r = $this->getBorderRightSize();
- $b = $this->getBorderBottomSize();
- $h = $this->getBorderInsideHSize();
- $v = $this->getBorderInsideVSize();
+ $top = $this->getBorderTopSize();
+ $left = $this->getBorderLeftSize();
+ $right = $this->getBorderRightSize();
+ $bottom = $this->getBorderBottomSize();
+ $insideH = $this->getBorderInsideHSize();
+ $insideV = $this->getBorderInsideVSize();
- return array($t, $l, $r, $b, $h, $v);
+ return array($top, $left, $right, $bottom, $insideH, $insideV);
}
/**
@@ -278,14 +278,14 @@ class Table extends AbstractStyle
*/
public function getBorderColor()
{
- $t = $this->getBorderTopColor();
- $l = $this->getBorderLeftColor();
- $r = $this->getBorderRightColor();
- $b = $this->getBorderBottomColor();
- $h = $this->getBorderInsideHColor();
- $v = $this->getBorderInsideVColor();
+ $top = $this->getBorderTopColor();
+ $left = $this->getBorderLeftColor();
+ $right = $this->getBorderRightColor();
+ $bottom = $this->getBorderBottomColor();
+ $insideH = $this->getBorderInsideHColor();
+ $insideV = $this->getBorderInsideVColor();
- return array($t, $l, $r, $b, $h, $v);
+ return array($top, $left, $right, $bottom, $insideH, $insideV);
}
/**
diff --git a/src/PhpWord/Style/Tabs.php b/src/PhpWord/Style/Tabs.php
deleted file mode 100755
index 66137c0e..00000000
--- a/src/PhpWord/Style/Tabs.php
+++ /dev/null
@@ -1,51 +0,0 @@
-tabs = $tabs;
- }
-
- /**
- * Return XML
- *
- * @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
- */
- public function toXml(XMLWriter &$xmlWriter = null)
- {
- if (isset($xmlWriter)) {
- $xmlWriter->startElement("w:tabs");
- foreach ($this->tabs as &$tab) {
- $tab->toXml($xmlWriter);
- }
- $xmlWriter->endElement();
- }
- }
-}
diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php
index fd5e9af6..a8a221d7 100644
--- a/src/PhpWord/Template.php
+++ b/src/PhpWord/Template.php
@@ -75,16 +75,16 @@ class Template
$this->zipClass->open($this->tempFileName);
// Find and load headers and footers
- $i = 1;
- while ($this->zipClass->locateName($this->getHeaderName($i)) !== false) {
- $this->headerXMLs[$i] = $this->zipClass->getFromName($this->getHeaderName($i));
- $i++;
+ $index = 1;
+ while ($this->zipClass->locateName($this->getHeaderName($index)) !== false) {
+ $this->headerXMLs[$index] = $this->zipClass->getFromName($this->getHeaderName($index));
+ $index++;
}
- $i = 1;
- while ($this->zipClass->locateName($this->getFooterName($i)) !== false) {
- $this->footerXMLs[$i] = $this->zipClass->getFromName($this->getFooterName($i));
- $i++;
+ $index = 1;
+ while ($this->zipClass->locateName($this->getFooterName($index)) !== false) {
+ $this->footerXMLs[$index] = $this->zipClass->getFromName($this->getFooterName($index));
+ $index++;
}
$this->documentXML = $this->zipClass->getFromName('word/document.xml');
diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php
index a909cd26..0d713bc5 100644
--- a/src/PhpWord/Writer/AbstractWriter.php
+++ b/src/PhpWord/Writer/AbstractWriter.php
@@ -251,9 +251,9 @@ abstract class AbstractWriter implements WriterInterface
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
- $ro = new \ReflectionObject($objZip);
- $zipOverWrite = $ro->getConstant('OVERWRITE');
- $zipCreate = $ro->getConstant('CREATE');
+ $reflection = new \ReflectionObject($objZip);
+ $zipOverWrite = $reflection->getConstant('OVERWRITE');
+ $zipCreate = $reflection->getConstant('CREATE');
// Remove any existing file
if (file_exists($filename)) {
diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php
index 31a7ca61..f4e09fc9 100644
--- a/src/PhpWord/Writer/HTML.php
+++ b/src/PhpWord/Writer/HTML.php
@@ -69,9 +69,13 @@ class HTML extends AbstractWriter implements WriterInterface
{
if (!is_null($this->getPhpWord())) {
$this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/');
- $hFile = fopen($filename, 'w') or die("can't open file");
- fwrite($hFile, $this->writeDocument());
- fclose($hFile);
+ $hFile = fopen($filename, 'w');
+ if ($hFile !== false) {
+ fwrite($hFile, $this->writeDocument());
+ fclose($hFile);
+ } else {
+ throw new Exception("Can't open file");
+ }
$this->clearTempDir();
} else {
throw new Exception("No PHPWord assigned.");
@@ -739,9 +743,9 @@ class HTML extends AbstractWriter implements WriterInterface
$imageBinary = ob_get_contents();
ob_end_clean();
} else {
- if ($fp = fopen($actualSource, 'rb', false)) {
- $imageBinary = fread($fp, filesize($actualSource));
- fclose($fp);
+ if ($fileHandle = fopen($actualSource, 'rb', false)) {
+ $imageBinary = fread($fileHandle, filesize($actualSource));
+ fclose($fileHandle);
}
}
if (!is_null($imageBinary)) {
diff --git a/src/PhpWord/Writer/ODText/Base.php b/src/PhpWord/Writer/ODText/Base.php
index 24eab60c..d38aef23 100644
--- a/src/PhpWord/Writer/ODText/Base.php
+++ b/src/PhpWord/Writer/ODText/Base.php
@@ -65,7 +65,7 @@ class Base extends AbstractWriterPart
$styles = Style::getStyles();
$numFonts = 0;
if (count($styles) > 0) {
- foreach ($styles as $styleName => $style) {
+ foreach ($styles as $style) {
// Font
if ($style instanceof Font) {
$numFonts++;
diff --git a/src/PhpWord/Writer/ODText/Content.php b/src/PhpWord/Writer/ODText/Content.php
index 6b4d6dfa..fe4d18c7 100644
--- a/src/PhpWord/Writer/ODText/Content.php
+++ b/src/PhpWord/Writer/ODText/Content.php
@@ -187,7 +187,7 @@ class Content extends Base
if ($SfIsObject) {
// Don't never be the case, because I browse all sections for cleaning all styles not declared
- die('PhpWord : $SfIsObject wouldn\'t be an object');
+ throw new Exception('PhpWord : $SfIsObject wouldn\'t be an object');
} else {
if (!$withoutP) {
$xmlWriter->startElement('text:p'); // text:p
@@ -457,8 +457,8 @@ class Content extends Base
}
// Images
- $imageData = Media::getElements('section');
- foreach ($imageData as $imageId => $image) {
+ $images = Media::getElements('section');
+ foreach ($images as $image) {
if ($image['type'] == 'image') {
$xmlWriter->startElement('style:style');
$xmlWriter->writeAttribute('style:name', 'fr' . $image['rID']);
diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php
index 354e2ed1..860a29dc 100644
--- a/src/PhpWord/Writer/PDF/AbstractRenderer.php
+++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php
@@ -45,13 +45,6 @@ abstract class AbstractRenderer extends \PhpOffice\PhpWord\Writer\HTML
*/
protected $orientation = null;
- /**
- * Temporary storage for Save Array Return type
- *
- * @var string
- */
- private $saveArrayReturnType;
-
/**
* Paper Sizes xRef List
*
diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php
index 2452ca7f..ef965ea5 100755
--- a/src/PhpWord/Writer/RTF.php
+++ b/src/PhpWord/Writer/RTF.php
@@ -9,6 +9,8 @@
namespace PhpOffice\PhpWord\Writer;
+use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\TOC;
use PhpOffice\PhpWord\Element\Image;
use PhpOffice\PhpWord\Element\Link;
use PhpOffice\PhpWord\Element\ListItem;
@@ -20,11 +22,9 @@ use PhpOffice\PhpWord\Element\TextBreak;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\Title;
use PhpOffice\PhpWord\Exception\Exception;
-use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\Drawing;
-use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style;
-use PhpOffice\PhpWord\TOC;
+use PhpOffice\PhpWord\Style\Font;
/**
* RTF writer
@@ -75,10 +75,13 @@ class RTF extends AbstractWriter implements WriterInterface
if (!is_null($this->phpWord)) {
$pFilename = $this->getTempFile($pFilename);
- $hFile = fopen($pFilename, 'w') or die("can't open file");
- fwrite($hFile, $this->getData());
- fclose($hFile);
-
+ $hFile = fopen($pFilename, 'w');
+ if ($hFile !== false) {
+ fwrite($hFile, $this->getData());
+ fclose($hFile);
+ } else {
+ throw new Exception("Can't open file");
+ }
$this->cleanupTempFile();
} else {
throw new Exception("PhpWord object unassigned.");
@@ -160,7 +163,7 @@ class RTF extends AbstractWriter implements WriterInterface
// Browse styles
$styles = Style::getStyles();
if (count($styles) > 0) {
- foreach ($styles as $styleName => $style) {
+ foreach ($styles as $style) {
// Font
if ($style instanceof Font) {
if (in_array($style->getName(), $arrFonts) == false) {
@@ -212,7 +215,7 @@ class RTF extends AbstractWriter implements WriterInterface
// Browse styles
$styles = Style::getStyles();
if (count($styles) > 0) {
- foreach ($styles as $styleName => $style) {
+ foreach ($styles as $style) {
// Font
if ($style instanceof Font) {
$color = $style->getColor();
diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php
index b6403553..6db8bcfc 100755
--- a/src/PhpWord/Writer/Word2007.php
+++ b/src/PhpWord/Writer/Word2007.php
@@ -180,7 +180,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
$writeFunction = $elmType == 'header' ? 'writeHeader' : 'writeFooter';
$elmCount = ($section->getSectionId() - 1) * 3;
$elmObjects = $section->$getFunction();
- foreach ($elmObjects as $index => &$elmObject) {
+ foreach ($elmObjects as &$elmObject) {
$elmCount++;
$elmObject->setRelationId(++$rId);
$elmFile = "{$elmType}{$elmCount}.xml";
diff --git a/src/PhpWord/Writer/Word2007/Base.php b/src/PhpWord/Writer/Word2007/Base.php
index 897830ff..e491d55c 100644
--- a/src/PhpWord/Writer/Word2007/Base.php
+++ b/src/PhpWord/Writer/Word2007/Base.php
@@ -814,8 +814,18 @@ class Base extends AbstractWriterPart
}
// Tabs
- if (!is_null($tabs)) {
- $tabs->toXml($xmlWriter);
+ if (!empty($tabs)) {
+ $xmlWriter->startElement("w:tabs");
+ foreach ($tabs as $tab) {
+ $xmlWriter->startElement("w:tab");
+ $xmlWriter->writeAttribute("w:val", $tab->getStopType());
+ if (!is_null($tab->getLeader())) {
+ $xmlWriter->writeAttribute("w:leader", $tab->getLeader());
+ }
+ $xmlWriter->writeAttribute("w:pos", $tab->getPosition());
+ $xmlWriter->endElement();
+ }
+ $xmlWriter->endElement();
}
if (!$withoutPPR) {
diff --git a/src/PhpWord/Writer/Word2007/Rels.php b/src/PhpWord/Writer/Word2007/Rels.php
index 1d182b5d..58e510fd 100755
--- a/src/PhpWord/Writer/Word2007/Rels.php
+++ b/src/PhpWord/Writer/Word2007/Rels.php
@@ -80,9 +80,9 @@ class Rels extends AbstractWriterPart
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param null|array $xmlRels
* @param null|array $mediaRels
- * @param integer $id
+ * @param integer $relId
*/
- private function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $id = 1)
+ private function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $relId = 1)
{
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
$xmlWriter->startElement('Relationships');
@@ -91,7 +91,7 @@ class Rels extends AbstractWriterPart
// XML files relationships
if (is_array($xmlRels)) {
foreach ($xmlRels as $target => $type) {
- $this->writeRel($xmlWriter, $id++, $type, $target);
+ $this->writeRel($xmlWriter, $relId++, $type, $target);
}
}
@@ -105,7 +105,7 @@ class Rels extends AbstractWriterPart
$target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : '';
$target .= $mediaRel['target'];
$targetMode = ($type == 'hyperlink') ? 'External' : '';
- $this->writeRel($xmlWriter, $id++, "officeDocument/2006/relationships/{$type}", $target, $targetMode);
+ $this->writeRel($xmlWriter, $relId++, "officeDocument/2006/relationships/{$type}", $target, $targetMode);
}
}
@@ -119,19 +119,19 @@ class Rels extends AbstractWriterPart
*
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
- * @param int $id Relationship ID
+ * @param int $relId Relationship ID
* @param string $type Relationship type
* @param string $target Relationship target
* @param string $targetMode Relationship target mode
*/
- private function writeRel(XMLWriter $xmlWriter, $id, $type, $target, $targetMode = '')
+ private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')
{
if ($type != '' && $target != '') {
- if (strpos($id, 'rId') === false) {
- $id = 'rId' . $id;
+ if (strpos($relId, 'rId') === false) {
+ $relId = 'rId' . $relId;
}
$xmlWriter->startElement('Relationship');
- $xmlWriter->writeAttribute('Id', $id);
+ $xmlWriter->writeAttribute('Id', $relId);
$xmlWriter->writeAttribute('Type', self::RELS_BASE . $type);
$xmlWriter->writeAttribute('Target', $target);
if ($targetMode != '') {
diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php
index 413eb149..690e34e1 100644
--- a/tests/PhpWord/Tests/Style/ParagraphTest.php
+++ b/tests/PhpWord/Tests/Style/ParagraphTest.php
@@ -37,7 +37,6 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
$object = new Paragraph();
$attributes = array(
- 'tabs' => null,
'widowControl' => true,
'keepNext' => false,
'keepLines' => false,
@@ -96,7 +95,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
{
$object = new Paragraph();
$object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300)));
- $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs());
+ $this->assertEquals(2, count($object->getTabs()));
}
/**