From c3e34a0d24070d7f52014c9ca6229d3f252f73c8 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 25 Sep 2022 21:43:00 +0200 Subject: [PATCH] Support for PHP7.1 (min.) --- .github/workflows/ci.yml | 43 ++++--------------- composer.json | 11 ++--- tests/PhpWordTests/Shared/HtmlTest.php | 16 +++---- .../Writer/Word2007/Part/DocumentTest.php | 2 +- 4 files changed, 22 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56b4a86b05..d9b2596624 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,9 @@ jobs: strategy: matrix: php-version: + - "7.1" + - "7.2" + - "7.3" - "7.4" - "8.0" - "8.1" @@ -76,42 +79,14 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Code style with PHP-CS-Fixer - run: ./vendor/bin/php-cs-fixer fix --dry-run --show-progress=none --using-cache=no -v --format=checkstyle | cs2pr - - phpcs: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Composer Install + run: composer global require friendsofphp/php-cs-fixer - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib - coverage: none - tools: cs2pr + - name: Add environment path + run: export PATH="$PATH:$HOME/.composer/vendor/bin" - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Code style with PHP_CodeSniffer - run: ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip --report=checkstyle | cs2pr + - name: Code style with PHP-CS-Fixer + run: php-cs-fixer fix --dry-run --diff coverage: runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index eac537ff72..f95fbe739e 100644 --- a/composer.json +++ b/composer.json @@ -58,26 +58,23 @@ "fix": "Fixes issues found by PHP-CS" }, "require": { - "php": "^7.4 || ^8.0", + "php": "^7.1|^8.0", "ext-dom": "*", "ext-json": "*", "ext-xml": "*", - "laminas/laminas-escaper": "^2.10" + "laminas/laminas-escaper": ">=2.6" }, "require-dev": { "ext-zip": "*", "ext-gd": "*", "ext-libxml": "*", "dompdf/dompdf": "^2.0", - "friendsofphp/php-cs-fixer": "^3.11", "mpdf/mpdf": "^8.1", "php-coveralls/php-coveralls": "^2.5", - "phploc/phploc": "^7.0", "phpmd/phpmd": "^2.13", - "phpunit/phpunit": "^9.5", - "squizlabs/php_codesniffer": "^3.7", + "phpunit/phpunit": ">=7.0", "tecnickcom/tcpdf": "^6.5", - "symfony/process": "^5.4" + "symfony/process": "^4.4" }, "suggest": { "ext-zip": "Allows writing OOXML and ODF", diff --git a/tests/PhpWordTests/Shared/HtmlTest.php b/tests/PhpWordTests/Shared/HtmlTest.php index cd2338e18e..9de29933e4 100644 --- a/tests/PhpWordTests/Shared/HtmlTest.php +++ b/tests/PhpWordTests/Shared/HtmlTest.php @@ -501,15 +501,15 @@ public function testParseTableCellspacingRowBgColor(): void public function testParseTableStyleAttributeInlineStyle(): void { $phpWord = new PhpWord(); - $section = $phpWord->addSection(); + $section = $phpWord->addSection([ + 'orientation' => \PhpOffice\PhpWord\Style\Section::ORIENTATION_LANDSCAPE, + ]); - $html = << - - A - - - HTML; + $html = ' + + + +
A
'; Html::addHtml($section, $html); $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); diff --git a/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php index 00582e12ab..98449f3b6d 100644 --- a/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php @@ -408,7 +408,7 @@ public function testWriteImage(): void // behind $element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:pict/v:shape'); $style = $element->getAttribute('style'); - self::assertMatchesRegularExpression('/z\-index:\-[0-9]*/', $style); + self::assertRegExp('/z\-index:\-[0-9]*/', $style); // square $element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:pict/v:shape/w10:wrap');