Skip to content

Commit 0060e43

Browse files
committed
PHPMD fixes and remove Style\Tabs (not needed)
1 parent f829559 commit 0060e43

File tree

21 files changed

+159
-168
lines changed

21 files changed

+159
-168
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ This release marked heavy refactorings on internal code structure with the creat
7272
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
7373
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
7474
- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59
75+
- Refactor: Remove Style\Tabs
7576

7677
## 0.9.1 - 27 Mar 2014
7778

phpmd.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHPPowerPoint mess detector ruleset"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
<description>PHPPowerPoint ruleset</description>
8+
<rule ref="rulesets/unusedcode.xml" />
9+
<rule ref="rulesets/design.xml" />
10+
<rule ref="rulesets/naming.xml/LongVariable">
11+
<properties>
12+
<property name="maximum" value="30" />
13+
</properties>
14+
</rule>
15+
<rule ref="rulesets/naming.xml/ShortVariable" />
16+
<rule ref="rulesets/naming.xml/ShortMethodName" />
17+
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
18+
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
19+
</ruleset>

src/PhpWord/Element/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public function addRow($height = null, $style = null)
7373
*/
7474
public function addCell($width = null, $style = null)
7575
{
76-
$i = count($this->rows) - 1;
77-
$cell = $this->rows[$i]->addCell($width, $style);
76+
$index = count($this->rows) - 1;
77+
$cell = $this->rows[$index]->addCell($width, $style);
7878
return $cell;
7979
}
8080

src/PhpWord/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function countElements($container, $mediaType = null)
113113
$mediaCount = 0;
114114

