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
This commit is contained in:
parent
fce1bf28c8
commit
b614497ae6
|
|
@ -15,7 +15,7 @@ tools:
|
|||
ruleset: phpmd.xml.dist
|
||||
external_code_coverage:
|
||||
enabled: true
|
||||
timeout: 900
|
||||
timeout: 1200
|
||||
php_cpd: true
|
||||
# php_sim: # Temporarily disabled to allow focus on things other than duplicates
|
||||
# min_mass: 40
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ php:
|
|||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: COVERAGE=1
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ Change Log
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
v0.14.0 (28 Dec 2017)
|
||||
v0.14.0 (29 Dec 2017)
|
||||
----------------------
|
||||
This release fixes several bugs and adds some new features.
|
||||
This is the last version to support PHP 5.3
|
||||
This version brings compatibility with PHP 7.0 & 7.1
|
||||
|
||||
### Added
|
||||
- Possibility to control the footnote numbering - @troosan #1068
|
||||
|
|
|
|||
|
|
@ -46,23 +46,22 @@
|
|||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": "^5.3.3 || ^7.0",
|
||||
"ext-xml": "*",
|
||||
"zendframework/zend-escaper": "^2.2",
|
||||
"zendframework/zend-stdlib": "^2.2 || ^3.0",
|
||||
"phpoffice/common": "^0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36",
|
||||
"phpunit/phpunit": "^4.8.36 || ^5.0",
|
||||
"phpdocumentor/phpdocumentor":"2.*",
|
||||
"twig/twig":"1.27",
|
||||
"squizlabs/php_codesniffer": "^2.7",
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phploc/phploc": "2.*",
|
||||
"phploc/phploc": "2.* || 3.* || 4.*",
|
||||
"dompdf/dompdf":"0.8.*",
|
||||
"tecnickcom/tcpdf": "6.*",
|
||||
"mpdf/mpdf": "5.*"
|
||||
"mpdf/mpdf": "5.* || 6.* || 7.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-zip": "Allows writing OOXML and ODF",
|
||||
|
|
|
|||
|
|
@ -1,28 +1,35 @@
|
|||
Issue tracker is **ONLY** used for reporting bugs. NO NEW FEATURE ACCEPTED! Use [stackoverflow](https://stackoverflow.com/questions/tagged/phpword) for supporting issues.
|
||||
This is:
|
||||
|
||||
- [ ] a bug report
|
||||
- [ ] a feature request
|
||||
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpword)
|
||||
|
||||
# Expected Behavior
|
||||
|
||||
Please describe the behavior you are expecting.
|
||||
|
||||
# Current Behavior
|
||||
### Current Behavior
|
||||
|
||||
What is the current behavior?
|
||||
|
||||
# Failure Information
|
||||
### Failure Information
|
||||
|
||||
Please help provide information about the failure.
|
||||
|
||||
## How to Reproduce
|
||||
### How to Reproduce
|
||||
|
||||
Please provide a code sample that reproduces the issue.
|
||||
|
||||
```php
|
||||
<?php
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
$section->...
|
||||
```
|
||||
|
||||
## Context
|
||||
### Context
|
||||
|
||||
* PHP version:
|
||||
* PHPWord version: 0.14
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
# Description
|
||||
### Description
|
||||
|
||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
|
||||
|
||||
Fixes # (issue)
|
||||
|
||||
# Checklist:
|
||||
### Checklist:
|
||||
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have run phpunit, phpcs, php-cs-fixer, phpmd
|
||||
- [ ] I have run `composer check` and no errors were reported
|
||||
- [ ] The new code is covered by unit tests
|
||||
- [ ] I have update the documentation to describe the changes
|
||||
|
|
|
|||
20
run_tests.sh
20
run_tests.sh
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/bash
|
||||
echo "Running composer update"
|
||||
composer update
|
||||
|
||||
## PHP_CodeSniffer
|
||||
echo "Running CodeSniffer"
|
||||
./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
|
||||
|
||||
## PHP-CS-Fixer
|
||||
echo "Running CS Fixer"
|
||||
./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
|
||||
|
||||
## PHP Mess Detector
|
||||
echo "Running Mess Detector"
|
||||
./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
|
||||
|
||||
## PHPUnit
|
||||
echo "Running PHPUnit"
|
||||
./vendor/bin/phpunit -c ./
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ abstract class AbstractElement
|
|||
/**
|
||||
* Get element unique ID
|
||||
*
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getElementId()
|
||||
{
|
||||
|
|
@ -425,18 +425,18 @@ abstract class AbstractElement
|
|||
/**
|
||||
* Set enum value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array $enum
|
||||
* @param mixed $default
|
||||
* @param string|null $value
|
||||
* @param string[] $enum
|
||||
* @param string|null $default
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return mixed
|
||||
* @return string|null
|
||||
*
|
||||
* @todo Merge with the same method in AbstractStyle
|
||||
*/
|
||||
protected function setEnumVal($value = null, $enum = array(), $default = null)
|
||||
{
|
||||
if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
|
||||
if ($value !== null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
|
||||
throw new \InvalidArgumentException("Invalid style value: {$value}");
|
||||
} elseif ($value === null || trim($value) == '') {
|
||||
$value = $default;
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class Field extends AbstractElement
|
|||
* @throws \InvalidArgumentException
|
||||
* @return null|string|TextRun
|
||||
*/
|
||||
public function setText($text)
|
||||
public function setText($text = null)
|
||||
{
|
||||
if (isset($text)) {
|
||||
if (is_string($text) || $text instanceof TextRun) {
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ class TrackChange extends AbstractContainer
|
|||
{
|
||||
$this->author = $author;
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class Protection
|
|||
/**
|
||||
* Set salt. Salt HAS to be 16 characters, or an exception will be thrown.
|
||||
*
|
||||
* @param $salt
|
||||
* @param string $salt
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class Settings extends AbstractPart
|
|||
$revisionView = new TrackChangesView();
|
||||
$revisionView->setMarkup(filter_var($xmlReader->getAttribute('w:markup', $node), FILTER_VALIDATE_BOOLEAN));
|
||||
$revisionView->setComments($xmlReader->getAttribute('w:comments', $node));
|
||||
$revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node));
|
||||
$revisionView->setInsDel(filter_var($xmlReader->getAttribute('w:insDel', $node), FILTER_VALIDATE_BOOLEAN));
|
||||
$revisionView->setFormatting(filter_var($xmlReader->getAttribute('w:formatting', $node), FILTER_VALIDATE_BOOLEAN));
|
||||
$revisionView->setInkAnnotations(filter_var($xmlReader->getAttribute('w:inkAnnotations', $node), FILTER_VALIDATE_BOOLEAN));
|
||||
$phpWord->getSettings()->setRevisionView($revisionView);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Converter
|
|||
/**
|
||||
* Convert centimeter to twip
|
||||
*
|
||||
* @param int $centimeter
|
||||
* @param float $centimeter
|
||||
* @return float
|
||||
*/
|
||||
public static function cmToTwip($centimeter = 1)
|
||||
|
|
@ -44,7 +44,7 @@ class Converter
|
|||
/**
|
||||
* Convert centimeter to inch
|
||||
*
|
||||
* @param int $centimeter
|
||||
* @param float $centimeter
|
||||
* @return float
|
||||
*/
|
||||
public static function cmToInch($centimeter = 1)
|
||||
|
|
@ -55,7 +55,7 @@ class Converter
|
|||
/**
|
||||
* Convert centimeter to pixel
|
||||
*
|
||||
* @param int $centimeter
|
||||
* @param float $centimeter
|
||||
* @return float
|
||||
*/
|
||||
public static function cmToPixel($centimeter = 1)
|
||||
|
|
@ -66,7 +66,7 @@ class Converter
|
|||
/**
|
||||
* Convert centimeter to point
|
||||
*
|
||||
* @param int $centimeter
|
||||
* @param float $centimeter
|
||||
* @return float
|
||||
*/
|
||||
public static function cmToPoint($centimeter = 1)
|
||||
|
|
@ -77,8 +77,8 @@ class Converter
|
|||
/**
|
||||
* Convert centimeter to EMU
|
||||
*
|
||||
* @param int $centimeter
|
||||
* @return int
|
||||
* @param float $centimeter
|
||||
* @return float
|
||||
*/
|
||||
public static function cmToEmu($centimeter = 1)
|
||||
{
|
||||
|
|
@ -88,8 +88,8 @@ class Converter
|
|||
/**
|
||||
* Convert inch to twip
|
||||
*
|
||||
* @param int $inch
|
||||
* @return int
|
||||
* @param float $inch
|
||||
* @return float
|
||||
*/
|
||||
public static function inchToTwip($inch = 1)
|
||||
{
|
||||
|
|
@ -99,7 +99,7 @@ class Converter
|
|||
/**
|
||||
* Convert inch to centimeter
|
||||
*
|
||||
* @param int $inch
|
||||
* @param float $inch
|
||||
* @return float
|
||||
*/
|
||||
public static function inchToCm($inch = 1)
|
||||
|
|
@ -110,8 +110,8 @@ class Converter
|
|||
/**
|
||||
* Convert inch to pixel
|
||||
*
|
||||
* @param int $inch
|
||||
* @return int
|
||||
* @param float $inch
|
||||
* @return float
|
||||
*/
|
||||
public static function inchToPixel($inch = 1)
|
||||
{
|
||||
|
|
@ -121,8 +121,8 @@ class Converter
|
|||
/**
|
||||
* Convert inch to point
|
||||
*
|
||||
* @param int $inch
|
||||
* @return int
|
||||
* @param float $inch
|
||||
* @return float
|
||||
*/
|
||||
public static function inchToPoint($inch = 1)
|
||||
{
|
||||
|
|
@ -132,8 +132,8 @@ class Converter
|
|||
/**
|
||||
* Convert inch to EMU
|
||||
*
|
||||
* @param int $inch
|
||||
* @return int
|
||||
* @param float $inch
|
||||
* @return float
|
||||
*/
|
||||
public static function inchToEmu($inch = 1)
|
||||
{
|
||||
|
|
@ -144,7 +144,7 @@ class Converter
|
|||
* Convert pixel to twip
|
||||
*
|
||||
* @param int $pixel
|
||||
* @return int
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelToTwip($pixel = 1)
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ class Converter
|
|||
* Convert point to twip unit
|
||||
*
|
||||
* @param int $point
|
||||
* @return int
|
||||
* @return float
|
||||
*/
|
||||
public static function pointToTwip($point = 1)
|
||||
{
|
||||
|
|
@ -210,7 +210,7 @@ class Converter
|
|||
* Convert point to EMU
|
||||
*
|
||||
* @param int $point
|
||||
* @return int
|
||||
* @return float
|
||||
*/
|
||||
public static function pointToEmu($point = 1)
|
||||
{
|
||||
|
|
@ -221,7 +221,7 @@ class Converter
|
|||
* Convert EMU to pixel
|
||||
*
|
||||
* @param int $emu
|
||||
* @return int
|
||||
* @return float
|
||||
*/
|
||||
public static function emuToPixel($emu = 1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -518,6 +518,7 @@ class Html
|
|||
private static function parseImage($node, $element)
|
||||
{
|
||||
$style = array();
|
||||
$src = null;
|
||||
foreach ($node->attributes as $attribute) {
|
||||
switch ($attribute->name) {
|
||||
case 'src':
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class PasswordEncoder
|
|||
/**
|
||||
* Returns the algorithm ID
|
||||
*
|
||||
* @param sting $algorithmName
|
||||
* @param string $algorithmName
|
||||
* @return int
|
||||
*/
|
||||
public static function getAlgorithmId($algorithmName)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class ZipArchive
|
|||
{
|
||||
if (!$this->usePclzip) {
|
||||
if ($this->zip->close() === false) {
|
||||
throw new Exception("Could not close zip file {$this->filename}.");
|
||||
throw new Exception("Could not close zip file {$this->filename}: ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,14 +118,14 @@ class Paper extends AbstractStyle
|
|||
/**
|
||||
* Width
|
||||
*
|
||||
* @var int (twip)
|
||||
* @var float (twip)
|
||||
*/
|
||||
private $width;
|
||||
|
||||
/**
|
||||
* Height
|
||||
*
|
||||
* @var int (twip)
|
||||
* @var float (twip)
|
||||
*/
|
||||
private $height;
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ class Paper extends AbstractStyle
|
|||
/**
|
||||
* Get width
|
||||
*
|
||||
* @return int
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
|
|
@ -185,7 +185,7 @@ class Paper extends AbstractStyle
|
|||
/**
|
||||
* Get height
|
||||
*
|
||||
* @return int
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\PDF;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\Writer\WriterInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -27,12 +29,14 @@ use PhpOffice\PhpWord\Writer\WriterInterface;
|
|||
*/
|
||||
class MPDF extends AbstractRenderer implements WriterInterface
|
||||
{
|
||||
/**
|
||||
* Name of renderer include file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $includeFile = 'mpdf.php';
|
||||
public function __construct(PhpWord $phpWord)
|
||||
{
|
||||
if (file_exists(Settings::getPdfRendererPath() . '/mpdf.php')) {
|
||||
// MPDF version 5.* needs this file to be included, later versions not
|
||||
$this->includeFile = 'mpdf.php';
|
||||
}
|
||||
parent::__construct($phpWord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PhpWord to file.
|
||||
|
|
@ -48,7 +52,13 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
|||
$orientation = strtoupper('portrait');
|
||||
|
||||
// Create PDF
|
||||
if ($this->includeFile != null) {
|
||||
// MPDF version 5.*
|
||||
$pdf = new \mpdf();
|
||||
} else {
|
||||
// MPDF version > 6.*
|
||||
$pdf = new \Mpdf\Mpdf();
|
||||
}
|
||||
$pdf->_setPageSize($paperSize, $orientation);
|
||||
$pdf->addPage($orientation);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class Comments extends AbstractPart
|
|||
/**
|
||||
* Comments collection to be written
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Collection\Comments
|
||||
* @var \PhpOffice\PhpWord\Element\Comment[]
|
||||
*/
|
||||
protected $elements;
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ class Comments extends AbstractPart
|
|||
/**
|
||||
* Set element
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Collection\Comments $elements
|
||||
* @param \PhpOffice\PhpWord\Element\Comment[] $elements
|
||||
* @return self
|
||||
*/
|
||||
public function setElements($elements)
|
||||
|
|
|
|||
|
|
@ -27,15 +27,15 @@ use PhpOffice\PhpWord\Settings;
|
|||
*/
|
||||
class ZipArchiveTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* Test close method exception: Working in local, not working in Travis
|
||||
*
|
||||
* expectedException \PhpOffice\PhpWord\Exception\Exception
|
||||
* expectedExceptionMessage Could not close zip file
|
||||
* covers ::close
|
||||
*/
|
||||
public function testCloseException()
|
||||
{
|
||||
// /**
|
||||
// * Test close method exception: Working in local, not working in Travis
|
||||
// *
|
||||
// * expectedException \PhpOffice\PhpWord\Exception\Exception
|
||||
// * expectedExceptionMessage Could not close zip file
|
||||
// * covers ::close
|
||||
// */
|
||||
// public function testCloseException()
|
||||
// {
|
||||
// $zipFile = __DIR__ . "/../_files/documents/ziptest.zip";
|
||||
|
||||
// $object = new ZipArchive();
|
||||
|
|
@ -54,7 +54,7 @@ class ZipArchiveTest extends \PHPUnit\Framework\TestCase
|
|||
// fclose($resource);
|
||||
|
||||
// @unlink($zipFile);
|
||||
}
|
||||
// }
|
||||
|
||||
/**
|
||||
* Test all methods
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ class ODTextTest extends \PHPUnit\Framework\TestCase
|
|||
$section->addText('Test');
|
||||
$writer = new ODText($phpWord);
|
||||
$writer->save('php://output');
|
||||
$this->assertNotNull($this->getActualOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -111,5 +111,6 @@ class RTFTest extends \PHPUnit\Framework\TestCase
|
|||
$section->addText(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
|
||||
$writer = new RTF($phpWord);
|
||||
$writer->save('php://output');
|
||||
$this->assertNotNull($this->getActualOutput());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ class DocumentTest extends \PHPUnit\Framework\TestCase
|
|||
$docInfo->setCustomProperty('key6', new \DateTime());
|
||||
$docInfo->setCustomProperty('key7', time(), DocInfo::PROPERTY_TYPE_DATE);
|
||||
|
||||
TestHelperDOCX::getDocument($phpWord);
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
$this->assertNotNull($doc);
|
||||
|
||||
// $this->assertTrue($doc->elementExists('/Properties/property[name="key1"]/vt:lpwstr'));
|
||||
// $this->assertTrue($doc->elementExists('/Properties/property[name="key2"]/vt:bool'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue