Skip to content

Commit 1a80aac

Browse files
author
hazington
committed
Added type hints and matching PHPDoc. Also added @return void.
1 parent 40d5770 commit 1a80aac

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

src/PhpWord/Style/TextBox.php

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
/**
33
* This file is part of PHPWord - A pure PHP library for reading and writing
44
* word processing documents.
5-
*
65
* PHPWord is free software distributed under the terms of the GNU Lesser
76
* General Public License version 3 as published by the Free Software Foundation.
8-
*
97
* For the full copyright and license information, please read the LICENSE
108
* file that was distributed with this source code. For the full list of
119
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
1210
*
1311
* @see https://github.com/PHPOffice/PHPWord
14-
*
1512
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1613
*/
1714

@@ -27,158 +24,164 @@ class TextBox extends Image
2724
/**
2825
* margin top.
2926
*
30-
* @var int
27+
* @var null|int
3128
*/
3229
private $innerMarginTop;
3330

3431
/**
3532
* margin left.
3633
*
37-
* @var int
34+
* @var null|int
3835
*/
3936
private $innerMarginLeft;
4037

4138
/**
4239
* margin right.
4340
*
44-
* @var int
41+
* @var null|int
4542
*/
4643
private $innerMarginRight;
4744

4845
/**
4946
* Cell margin bottom.
5047
*
51-
* @var int
48+
* @var null|int
5249
*/
5350
private $innerMarginBottom;
5451

5552
/**
5653
* border size.
5754
*
58-
* @var int
55+
* @var null|int
5956
*/
6057
private $borderSize;
6158

6259
/**
6360
* border color.
6461
*
65-
* @var string
62+
* @var null|string
6663
*/
6764
private $borderColor;
6865

6966
/**
7067
* background color.
7168
*
72-
* @var string
69+
* @var null|string
7370
*/
7471
private $bgColor;
7572

7673
/**
7774
* Set background color.
7875
*
79-
* @param string $value
76+
* @param null|string $value
77+
* @return void
8078
*/
81-
public function setBgColor($value = null): void
79+
public function setBgColor(string $value = null): void
8280
{
8381
$this->bgColor = $value;
8482
}
8583

8684
/**
8785
* Get background color.
8886
*
89-
* @return string
87+
* @return null|string
9088
*/
91-
public function getBgColor()
89+
public function getBgColor(): ?string
9290
{
9391
return $this->bgColor;
9492
}
9593

9694
/**
9795
* Set margin top.
9896
*
99-
* @param int $value
97+
* @param null|int $value
98+
* @return void
10099
*/
101-
public function setInnerMarginTop($value = null): void
100+
public function setInnerMarginTop(int $value = null): void
102101
{
103102
$this->innerMarginTop = $value;
104103
}
105104

106105
/**
107106
* Get margin top.
108107
*
109-
* @return int
108+
* @return null|int
110109
*/
111-
public function getInnerMarginTop()
110+
public function getInnerMarginTop(): ?int
112111
{
113112
return $this->innerMarginTop;
114113
}
115114

116115
/**
117116
* Set margin left.
118117
*
119-
* @param int $value
118+
* @param null|int $value
119+
* @return void
120120
*/
121-
public function setInnerMarginLeft($value = null): void
121+
public function setInnerMarginLeft(int $value = null): void
122122
{
123123
$this->innerMarginLeft = $value;
124124
}
125125

126126
/**
127127
* Get margin left.
128128
*
129-
* @return int
129+
* @return null|int
130130
*/
131-
public function getInnerMarginLeft()
131+
public function getInnerMarginLeft(): ?int
132132
{
133133
return $this->innerMarginLeft;
134134
}
135135

136136
/**
137137
* Set margin right.
138138
*
139-
* @param int $value
139+
* @param null|int $value
140+
* @return void
140141
*/
141-
public function setInnerMarginRight($value = null): void
142+
public function setInnerMarginRight(int $value = null): void
142143
{
143144
$this->innerMarginRight = $value;
144145
}
145146

146147
/**
147148
* Get margin right.
148149
*
149-
* @return int
150+
* @return null|int
150151
*/
151-
public function getInnerMarginRight()
152+
public function getInnerMarginRight(): ?int
152153
{
153154
return $this->innerMarginRight;
154155
}
155156

156157
/**
157158
* Set margin bottom.
158159
*
159-
* @param int $value
160+
* @param null|int $value
161+
* @return void
160162
*/
161-
public function setInnerMarginBottom($value = null): void
163+
public function setInnerMarginBottom(int $value = null): void
162164
{
163165
$this->innerMarginBottom = $value;
164166
}
165167

