Skip to content

Commit 3085445

Browse files
author
Bas-Jan 't Jong
committed
Merge branch 'develop' of https://github.com/PHPOffice/PHPWord.git into develop
2 parents 36080c1 + d7f3d25 commit 3085445

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r
3636
- Header: All images added to the second header were assigned to the first header - @basjan GH-222
3737
- Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan GH-233 GH-234
3838
- PageBreak: Page break adds new line in the beginning of the new page - @ivanlanin GH-150
39+
- Image: `marginLeft` and `marginTop` cannot accept float value - @ivanlanin GH-248
3940

4041
### Deprecated
4142

src/PhpWord/Style/AbstractStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ protected function setFloatVal($value, $default = null)
245245
if (is_string($value) && (preg_match('/[^\d\.\,]/', $value) == 0)) {
246246
$value = floatval($value);
247247
}
248-
if (!is_float($value)) {
248+
if (!is_numeric($value)) {
249249
$value = $default;
250250
}
251251

src/PhpWord/Style/Image.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ class Image extends AbstractStyle
102102
/**
103103
* Margin Top
104104
*
105-
* @var int
105+
* @var int|float
106106
*/
107107
private $marginTop = 0;
108108

109109
/**
110110
* Margin Left
111111
*
112-
* @var int
112+
* @var int|float
113113
*/
114114
private $marginLeft = 0;
115115

@@ -235,7 +235,7 @@ public function setAlign($value = null)
235235
/**
236236
* Get margin top
237237
*
238-
* @return int
238+
* @return int|float
239239
*/
240240
public function getMarginTop()
241241
{
@@ -245,20 +245,20 @@ public function getMarginTop()
245245
/**
246246
* Set margin top
247247
*
248-
* @param int $value
248+
* @param int|float $value
249249
* @return self
250250
*/
251251
public function setMarginTop($value = 0)
252252
{
253-
$this->marginTop = $this->setIntVal($value, 0);
253+
$this->marginTop = $this->setNumericVal($value, 0);
254254

255255
return $this;
256256
}
257257

258258
/**
259259
* Get margin left
260260
*
261-
* @return int
261+
* @return int|float
262262
*/
263263
public function getMarginLeft()
264264
{
@@ -268,12 +268,12 @@ public function getMarginLeft()
268268
/**
269269
* Set margin left
270270
*
271-
* @param int $value
271+
* @param int|float $value
272272
* @return self
273273
*/
274274
public function setMarginLeft($value = 0)
275275
{
276-
$this->marginLeft = $this->setIntVal($value, 0);
276+
$this->marginLeft = $this->setNumericVal($value, 0);
277277

278278
return $this;
279279
}

0 commit comments

Comments
 (0)