Skip to content

Commit

Permalink
Added support for PHP 8.4 (#2660)
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 authored Jan 7, 2025
1 parent f24aabc commit b285578
Show file tree
Hide file tree
Showing 505 changed files with 1,207 additions and 5,910 deletions.
237 changes: 98 additions & 139 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,165 +1,124 @@
name: CI
on:
pull_request:
push:
branches:
- master
name: PHPWord
on: [push, pull_request]
jobs:
test:
php-cs-fixer:
name: PHP CS Fixer
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "7.1.3"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

name: PHP ${{ matrix.php-version }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP, with composer and extensions
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none

- 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@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Remove lock for old EOL PHP versions
if: matrix.php-version == '7.1.3' || matrix.php-version == '7.2' || matrix.php-version == '7.3' || matrix.php-version == '7.4'
run: rm composer.lock && composer config platform.php ${{ matrix.php-version }}
php-version: '8.3'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
- uses: actions/checkout@v2

- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Validate composer config
run: composer validate --strict

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Composer Install
run: composer global require friendsofphp/php-cs-fixer

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Add environment path
run: export PATH="$PATH:$HOME/.composer/vendor/bin"

- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
- name: Run PHPCSFixer
run: php-cs-fixer fix --dry-run --diff

- name: Test with PHPUnit
run: ./vendor/bin/phpunit --no-coverage

php-cs-fixer:
phpmd:
name: PHP Mess Detector
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: gd, xml, zip
- uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none
tools: cs2pr
- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- 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@v3
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-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
- name: Run phpmd
run: ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude "src/PhpWord/Shared/PCLZip/*"

phpstan:
name: PHP Static Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Disabled PHPStan in '7.1'
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd, xml, zip
- uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none
tools: cs2pr
- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- 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@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Run phpstan
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist

- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Static analysis with PHPStan
run: ./vendor/bin/phpstan analyse

coverage:
phpunit:
name: PHPUnit ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd, xml, zip
coverage: ${{ (matrix.php == '7.3') && 'xdebug' || 'none' }}

- uses: actions/checkout@v2

- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Run phpunit
if: matrix.php != '7.3'
run: ./vendor/bin/phpunit -c phpunit.xml.dist --no-coverage

- name: Run phpunit
if: matrix.php == '7.3'
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml

- name: Upload coverage results to Coveralls
if: matrix.php == '7.3'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
chmod +x php-coveralls.phar
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv
samples:
name: Check samples
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd, xml, zip
coverage: xdebug

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: xdebug
- uses: actions/checkout@v2

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Cache composer dependencies
uses: actions/cache@v3
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: Run phpunit
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
chmod +x php-coveralls.phar
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv
- name: Generate samples files
run: composer run samples
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/composer.lock


.DS_Store
._*
.Spotlight-V100
Expand Down
69 changes: 55 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"homepage": "https://phpoffice.github.io/PHPWord/",
"type": "library",
"license": "LGPL-3.0",
"license": "LGPL-3.0-only",
"authors": [
{
"name": "Mark Baker"
Expand Down Expand Up @@ -49,6 +49,53 @@
],
"fix": [
"@php vendor/bin/php-cs-fixer fix --ansi"
],
"samples": [
"php samples/Sample_01_SimpleText.php",
"php samples/Sample_02_TabStops.php",
"php samples/Sample_03_Sections.php",
"php samples/Sample_04_Textrun.php",
"php samples/Sample_05_Multicolumn.php",
"php samples/Sample_06_Footnote.php",
"php samples/Sample_07_TemplateCloneRow.php",
"php samples/Sample_08_ParagraphPagination.php",
"php samples/Sample_09_Tables.php",
"php samples/Sample_10_EastAsianFontStyle.php",
"php samples/Sample_11_ReadWord97.php",
"php samples/Sample_11_ReadWord2007.php",
"php samples/Sample_12_HeaderFooter.php",
"php samples/Sample_13_Images.php",
"php samples/Sample_14_ListItem.php",
"php samples/Sample_15_Link.php",
"php samples/Sample_16_Object.php",
"php samples/Sample_17_TitleTOC.php",
"php samples/Sample_18_Watermark.php",
"php samples/Sample_19_TextBreak.php",
"php samples/Sample_20_BGColor.php",
"php samples/Sample_21_TableRowRules.php",
"php samples/Sample_22_CheckBox.php",
"php samples/Sample_23_TemplateBlock.php",
"php samples/Sample_24_ReadODText.php",
"php samples/Sample_25_TextBox.php",
"php samples/Sample_26_Html.php",
"php samples/Sample_27_Field.php",
"php samples/Sample_28_ReadRTF.php",
"php samples/Sample_29_Line.php",
"php samples/Sample_30_ReadHTML.php",
"php samples/Sample_31_Shape.php",
"php samples/Sample_32_Chart.php",
"php samples/Sample_33_FormField.php",
"php samples/Sample_34_SDT.php",
"php samples/Sample_35_InternalLink.php",
"php samples/Sample_36_RTL.php",
"php samples/Sample_37_Comments.php",
"php samples/Sample_38_Protection.php",
"php samples/Sample_39_TrackChanges.php",
"php samples/Sample_40_TemplateSetComplexValue.php",
"php samples/Sample_41_TemplateSetChart.php",
"php samples/Sample_42_TemplateSetCheckbox.php",
"php samples/Sample_43_RTLDefault.php",
"php samples/Sample_44_ExtractVariablesFromReaderWord2007.php"
]
},
"scripts-descriptions": {
Expand All @@ -57,34 +104,28 @@
"check": "Runs PHP CheckStyle and PHP Mess detector",
"fix": "Fixes issues found by PHP-CS"
},
"config": {
"platform": {
"php": "8.0"
}
},
"require": {
"php": "^7.1|^8.0",
"ext-dom": "*",
"ext-gd": "*",
"ext-json": "*",
"ext-xml": "*",
"ext-zip": "*",
"phpoffice/math": "^0.2"
},
"require-dev": {
"ext-zip": "*",
"ext-gd": "*",
"ext-libxml": "*",
"dompdf/dompdf": "^2.0 || ^3.0",
"mpdf/mpdf": "^8.1",
"friendsofphp/php-cs-fixer": "^3.3",
"mpdf/mpdf": "^7.0 || ^8.0",
"phpmd/phpmd": "^2.13",
"phpstan/phpstan": "^0.12.88 || ^1.0.0",
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
"phpunit/phpunit": ">=7.0",
"tecnickcom/tcpdf": "^6.5",
"symfony/process": "^4.4 || ^5.0",
"friendsofphp/php-cs-fixer": "^3.3",
"phpstan/phpstan-phpunit": "@stable"
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"ext-zip": "Allows writing OOXML and ODF",
"ext-gd2": "Allows adding images",
"ext-xmlwriter": "Allows writing OOXML and ODF",
"ext-xsl": "Allows applying XSL style sheet to headers, to main document part, and to footers of an OOXML template",
"dompdf/dompdf": "Allows writing PDF"
Expand Down
Loading

0 comments on commit b285578

Please sign in to comment.