Skip to content

Commit 27fa3ba

Browse files
committed
Remove fontStyle parameter from ListItemRun and various small fixes
1 parent e40b377 commit 27fa3ba

File tree

13 files changed

+184
-225
lines changed

13 files changed

+184
-225
lines changed

.scrutinizer.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ tools:
99
enabled: true
1010
config:
1111
standard: PSR2
12-
php_cpd: true
1312
php_mess_detector:
1413
enabled: true
1514
config:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r
1818
- RTF: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158
1919
- Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237
2020
- RTF: Ability to add links and page breaks in RTF - @ivanlanin GH-196
21+
- ListItemRun: Remove fontStyle parameter because ListItemRun is inherited from TextRun and TextRun doesn't have fontStyle - @ivanlanin
2122

2223
### Bugfixes
2324

src/PhpWord/Element/AbstractContainer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,13 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n
213213
* Add listitemrun element
214214
*
215215
* @param int $depth
216-
* @param mixed $fontStyle
217216
* @param mixed $listStyle
218217
* @param mixed $paragraphStyle
219218
* @return \PhpOffice\PhpWord\Element\ListItemRun
220219
*/
221-
public function addListItemRun($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
220+
public function addListItemRun($depth = 0, $listStyle = null, $paragraphStyle = null)
222221
{
223-
return $this->addElement('ListItemRun', $depth, $fontStyle, $listStyle, $paragraphStyle);
222+
return $this->addElement('ListItemRun', $depth, $listStyle, $paragraphStyle);
224223
}
225224

226225
/**

src/PhpWord/Element/ListItemRun.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ class ListItemRun extends TextRun
4848
* Create a new ListItem
4949
*
5050
* @param int $depth
51-
* @param mixed $fontStyle
5251
* @param array|string|null $listStyle
5352
* @param mixed $paragraphStyle
5453
*/
55-
public function __construct($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
54+
public function __construct($depth = 0, $listStyle = null, $paragraphStyle = null)
5655
{
5756
$this->depth = $depth;
5857

src/PhpWord/Element/Title.php

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ class Title extends AbstractElement
4646
*/
4747
private $style;
4848

49-
/**
50-
* Title anchor
51-
*
52-
* @var string
53-
* @deprecated 0.10.0
54-
*/
55-
private $anchor;
56-
5749
/**
5850
* Create a new Title Element
5951
*
@@ -101,52 +93,4 @@ public function getStyle()
10193
{
10294
return $this->style;
10395
}
104-
105-
/**
106-
* Set Anchor
107-
*
108-
* @param string $anchor
109-
* @deprecated 0.10.0
110-
* @codeCoverageIgnore
111-
*/
112-
public function setAnchor($anchor)
113-
{
114-
$this->anchor = $anchor;
115-
}
116-
117-
/**
118-
* Get Anchor
119-
*
120-
* @return string
121-
* @deprecated 0.10.0
122-
* @codeCoverageIgnore
123-
*/
124-
public function getAnchor()
125-
{
126-
return '_Toc' . (252634154 + $this->getRelationId());
127-
}
128-
129-
/**
130-
* Set Bookmark ID
131-
*
132-
* @param int $value
133-
* @deprecated 0.11.0
134-
* @codeCoverageIgnore
135-
*/
136-
public function setBookmarkId($value)
137-
{
138-
$this->setRelationId($value);
139-
}
140-
141-
/**
142-
* Get bookmark ID
143-
*
144-
* @return int
145-
* @deprecated 0.11.0
146-
* @codeCoverageIgnore
147-
*/
148-
public function getBookmarkId()
149-
{
150-
return $this->getRelationId();
151-
}
15296
}

src/PhpWord/Style/Border.php

Lines changed: 58 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,6 @@ class Border extends AbstractStyle
7878
*/
7979
protected $borderBottomColor;
8080

81-
/**
82-
* Set border size
83-
*
84-
* @param int|float $value
85-
* @return self
86-
*/
87-
public function setBorderSize($value = null)
88-
{
89-
$this->setBorderTopSize($value);
90-
$this->setBorderLeftSize($value);
91-
$this->setBorderRightSize($value);
92-
$this->setBorderBottomSize($value);
93-
94-
return $this;
95-
}
96-
9781
/**
9882
* Get border size
9983
*
@@ -110,17 +94,17 @@ public function getBorderSize()
11094
}
11195

11296
/**
113-
* Set border color
97+
* Set border size
11498
*
115-
* @param string $value
99+
* @param int|float $value
116100
* @return self
117101
*/
118-
public function setBorderColor($value = null)
102+
public function setBorderSize($value = null)
119103
{
120-
$this->setBorderTopColor($value);
121-
$this->setBorderLeftColor($value);
122-
$this->setBorderRightColor($value);
123-
$this->setBorderBottomColor($value);
104+
$this->setBorderTopSize($value);
105+
$this->setBorderLeftSize($value);
106+
$this->setBorderRightSize($value);
107+
$this->setBorderBottomSize($value);
124108

125109
return $this;
126110
}
@@ -141,14 +125,17 @@ public function getBorderColor()
141125
}
142126

143127
/**
144-
* Set border top size
128+
* Set border color
145129
*
146-
* @param int|float $value
130+
* @param string $value
147131
* @return self
148132
*/
149-
public function setBorderTopSize($value = null)
133+
public function setBorderColor($value = null)
150134
{
151-
$this->borderTopSize = $value;
135+
$this->setBorderTopColor($value);
136+
$this->setBorderLeftColor($value);
137+
$this->setBorderRightColor($value);
138+
$this->setBorderBottomColor($value);
152139

153140
return $this;
154141
}
@@ -164,14 +151,14 @@ public function getBorderTopSize()
164151
}
165152

