Skip to content

Commit

Permalink
Fix compatibility issues with PHP 7.3 (#1316)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Aug 1, 2023
2 parents 260104f + 7771393 commit 0ae3d99
Show file tree
Hide file tree
Showing 13 changed files with 893 additions and 1,316 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Expand Up @@ -21,6 +21,8 @@ body:
description: What version of PHP do you have installed?
multiple: true
options:
- PHP 7.3
- PHP 7.4
- PHP 8.0
- PHP 8.1
- PHP 8.2
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/codecov.yml
Expand Up @@ -25,8 +25,29 @@ jobs:
tools: composer:v2
extensions: mongodb, redis

- name: Install locked dependencies
uses: ramsey/composer-install@v2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache 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
working-directory: ${{ github.workspace }}
run: |
composerCommand="install"
composerOptions=("--no-interaction" "--no-progress" "--ansi")
# Use `update` if there is no composer.lock file
if [ ! -f "composer.lock" ]; then
composerCommand="update"
fi
fullCommand="composer ${composerCommand} ${composerOptions[*]}"
echo "Running: ${fullCommand}"
${fullCommand}
- name: Run PHPUnit to collect coverage
run: composer phpunit:coverage
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/psalm.yml
Expand Up @@ -23,12 +23,33 @@ jobs:
- name: Set up php
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 7.3
coverage: pcov
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache 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
uses: ramsey/composer-install@v2
working-directory: ${{ github.workspace }}
run: |
composerCommand="install"
composerOptions=("--no-interaction" "--no-progress" "--ansi")
# Use `update` if there is no composer.lock file
if [ ! -f "composer.lock" ]; then
composerCommand="update"
fi
fullCommand="composer ${composerCommand} ${composerOptions[*]}"
echo "Running: ${fullCommand}"
${fullCommand}
- name: Run Psalm
run: composer psalm
35 changes: 30 additions & 5 deletions .github/workflows/tests.yml
Expand Up @@ -15,11 +15,11 @@ jobs:

strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
dependencies: ['lowest','highest','locked']
dev: ['8.3']

continue-on-error: ${{ matrix.php == matrix.dev }}
continue-on-error: ${{ matrix.php == matrix.dev || matrix.dependencies == 'lowest' }}

steps:
- name: Checkout Code
Expand All @@ -40,10 +40,35 @@ jobs:
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install ${{ matrix.dependencies }} Dependencies
uses: ramsey/composer-install@v2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
dependency-versions: ${{ matrix.dependencies }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-

- name: Install ${{ matrix.dependencies }} dependencies
working-directory: ${{ github.workspace }}
run: |
composerDependency="${{ matrix.dependencies }}"
composerCommand="update"
composerOptions=("--no-interaction" "--no-progress" "--ansi")
case ${composerDependency} in
highest) composerCommand="update" ;;
lowest) composerOptions+=("--prefer-lowest" "--prefer-stable") ;;
*) composerCommand="install" ;;
esac
# Use `update` if there is no composer.lock file
if [ ! -f "composer.lock" ]; then
composerCommand="update"
fi
fullCommand="composer ${composerCommand} ${composerOptions[*]}"
echo "Running: ${fullCommand}"
${fullCommand}
- name: Execute PHPUnit
run: composer phpunit
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -20,7 +20,11 @@ docs/api/index.html: vendor/composer/installed.json $(library_files) phpDocument
docker run -it --rm -v $$PWD:/opt/mockery -w /opt/mockery ghcr.io/ghostwriter/php:8.1-pcov php phpDocumentor.phar run -d src -t docs/api

.PHONY: test-all
test-all: test-83 test-82 test-81 test-80 test-74
test-all: test-83 test-82 test-81 test-80 test-74 test-73

.PHONY: test-73
test-73: deps
docker run -it --rm -v $$PWD:/opt/mockery -w /opt/mockery ghcr.io/ghostwriter/php:7.3-pcov php vendor/bin/phpunit

.PHONY: test-74
test-74: deps
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -44,15 +44,15 @@
"security": "https://github.com/mockery/mockery/security/advisories"
},
"require": {
"php": ">=7.4,<8.3",
"php": ">=7.3",
"lib-pcre": ">=7.0",
"hamcrest/hamcrest-php": "^2.0.1"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.3",
"phpunit/phpunit": "^8.5 || ^9.6.10",
"psalm/plugin-phpunit": "^0.18.4",
"symplify/easy-coding-standard": "^11.5.0",
"vimeo/psalm": "^5.13.1"
"vimeo/psalm": "^4.30"
},
"conflict": {
"phpunit/phpunit": "<8.0"
Expand All @@ -79,7 +79,7 @@
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.4.999"
"php": "7.3.999"
},
"preferred-install": "dist",
"sort-packages": true
Expand Down

0 comments on commit 0ae3d99

Please sign in to comment.