Skip to content

Commit b614497

Browse files
authored
fix dependencies to have 7.1 compatible build (#1228)
* add assertions in test methods without assertions * loosen dependencies so 7.0 & 7.1 builds can succeed * fix some scrutinizer errors * update release date
1 parent fce1bf2 commit b614497

23 files changed

+110
-113
lines changed

.scrutinizer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tools:
1515
ruleset: phpmd.xml.dist
1616
external_code_coverage:
1717
enabled: true
18-
timeout: 900
18+
timeout: 1200
1919
php_cpd: true
2020
# php_sim: # Temporarily disabled to allow focus on things other than duplicates
2121
# min_mass: 40

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ php:
99
- 5.6
1010
- 7.0
1111
- 7.1
12+
- 7.2
1213

1314
matrix:
1415
include:
1516
- php: 5.6
1617
env: COVERAGE=1
1718
allow_failures:
18-
- php: 7.0
19-
- php: 7.1
19+
- php: 7.2
2020

2121
cache:
2222
directories:

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Change Log
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6-
v0.14.0 (28 Dec 2017)
6+
v0.14.0 (29 Dec 2017)
77
----------------------
88
This release fixes several bugs and adds some new features.
9-
This is the last version to support PHP 5.3
9+
This version brings compatibility with PHP 7.0 & 7.1
1010

1111
### Added
1212
- Possibility to control the footnote numbering - @troosan #1068

composer.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,22 @@
4646
]
4747
},
4848
"require": {
49-
"php": ">=5.3.3",
49+
"php": "^5.3.3 || ^7.0",
5050
"ext-xml": "*",
5151
"zendframework/zend-escaper": "^2.2",
5252
"zendframework/zend-stdlib": "^2.2 || ^3.0",
5353
"phpoffice/common": "^0.2"
5454
},
5555
"require-dev": {
56-
"phpunit/phpunit": "^4.8.36",
56+
"phpunit/phpunit": "^4.8.36 || ^5.0",
5757
"phpdocumentor/phpdocumentor":"2.*",
58-
"twig/twig":"1.27",
5958
"squizlabs/php_codesniffer": "^2.7",
6059
"friendsofphp/php-cs-fixer": "^2.0",
6160
"phpmd/phpmd": "2.*",
62-
"phploc/phploc": "2.*",
61+
"phploc/phploc": "2.* || 3.* || 4.*",
6362
"dompdf/dompdf":"0.8.*",
6463
"tecnickcom/tcpdf": "6.*",
65-
"mpdf/mpdf": "5.*"
64+
"mpdf/mpdf": "5.* || 6.* || 7.*"
6665
},
6766
"suggest": {
6867
"ext-zip": "Allows writing OOXML and ODF",

docs/ISSUE_TEMPLATE.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
Issue tracker is **ONLY** used for reporting bugs. NO NEW FEATURE ACCEPTED! Use [stackoverflow](https://stackoverflow.com/questions/tagged/phpword) for supporting issues.
1+
This is:
2+
3+
- [ ] a bug report
4+
- [ ] a feature request
5+
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpword)
26

37
# Expected Behavior
48

59
Please describe the behavior you are expecting.
610

7-
# Current Behavior
11+
### Current Behavior
812

913
What is the current behavior?
1014

11-
# Failure Information
15+
### Failure Information
1216

1317
Please help provide information about the failure.
1418

15-
## How to Reproduce
19+
### How to Reproduce
1620

1721
Please provide a code sample that reproduces the issue.
1822

1923
```php
24+
<?php
25+
require __DIR__ . '/vendor/autoload.php';
26+
2027
$phpWord = new \PhpOffice\PhpWord\PhpWord();
2128
$section = $phpWord->addSection();
2229
$section->...
2330
```
2431

25-
## Context
32+
### Context
2633

2734
* PHP version:
2835
* PHPWord version: 0.14

docs/PULL_REQUEST_TEMPLATE.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Description
1+
### Description
22

33
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
44

55
Fixes # (issue)
66

7-
# Checklist:
7+
### Checklist:
88

9-
- [ ] I have commented my code, particularly in hard-to-understand areas
10-
- [ ] I have run phpunit, phpcs, php-cs-fixer, phpmd
9+
- [ ] I have run `composer check` and no errors were reported
1110
- [ ] The new code is covered by unit tests
1211
- [ ] I have update the documentation to describe the changes

run_tests.sh

-20
This file was deleted.

src/PhpWord/Element/AbstractElement.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function setElementIndex($value)
228228
/**
229229
* Get element unique ID
230230
*
231-
* @return int
231+
* @return string
232232
*/
233233
public function getElementId()
234234
{
@@ -425,18 +425,18 @@ protected function setNewStyle($styleObject, $styleValue = null, $returnObject =
425425
/**
426426
* Set enum value
427427
*
428-
* @param mixed $value
429-
* @param array $enum
430-
* @param mixed $default
428+
* @param string|null $value
429+
* @param string[] $enum
430+
* @param string|null $default
431431
*
432432
* @throws \InvalidArgumentException
433-
* @return mixed
433+
* @return string|null
434434
*
435435
* @todo Merge with the same method in AbstractStyle
436436
*/
437437
protected function setEnumVal($value = null, $enum = array(), $default = null)
438438
{
439-
if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
439+
if ($value !== null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
440440
throw new \InvalidArgumentException("Invalid style value: {$value}");
441441
} elseif ($value === null || trim($value) == '') {
442442
$value = $default;

src/PhpWord/Element/Field.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function getOptions()
211211
* @throws \InvalidArgumentException
212212
* @return null|string|TextRun
213213
*/
214-
public function setText($text)
214+
public function setText($text = null)
215215
{
216216
if (isset($text)) {
217217
if (is_string($text) || $text instanceof TextRun) {

src/PhpWord/Element/TrackChange.php

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public function __construct($author, \DateTime $date = null)
5252
{
5353
$this->author = $author;
5454
$this->date = $date;
55-
56-
return $this;
5755
}
5856

5957
/**

src/PhpWord/Metadata/Protection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function getSalt()
182182
/**
183183
* Set salt. Salt HAS to be 16 characters, or an exception will be thrown.
184184
*
185-
* @param $salt
185+
* @param string $salt
186186
* @throws \InvalidArgumentException
187187
* @return self
188188
*/

src/PhpWord/Reader/Word2007/Settings.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function setRevisionView(XMLReader $xmlReader, PhpWord $phpWord, \DOME
152152
$revisionView = new TrackChangesView();
153153
$revisionView->setMarkup(filter_var($xmlReader->getAttribute('w:markup', $node), FILTER_VALIDATE_BOOLEAN));
154154
$revisionView->setComments($xmlReader->getAttribute('w:comments', $node));
155-
$revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node));
155+
$revisionView->setInsDel(filter_var($xmlReader->getAttribute('w:insDel', $node), FILTER_VALIDATE_BOOLEAN));
156156
$revisionView->setFormatting(filter_var($xmlReader->getAttribute('w:formatting', $node), FILTER_VALIDATE_BOOLEAN));
157157
$revisionView->setInkAnnotations(filter_var($xmlReader->getAttribute('w:inkAnnotations', $node), FILTER_VALIDATE_BOOLEAN));
158158
$phpWord->getSettings()->setRevisionView($revisionView);

src/PhpWord/Shared/Converter.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Converter
3333
/**
3434
* Convert centimeter to twip
3535
*
36-
* @param int $centimeter
36+
* @param float $centimeter
3737
* @return float
3838
*/
3939
public static function cmToTwip($centimeter = 1)
@@ -44,7 +44,7 @@ public static function cmToTwip($centimeter = 1)
4444
/**
4545
* Convert centimeter to inch
4646
*
47-
* @param int $centimeter
47+
* @param float $centimeter
4848
* @return float
4949
*/
5050
public static function cmToInch($centimeter = 1)
@@ -55,7 +55,7 @@ public static function cmToInch($centimeter = 1)
5555
/**
5656
* Convert centimeter to pixel
5757
*
58-
* @param int $centimeter
58+
* @param float $centimeter
5959
* @return float
6060
*/
6161
public static function cmToPixel($centimeter = 1)
@@ -66,7 +66,7 @@ public static function cmToPixel($centimeter = 1)
6666
/**
6767
* Convert centimeter to point
6868
*
69-
* @param int $centimeter
69+
* @param float $centimeter
7070
* @return float
7171
*/
7272
public static function cmToPoint($centimeter = 1)
@@ -77,8 +77,8 @@ public static function cmToPoint($centimeter = 1)
7777
/**
7878
* Convert centimeter to EMU
7979
*
80-
* @param int $centimeter
81-
* @return int
80+
* @param float $centimeter
81+
* @return float
8282
*/
8383
public static function cmToEmu($centimeter = 1)
8484
{
@@ -88,8 +88,8 @@ public static function cmToEmu($centimeter = 1)
8888
/**
8989
* Convert inch to twip
9090
*
91-
* @param int $inch
92-
* @return int
91+
* @param float $inch
92+
* @return float
9393
*/
9494
public static function inchToTwip($inch = 1)
9595
{
@@ -99,7 +99,7 @@ public static function inchToTwip($inch = 1)
9999
/**
100100
* Convert inch to centimeter
101101
*
102-
* @param int $inch
102+
* @param float $inch
103103
* @return float
104104
*/
105105
public static function inchToCm($inch = 1)
@@ -110,8 +110,8 @@ public static function inchToCm($inch = 1)
110110
/**
111111
* Convert inch to pixel
112112
*
113-
* @param int $inch
114-
* @return int
113+
* @param float $inch
114+
* @return float
115115
*/
116116
public static function inchToPixel($inch = 1)
117117
{
@@ -121,8 +121,8 @@ public static function inchToPixel($inch = 1)
121121
/**
122122
* Convert inch to point
123123
*
124-
* @param int $inch
125-
* @return int
124+
* @param float $inch
125+
* @return float
126126
*/
127127
public static function inchToPoint($inch = 1)
128128
{
@@ -132,8 +132,8 @@ public static function inchToPoint($inch = 1)
132132
/**
133133
* Convert inch to EMU
134134
*
135-
* @param int $inch
136-
* @return int
135+
* @param float $inch
136+
* @return float
137137
*/
138138
public static function inchToEmu($inch = 1)
139139
{
@@ -144,7 +144,7 @@ public static function inchToEmu($inch = 1)
144144
* Convert pixel to twip
145145
*
146146
* @param int $pixel
147-
* @return int
147+
* @return float
148148
*/
149149
public static function pixelToTwip($pixel = 1)
150150
{
@@ -188,7 +188,7 @@ public static function pixelToEmu($pixel = 1)
188188
* Convert point to twip unit
189189
*
190190
* @param int $point
191-
* @return int
191+
* @return float
192192
*/
193193
public static function pointToTwip($point = 1)
194194
{
@@ -210,7 +210,7 @@ public static function pointToPixel($point = 1)
210210
* Convert point to EMU
211211
*
212212
* @param int $point
213-
* @return int
213+
* @return float
214214
*/
215215
public static function pointToEmu($point = 1)
216216
{
@@ -221,7 +221,7 @@ public static function pointToEmu($point = 1)
221221
* Convert EMU to pixel
222222
*
223223
* @param int $emu
224-
* @return int
224+
* @return float
225225
*/
226226
public static function emuToPixel($emu = 1)
227227
{

src/PhpWord/Shared/Html.php

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ private static function parseStyle($attribute, $styles)
518518
private static function parseImage($node, $element)
519519
{
520520
$style = array();
521+
$src = null;
521522
foreach ($node->attributes as $attribute) {
522523
switch ($attribute->name) {
523524
case 'src':

src/PhpWord/Shared/Microsoft/PasswordEncoder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private static function getAlgorithm($algorithmName)
165165
/**
166166
* Returns the algorithm ID
167167
*
168-
* @param sting $algorithmName
168+
* @param string $algorithmName
169169
* @return int
170170
*/
171171
public static function getAlgorithmId($algorithmName)

src/PhpWord/Shared/ZipArchive.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function close()
161161
{
162162
if (!$this->usePclzip) {
163163
if ($this->zip->close() === false) {
164-
throw new Exception("Could not close zip file {$this->filename}.");
164+
throw new Exception("Could not close zip file {$this->filename}: ");
165165
}
166166
}
167167

0 commit comments

Comments
 (0)