Skip to content

Commit a38f898

Browse files
authored
Merge branch 'master' into bullet_list_render
2 parents 7faa833 + 0ab0b49 commit a38f898

File tree

102 files changed

+587
-493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+587
-493
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Fixes # (issue)
99
- [ ] My CI is :green_circle:
1010
- [ ] I have covered by unit tests my new code (check build/coverage for coverage report)
1111
- [ ] I have updated the [documentation](https://github.com/PHPOffice/PHPWord/tree/master/docs) to describe the changes
12-
- [ ] I have updated the [changelog](https://github.com/PHPOffice/PHPWord/blob/master/docs/changes/1.x/1.4.0.md)
12+
- [ ] I have updated the [changelog](https://github.com/PHPOffice/PHPWord/blob/master/docs/changes/1.x/1.5.0.md)

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@
112112
"ext-zip": "*",
113113
"ext-json": "*",
114114
"ext-xml": "*",
115-
"phpoffice/math": "^0.2"
115+
"phpoffice/math": "^0.3"
116116
},
117117
"require-dev": {
118118
"ext-libxml": "*",
119119
"dompdf/dompdf": "^2.0 || ^3.0",
120120
"friendsofphp/php-cs-fixer": "^3.3",
121121
"mpdf/mpdf": "^7.0 || ^8.0",
122122
"phpmd/phpmd": "^2.13",
123-
"phpstan/phpstan": "^0.12.88 || ^1.0.0",
123+
"phpstan/phpstan": "^0.12.88 || ^1.0.0 || ^2.0.0",
124124
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
125125
"phpunit/phpunit": ">=7.0",
126126
"symfony/process": "^4.4 || ^5.0",

docs/changes/1.x/1.4.0.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [1.4.0](https://github.com/PHPOffice/PHPWord/tree/1.4.0) (WIP)
1+
# [1.4.0](https://github.com/PHPOffice/PHPWord/tree/1.4.0)
22

33
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.3.0...1.4.0)
44

@@ -31,13 +31,16 @@
3131
- Writer HTML: Fixed null string for Text Elements by [@armagedon007](https://github.com/armagedon007) and [@Progi1984](https://github.com/Progi1984) in [#2738](https://github.com/PHPOffice/PHPWord/pull/2738)
3232
- Template Processor: Fix 0 considered as empty string by [@cavasinf](https://github.com/cavasinf), [@SnipsMine](https://github.com/SnipsMine) and [@Progi1984](https://github.com/Progi1984) fixing [#2572](https://github.com/PHPOffice/PHPWord/issues/2572), [#2703](https://github.com/PHPOffice/PHPWord/issues/2703) in [#2748](https://github.com/PHPOffice/PHPWord/pull/2748)
3333
- Word2007 Writer : Corrected generating TOC to fix page number missing issues [@jgiacomello](https://github.com/jgiacomello) in [#2556](https://github.com/PHPOffice/PHPWord/pull/2556)
34+
- Enhanced error handling in encoding functions [@michalschroeder](https://github.com/michalschroeder) in [#2784](https://github.com/PHPOffice/PHPWord/pull/2784)
3435

3536
### Miscellaneous
3637

3738
- Bump dompdf/dompdf from 2.0.4 to 3.0.0 by [@dependabot](https://github.com/dependabot) fixing [#2621](https://github.com/PHPOffice/PHPWord/issues/2621) in [#2666](https://github.com/PHPOffice/PHPWord/pull/2666)
3839
- Add test case to make sure vMerge defaults to 'continue' by [@SpraxDev](https://github.com/SpraxDev) in [#2677](https://github.com/PHPOffice/PHPWord/pull/2677)
3940
- Adding the possibility to use iterate search and replace with setValues by [@moghwan](https://github.com/moghwan) in [#2632](https://github.com/PHPOffice/PHPWord/pull/2640)
4041
- Add test cases that test the ODTText and Word2007 reader using the corresponding writer, increasing test coverage by [@MichaelPFrey](https://github.com/MichaelPFrey) in [#2745](https://github.com/PHPOffice/PHPWord/pull/2745)
42+
- Updated TOCTest to use static HTML content instead of external resource [@michalschroeder](https://github.com/michalschroeder) in [#2784](https://github.com/PHPOffice/PHPWord/pull/2784)
43+
- Bump PHPOffice/math from 0.2.0 to 0.3.0 by [@eileenmcnaughton](https://github.com/eileenmcnaughton) in [#2785](https://github.com/PHPOffice/PHPWord/pull/2785)
4144

4245
### Deprecations
4346
- Deprecate `PhpOffice\PhpWord\Style\Paragraph::getIndent()` : Use `PhpOffice\PhpWord\Style\Paragraph::getIndentLeft()`

docs/changes/1.x/1.5.0.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# [1.5.0](https://github.com/PHPOffice/PHPWord/tree/1.5.0) (WIP)
2+
3+
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.4.0...1.5.0)
4+
5+
## Enhancements
6+
7+
### Bug fixes
8+
9+
- Set writeAttribute return type by [@radarhere](https://github.com/radarhere) fixing [#2204](https://github.com/PHPOffice/PHPWord/issues/2204) in [#2776](https://github.com/PHPOffice/PHPWord/pull/2776)
10+
11+
### Miscellaneous
12+
13+
- Update phpstan/phpstan requirement from ^0.12.88 || ^1.0.0 to ^0.12.88 || ^1.0.0 || ^2.0.0 by [@dependabot](https://github.com/dependabot) & [@Progi1984](https://github.com/Progi1984) in [#2736](https://github.com/PHPOffice/PHPWord/pull/2736)
14+
15+
### Deprecations
16+
17+
### BC Breaks
18+
19+
### Notes

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ nav:
8888
- Credits: 'credits.md'
8989
- Releases:
9090
- '1.x':
91-
- '1.4.0 (WIP)': 'changes/1.x/1.4.0.md'
91+
- '1.5.0 (WIP)': 'changes/1.x/1.5.0.md'
92+
- '1.4.0': 'changes/1.x/1.4.0.md'
9293
- '1.3.0': 'changes/1.x/1.3.0.md'
9394
- '1.2.0': 'changes/1.x/1.2.0.md'
9495
- '1.1.0': 'changes/1.x/1.1.0.md'

phpstan-baseline.neon

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,3 +1839,39 @@ parameters:
18391839
message: "#^Property PhpOffice\\\\PhpWordTests\\\\XmlDocument\\:\\:\\$xpath \\(DOMXPath\\) does not accept null\\.$#"
18401840
count: 1
18411841
path: tests/PhpWordTests/XmlDocument.php
1842+
1843+
# https://github.com/phpstan/phpstan/issues/8770
1844+
-
1845+
message: "#^PHPDoc tag @var with type PhpOffice\\\\PhpWord\\\\Writer\\\\HTML\\\\Part\\\\AbstractPart is not subtype of native type[\\sA-Za-z\\@\\\\\\/0-9\\.:|]+$#"
1846+
count: 1
1847+
path: src/PhpWord/Writer/HTML.php
1848+
1849+
# https://github.com/phpstan/phpstan/issues/8770
1850+
-
1851+
message: "#^PHPDoc tag @var with type PhpOffice\\\\PhpWord\\\\Element\\\\AbstractElement is not subtype of native type[\\sA-Za-z\\@\\\\\\/0-9\\.:]+$#"
1852+
count: 2
1853+
path: tests/PhpWordTests/Element/AbstractElementTest.php
1854+
1855+
# https://github.com/phpstan/phpstan/issues/8770
1856+
-
1857+
message: "#^PHPDoc tag @var with type PhpOffice\\\\PhpWord\\\\Style\\\\AbstractStyle is not subtype of native type[\\sA-Za-z\\@\\\\\\/0-9\\.:]+$#"
1858+
count: 4
1859+
path: tests/PhpWordTests/Style/AbstractStyleTest.php
1860+
1861+
# https://github.com/phpstan/phpstan/issues/8770
1862+
-
1863+
message: "#^PHPDoc tag @var with type PhpOffice\\\\PhpWord\\\\Writer\\\\EPub3\\\\Style\\\\AbstractStyle is not subtype of native type[\\sA-Za-z\\@\\\\\\/0-9\\.:]+$#"
1864+
count: 2
1865+
path: tests/PhpWordTests/Writer/EPub3/Style/AbstractStyleTest.php
1866+
1867+
# https://github.com/phpstan/phpstan/issues/8770
1868+
-
1869+
message: "#^PHPDoc tag @var with type PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Part\\\\AbstractPart is not subtype of native type[\\sA-Za-z\\@\\\\\\/0-9\\.:]+$#"
1870+
count: 2
1871+
path: tests/PhpWordTests/Writer/ODText/Part/AbstractPartTest.php
1872+
1873+
# https://github.com/phpstan/phpstan/issues/8770
1874+
-
1875+
message: "#^PHPDoc tag @var with type PhpOffice\\\\PhpWord\\\\Writer\\\\Word2007\\\\Part\\\\AbstractPart is not subtype of native type[\\sA-Za-z\\@\\\\\\/0-9\\.:]+$#"
1876+
count: 2
1877+
path: tests/PhpWordTests/Writer/Word2007/Part/AbstractPartTest.php

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ parameters:
1616
- tests/bootstrap.php
1717
## <=PHP7.4
1818
reportUnmatchedIgnoredErrors: false
19+
treatPhpDocTypesAsCertain: false
1920
ignoreErrors:
2021
-
2122
identifier: missingType.iterableValue

src/PhpWord/Element/Field.php

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class Field extends AbstractElement
108108
/**
109109
* Field text.
110110
*
111-
* @var string|TextRun
111+
* @var null|string|TextRun
112112
*/
113113
protected $text;
114114

@@ -217,22 +217,18 @@ public function getType()
217217
/**
218218
* Set Field properties.
219219
*
220-
* @param array $properties
221-
*
222220
* @return self
223221
*/
224-
public function setProperties($properties = [])
222+
public function setProperties(array $properties = [])
225223
{
226-
if (is_array($properties)) {
227-
foreach (array_keys($properties) as $propkey) {
228-
if (!(isset($this->fieldsArray[$this->type]['properties'][$propkey]))) {
229-
throw new InvalidArgumentException("Invalid property '$propkey'");
230-
}
224+
foreach (array_keys($properties) as $propkey) {
225+
if (!(isset($this->fieldsArray[$this->type]['properties'][$propkey]))) {
226+
throw new InvalidArgumentException("Invalid property '$propkey'");
231227
}
232-
$this->properties = array_merge($this->properties, $properties);
233228
}
229+
$this->properties = array_merge($this->properties, $properties);
234230

235-
return $this->properties;
231+
return $this;
236232
}
237233

238234
/**
@@ -248,22 +244,18 @@ public function getProperties()
248244
/**
249245
* Set Field options.
250246
*
251-
* @param array $options
252-
*
253247
* @return self
254248
*/
255-
public function setOptions($options = [])
249+
public function setOptions(array $options = [])
256250
{
257-
if (is_array($options)) {
258-
foreach (array_keys($options) as $optionkey) {
259-
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
260-
throw new InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
261-
}
251+
foreach (array_keys($options) as $optionkey) {
252+
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
253+
throw new InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
262254
}
263-
$this->options = array_merge($this->options, $options);
264255
}
256+
$this->options = array_merge($this->options, $options);
265257

266-
return $this->options;
258+
return $this;
267259
}
268260

269261
/**
@@ -279,13 +271,13 @@ public function getOptions()
279271
/**
280272
* Set Field text.
281273
*
282-
* @param null|string|TextRun $text
274+
* @param null|mixed|string|TextRun $text
283275
*
284276
* @return null|string|TextRun
285277
*/
286278
public function setText($text = null)
287279
{
288-
if (isset($text)) {
280+
if (null !== $text) {
289281
if (is_string($text) || $text instanceof TextRun) {
290282
$this->text = $text;
291283
} else {

src/PhpWord/Element/OLEObject.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,16 @@ class OLEObject extends AbstractElement
7070
public function __construct($source, $style = null)
7171
{
7272
$supportedTypes = ['xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx'];
73-
$pathInfo = pathinfo($source);
73+
$pathInfoExtension = pathinfo($source, PATHINFO_EXTENSION);
7474

75-
if (file_exists($source) && in_array($pathInfo['extension'], $supportedTypes)) {
76-
$ext = $pathInfo['extension'];
77-
if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
78-
$ext = substr($ext, 0, -1);
75+
if (file_exists($source) && in_array($pathInfoExtension, $supportedTypes)) {
76+
if (strlen($pathInfoExtension) == 4 && strtolower(substr($pathInfoExtension, -1)) == 'x') {
77+
$pathInfoExtension = substr($pathInfoExtension, 0, -1);
7978
}
8079

8180
$this->source = $source;
8281
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
83-
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
82+
$this->icon = realpath(__DIR__ . "/../resources/{$pathInfoExtension}.png");
8483

8584
return;
8685
}

src/PhpWord/Element/Section.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ public function __construct($sectionCount, $style = null)
7575

7676
/**
7777
* Set section style.
78-
*
79-
* @param array $style
8078
*/
81-
public function setStyle($style = null): void
79+
public function setStyle(?array $style = null): void
8280
{
83-
if (null !== $style && is_array($style)) {
81+
if (null !== $style) {
8482
$this->style->setStyleByArray($style);
8583
}
8684
}

0 commit comments

Comments
 (0)