166168
/**
167169
* Get margin bottom.
168170
*
169-
* @return int
171+
* @return null|int
170172
*/
171-
public function getInnerMarginBottom()
173+
public function getInnerMarginBottom(): ?int
172174
{
173175
return $this->innerMarginBottom;
174176
}
175177

176178
/**
177179
* Set TLRB cell margin.
178180
*
179-
* @param int $value Margin in twips
181+
* @param null|int $value Margin in twips
182+
* @return void
180183
*/
181-
public function setInnerMargin($value = null): void
184+
public function setInnerMargin(int $value = null): void
182185
{
183186
$this->setInnerMarginTop($value);
184187
$this->setInnerMarginLeft($value);
@@ -191,7 +194,7 @@ public function setInnerMargin($value = null): void
191194
*
192195
* @return int[]
193196
*/
194-
public function getInnerMargin()
197+
public function getInnerMargin(): array
195198
{
196199
return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
197200
}
@@ -201,7 +204,7 @@ public function getInnerMargin()
201204
*
202205
* @return bool
203206
*/
204-
public function hasInnerMargins()
207+
public function hasInnerMargins(): bool
205208
{
206209
$hasInnerMargins = false;
207210
$margins = $this->getInnerMargin();
@@ -218,9 +221,10 @@ public function hasInnerMargins()
218221
/**
219222
* Set border size.
220223
*
221-
* @param int $value Size in points
224+
* @param null|int $value Size in points
225+
* @return void
222226
*/
223-
public function setBorderSize($value = null): void
227+
public function setBorderSize(int $value = null): void
224228
{
225229
$this->borderSize = $value;
226230
}
@@ -230,27 +234,28 @@ public function setBorderSize($value = null): void
230234
*
231235
* @return int
232236
*/
233-
public function getBorderSize()
237+
public function getBorderSize(): int
234238
{
235239
return $this->borderSize;
236240
}
237241

238242
/**
239243
* Set border color.
240244
*
241-
* @param string $value
245+
* @param null|string $value
246+
* @return void
242247
*/
243-
public function setBorderColor($value = null): void
248+
public function setBorderColor(string $value = null): void
244249
{
245250
$this->borderColor = $value;
246251
}
247252

248253
/**
249254
* Get border color.
250255
*
251-
* @return string
256+
* @return null|string
252257
*/
253-
public function getBorderColor()
258+
public function getBorderColor(): ?string
254259
{
255260
return $this->borderColor;
256261
}

src/PhpWord/Writer/Word2007/Element/TextBox.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
/**
33
* This file is part of PHPWord - A pure PHP library for reading and writing
44
* word processing documents.
5-
*
65
* PHPWord is free software distributed under the terms of the GNU Lesser
76
* General Public License version 3 as published by the Free Software Foundation.
8-
*
97
* For the full copyright and license information, please read the LICENSE
108
* file that was distributed with this source code. For the full list of
119
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
1210
*
1311
* @see https://github.com/PHPOffice/PHPWord
14-
*
1512
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1613
*/
1714

@@ -28,18 +25,20 @@ class TextBox extends Image
2825
{
2926
/**
3027
* Write element.
28+
*
29+
* @return void
3130
*/
3231
public function write(): void
3332
{
3433
$xmlWriter = $this->getXmlWriter();
3534
$element = $this->getElement();
36-
if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) {
35+
if (! $element instanceof \PhpOffice\PhpWord\Element\TextBox) {
3736
return;
3837
}
3938
$style = $element->getStyle();
4039
$styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
4140

42-
if (!$this->withoutP) {
41+
if (! $this->withoutP) {
4342
$xmlWriter->startElement('w:p');
4443
$styleWriter->writeAlignment();
4544
}
@@ -53,6 +52,7 @@ public function write(): void
5352
if ($style->getBgColor()) {
5453
$xmlWriter->writeAttribute('fillcolor', $style->getBgColor());
5554
}
55+
5656
$styleWriter->write();
5757
$styleWriter->writeBorder();
5858

src/PhpWord/Writer/Word2007/Style/TextBox.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class TextBox extends Frame
2828
{
2929
/**
3030
* Writer inner margin.
31+
* @return void
3132
*/
3233
public function writeInnerMargin(): void
3334
{
@@ -44,6 +45,7 @@ public function writeInnerMargin(): void
4445

4546
/**
4647
* Writer border.
48+
* @return void
4749
*/
4850
public function writeBorder(): void
4951
{

0 commit comments

Comments
 (0)