115115
if (array_key_exists($container, self::$elements)) {
116-
foreach (self::$elements[$container] as $mediaKey => $mediaData) {
116+
foreach (self::$elements[$container] as $mediaData) {
117117
if (!is_null($mediaType)) {
118118
if ($mediaType == $mediaData['type']) {
119119
$mediaCount++;

src/PhpWord/Style/Cell.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ public function setBorderSize($pValue = null)
229229
*/
230230
public function getBorderSize()
231231
{
232-
$t = $this->getBorderTopSize();
233-
$l = $this->getBorderLeftSize();
234-
$r = $this->getBorderRightSize();
235-
$b = $this->getBorderBottomSize();
232+
$top = $this->getBorderTopSize();
233+
$left = $this->getBorderLeftSize();
234+
$right = $this->getBorderRightSize();
235+
$bottom = $this->getBorderBottomSize();
236236

237-
return array($t, $l, $r, $b);
237+
return array($top, $left, $right, $bottom);
238238
}
239239

240240
/**
@@ -255,12 +255,12 @@ public function setBorderColor($pValue = null)
255255
*/
256256
public function getBorderColor()
257257
{
258-
$t = $this->getBorderTopColor();
259-
$l = $this->getBorderLeftColor();
260-
$r = $this->getBorderRightColor();
261-
$b = $this->getBorderBottomColor();
258+
$top = $this->getBorderTopColor();
259+
$left = $this->getBorderLeftColor();
260+
$right = $this->getBorderRightColor();
261+
$bottom = $this->getBorderBottomColor();
262262

263-
return array($t, $l, $r, $b);
263+
return array($top, $left, $right, $bottom);
264264
}
265265

266266
/**

src/PhpWord/Style/Paragraph.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class Paragraph extends AbstractStyle
5757
/**
5858
* Set of Custom Tab Stops
5959
*
60-
* @var array
60+
* @var \PhpOffice\PhpWord\Style\Tab[]
6161
*/
62-
private $tabs;
62+
private $tabs = array();
6363

6464
/**
6565
* Indent by how much
@@ -172,7 +172,7 @@ public function getAlign()
172172
* Set Paragraph Alignment
173173
*
174174
* @param string $pValue
175-
* @return \PhpOffice\PhpWord\Style\Paragraph
175+
* @return self
176176
*/
177177
public function setAlign($pValue = null)
178178
{
@@ -198,7 +198,7 @@ public function getSpaceBefore()
198198
* Set Space before Paragraph
199199
*
200200
* @param int $pValue
201-
* @return \PhpOffice\PhpWord\Style\Paragraph
201+
* @return self
202202
*/
203203
public function setSpaceBefore($pValue = null)
204204
{
@@ -220,7 +220,7 @@ public function getSpaceAfter()
220220
* Set Space after Paragraph
221221
*
222222
* @param int $pValue
223-
* @return \PhpOffice\PhpWord\Style\Paragraph
223+
* @return self
224224
*/
225225
public function setSpaceAfter($pValue = null)
226226
{
@@ -242,7 +242,7 @@ public function getSpacing()
242242
* Set Spacing between breaks
243243
*
244244
* @param int $pValue
245-
* @return \PhpOffice\PhpWord\Style\Paragraph
245+
* @return self
246246
*/
247247
public function setSpacing($pValue = null)
248248
{
@@ -264,7 +264,7 @@ public function getIndent()
264264
* Set indentation
265265
*
266266
* @param int $pValue
267-
* @return \PhpOffice\PhpWord\Style\Paragraph
267+
* @return self
268268
*/
269269
public function setIndent($pValue = null)
270270
{
@@ -286,7 +286,7 @@ public function getHanging()
286286
* Set hanging
287287
*
288288
* @param int $pValue
289-
* @return \PhpOffice\PhpWord\Style\Paragraph
289+
* @return self
290290
*/
291291
public function setHanging($pValue = null)
292292
{
@@ -297,7 +297,7 @@ public function setHanging($pValue = null)
297297
/**
298298
* Get tabs
299299
*
300-
* @return \PhpOffice\PhpWord\Style\Tabs
300+
* @return \PhpOffice\PhpWord\Style\Tab[]
301301
*/
302302
public function getTabs()
303303
{
@@ -308,13 +308,14 @@ public function getTabs()
308308
* Set tabs
309309
*
310310
* @param array $pValue
311-
* @return \PhpOffice\PhpWord\Style\Paragraph
311+
* @return self
312312
*/
313313
public function setTabs($pValue = null)
314314
{
315315
if (is_array($pValue)) {
316-
$this->tabs = new Tabs($pValue);
316+
$this->tabs = $pValue;
317317
}
318+
318319
return $this;
319320
}
320321

@@ -332,7 +333,7 @@ public function getBasedOn()
332333
* Set parent style ID
333334
*
334335
* @param string $pValue
335-
* @return \PhpOffice\PhpWord\Style\Paragraph
336+
* @return self
336337
*/
337338
public function setBasedOn($pValue = 'Normal')
338339
{
@@ -354,7 +355,7 @@ public function getNext()
354355
* Set style for next paragraph
355356
*
356357
* @param string $pValue
357-
* @return \PhpOffice\PhpWord\Style\Paragraph
358+
* @return self
358359
*/
359360
public function setNext($pValue = null)
360361
{
@@ -376,7 +377,7 @@ public function getWidowControl()
376377
* Set keep paragraph with next paragraph setting
377378
*
378379
* @param bool $pValue
379-
* @return \PhpOffice\PhpWord\Style\Paragraph
380+
* @return self
380381
*/
381382
public function setWidowControl($pValue = true)
382383
{
@@ -401,7 +402,7 @@ public function getKeepNext()
401402
* Set keep paragraph with next paragraph setting
402403
*
403404
* @param bool $pValue
404-
* @return \PhpOffice\PhpWord\Style\Paragraph
405+
* @return self
405406
*/
406407
public function setKeepNext($pValue = false)
407408
{
@@ -426,7 +427,7 @@ public function getKeepLines()
426427
* Set keep all lines on one page setting
427428
*
428429
* @param bool $pValue
429-
* @return \PhpOffice\PhpWord\Style\Paragraph
430+
* @return self
430431
*/
431432
public function setKeepLines($pValue = false)
432433
{
@@ -451,7 +452,7 @@ public function getPageBreakBefore()
451452
* Set start paragraph on next page setting
452453
*
453454
* @param bool $pValue
454-
* @return \PhpOffice\PhpWord\Style\Paragraph
455+
* @return self
455456
*/
456457
public function setPageBreakBefore($pValue = false)
457458
{

src/PhpWord/Style/Section.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,12 @@ public function setBorderSize($pValue = null)
390390
*/
391391
public function getBorderSize()
392392
{
393-
$t = $this->getBorderTopSize();
394-
$l = $this->getBorderLeftSize();
395-
$r = $this->getBorderRightSize();
396-
$b = $this->getBorderBottomSize();
393+
$top = $this->getBorderTopSize();
394+
$left = $this->getBorderLeftSize();
395+
$right = $this->getBorderRightSize();
396+
$bottom = $this->getBorderBottomSize();
397397

398-
return array($t, $l, $r, $b);
398+
return array($top, $left, $right, $bottom);
399399
}
400400

401401
/**
@@ -418,12 +418,12 @@ public function setBorderColor($pValue = null)
418418
*/
419419
public function getBorderColor()
420420
{
421-
$t = $this->getBorderTopColor();
422-
$l = $this->getBorderLeftColor();
423-
$r = $this->getBorderRightColor();
424-
$b = $this->getBorderBottomColor();
421+
$top = $this->getBorderTopColor();
422+
$left = $this->getBorderLeftColor();
423+
$right = $this->getBorderRightColor();
424+
$bottom = $this->getBorderBottomColor();
425425

426-
return array($t, $l, $r, $b);
426+
return array($top, $left, $right, $bottom);
427427
}
428428

429429
/**

src/PhpWord/Style/Tab.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,33 @@ public function __construct($val = null, $position = 0, $leader = null)
9090
}
9191

9292
/**
93-
* Creates the XML DOM for the instance of Tab.
93+
* Get stop type
9494
*
95-
* @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
95+
* @return string
9696
*/
97-
public function toXml(XMLWriter &$xmlWriter = null)
97+
public function getStopType()
9898
{
99-
if (isset($xmlWriter)) {
100-
$xmlWriter->startElement("w:tab");
101-
$xmlWriter->writeAttribute("w:val", $this->val);
102-
if (!is_null($this->leader)) {
103-
$xmlWriter->writeAttribute("w:leader", $this->leader);
104-
}
105-
$xmlWriter->writeAttribute("w:pos", $this->position);
106-
$xmlWriter->endElement();
107-
}
99+
return $this->val;
100+
}
101+
102+
/**
103+
* Get leader
104+
*
105+
* @return string
106+
*/
107+
public function getLeader()
108+
{
109+
return $this->leader;
110+
}
111+
112+
/**
113+
* Get position
114+
*
115+
* @return integer
116+
*/
117+
public function getPosition()
118+
{
119+
return $this->position;
108120
}
109121

110122
/**

src/PhpWord/Style/Table.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ public function setBorderSize($pValue = null)
247247
*/
248248
public function getBorderSize()
249249
{
250-
$t = $this->getBorderTopSize();
251-
$l = $this->getBorderLeftSize();
252-
$r = $this->getBorderRightSize();
253-
$b = $this->getBorderBottomSize();
254-
$h = $this->getBorderInsideHSize();
255-
$v = $this->getBorderInsideVSize();
250+
$top = $this->getBorderTopSize();
251+
$left = $this->getBorderLeftSize();
252+
$right = $this->getBorderRightSize();
253+
$bottom = $this->getBorderBottomSize();
254+
$insideH = $this->getBorderInsideHSize();
255+
$insideV = $this->getBorderInsideVSize();
256256

257-
return array($t, $l, $r, $b, $h, $v);
257+
return array($top, $left, $right, $bottom, $insideH, $insideV);
258258
}
259259

260260
/**
@@ -278,14 +278,14 @@ public function setBorderColor($pValue = null)
278278
*/
279279
public function getBorderColor()
280280
{
281-
$t = $this->getBorderTopColor();
282-
$l = $this->getBorderLeftColor();
283-
$r = $this->getBorderRightColor();
284-
$b = $this->getBorderBottomColor();
285-
$h = $this->getBorderInsideHColor();
286-
$v = $this->getBorderInsideVColor();
281+
$top = $this->getBorderTopColor();
282+
$left = $this->getBorderLeftColor();
283+
$right = $this->getBorderRightColor();
284+
$bottom = $this->getBorderBottomColor();
285+
$insideH = $this->getBorderInsideHColor();
286+
$insideV = $this->getBorderInsideVColor();
287287

288-
return array($t, $l, $r, $b, $h, $v);
288+
return array($top, $left, $right, $bottom, $insideH, $insideV);
289289
}
290290

291291
/**

0 commit comments

Comments
 (0)