166153
/**
167-
* Set border top color
154+
* Set border top size
168155
*
169-
* @param string $value
156+
* @param int|float $value
170157
* @return self
171158
*/
172-
public function setBorderTopColor($value = null)
159+
public function setBorderTopSize($value = null)
173160
{
174-
$this->borderTopColor = $value;
161+
$this->borderTopSize = $this->setNumericVal($value, $this->borderTopSize);
175162

176163
return $this;
177164
}
@@ -187,14 +174,14 @@ public function getBorderTopColor()
187174
}
188175

189176
/**
190-
* Set border left size
177+
* Set border top color
191178
*
192-
* @param int|float $value
179+
* @param string $value
193180
* @return self
194181
*/
195-
public function setBorderLeftSize($value = null)
182+
public function setBorderTopColor($value = null)
196183
{
197-
$this->borderLeftSize = $value;
184+
$this->borderTopColor = $value;
198185

199186
return $this;
200187
}
@@ -210,14 +197,14 @@ public function getBorderLeftSize()
210197
}
211198

212199
/**
213-
* Set border left color
200+
* Set border left size
214201
*
215-
* @param string $value
202+
* @param int|float $value
216203
* @return self
217204
*/
218-
public function setBorderLeftColor($value = null)
205+
public function setBorderLeftSize($value = null)
219206
{
220-
$this->borderLeftColor = $value;
207+
$this->borderLeftSize = $this->setNumericVal($value, $this->borderLeftSize);
221208

222209
return $this;
223210
}
@@ -233,14 +220,14 @@ public function getBorderLeftColor()
233220
}
234221

235222
/**
236-
* Set border right size
223+
* Set border left color
237224
*
238-
* @param int|float $value
225+
* @param string $value
239226
* @return self
240227
*/
241-
public function setBorderRightSize($value = null)
228+
public function setBorderLeftColor($value = null)
242229
{
243-
$this->borderRightSize = $value;
230+
$this->borderLeftColor = $value;
244231

245232
return $this;
246233
}
@@ -256,14 +243,14 @@ public function getBorderRightSize()
256243
}
257244

258245
/**
259-
* Set border right color
246+
* Set border right size
260247
*
261-
* @param string $value
248+
* @param int|float $value
262249
* @return self
263250
*/
264-
public function setBorderRightColor($value = null)
251+
public function setBorderRightSize($value = null)
265252
{
266-
$this->borderRightColor = $value;
253+
$this->borderRightSize = $this->setNumericVal($value, $this->borderRightSize);
267254

268255
return $this;
269256
}
@@ -279,14 +266,14 @@ public function getBorderRightColor()
279266
}
280267

281268
/**
282-
* Set border bottom size
269+
* Set border right color
283270
*
284-
* @param int|float $value
271+
* @param string $value
285272
* @return self
286273
*/
287-
public function setBorderBottomSize($value = null)
274+
public function setBorderRightColor($value = null)
288275
{
289-
$this->borderBottomSize = $value;
276+
$this->borderRightColor = $value;
290277

291278
return $this;
292279
}
@@ -302,14 +289,14 @@ public function getBorderBottomSize()
302289
}
303290

304291
/**
305-
* Set border bottom color
292+
* Set border bottom size
306293
*
307-
* @param string $value
294+
* @param int|float $value
308295
* @return self
309296
*/
310-
public function setBorderBottomColor($value = null)
297+
public function setBorderBottomSize($value = null)
311298
{
312-
$this->borderBottomColor = $value;
299+
$this->borderBottomSize = $this->setNumericVal($value, $this->borderBottomSize);
313300

314301
return $this;
315302
}
@@ -325,20 +312,27 @@ public function getBorderBottomColor()
325312
}
326313

327314
/**
328-
* Has borders?
315+
* Set border bottom color
316+
*
317+
* @param string $value
318+
* @return self
319+
*/
320+
public function setBorderBottomColor($value = null)
321+
{
322+
$this->borderBottomColor = $value;
323+
324+
return $this;
325+
}
326+
327+
/**
328+
* Check if any of the border is not null
329329
*
330330
* @return bool
331331
*/
332-
public function hasBorders()
332+
public function hasBorder()
333333
{
334-
$hasBorders = false;
335334
$borders = $this->getBorderSize();
336-
for ($i = 0; $i < count($borders); $i++) {
337-
if (!is_null($borders[$i])) {
338-
$hasBorders = true;
339-
}
340-
}
341335

342-
return $hasBorders;
336+
return $borders !== array_filter($borders, 'is_null');
343337
}
344338
}

0 commit comments

Comments
 (0)