From 1d37592c24cb9897e1fc84817b9231d462b998a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Jensen?= Date: Tue, 5 Mar 2024 18:16:03 +0100 Subject: [PATCH] v1.1 --- .github/workflows/acceptance.yml | 172 +++++++++++-------------------- README.md | 1 + composer.json | 60 +++++------ phpunit.xml.dist | 26 +++-- src/Phrity/Util/ErrorHandler.php | 3 +- 5 files changed, 106 insertions(+), 156 deletions(-) diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index 6fd2287..3eff1c1 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -3,141 +3,91 @@ name: Acceptance on: [push, pull_request] jobs: - test-7-2: - runs-on: ubuntu-latest - name: Test PHP 7.2 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 7.2 - uses: shivammathur/setup-php@v2 - with: - php-version: '7.2' - - name: Composer - run: make deps-install - - name: Test - run: make test - test-7-3: + test: + strategy: + matrix: + php-versions: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] runs-on: ubuntu-latest - name: Test PHP 7.3 + name: Unit test steps: - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 7.3 + uses: actions/checkout@v4 + - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.3' - - name: Composer - run: make deps-install - - name: Test - run: make test - - test-7-4: - runs-on: ubuntu-latest - name: Test PHP 7.4 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 7.4 - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - - name: Composer - run: make deps-install - - name: Test - run: make test - - test-8-0: - runs-on: ubuntu-latest - name: Test PHP 8.0 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 8.0 - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - - name: Composer - run: make deps-install - - name: Test - run: make test - - test-8-1: - runs-on: ubuntu-latest - name: Test PHP 8.1 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 8.1 - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: pdo, pdo-sqlite - - name: Composer - run: make deps-install - - name: Test - run: make test - - test-8-2: - runs-on: ubuntu-latest - name: Test PHP 8.2 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 8.2 - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - - name: Composer - run: make deps-install - - name: Test - run: make test - - test-8-3: - runs-on: ubuntu-latest - name: Test PHP 8.3 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 8.3 - uses: shivammathur/setup-php@v2 + php-version: ${{ matrix.php-versions }} + coverage: none + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v4 with: - php-version: '8.3' - - name: Composer - run: make deps-install + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies + run: composer install --prefer-dist - name: Test - run: make test + run: vendor/bin/phpunit cs-check: runs-on: ubuntu-latest name: Code standard steps: - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 8.2 + uses: actions/checkout@v4 + - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' - - name: Composer - run: make deps-install + php-version: "8.3" + coverage: none + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies + run: composer install --prefer-dist - name: Code standard - run: make cs-check + run: vendor/bin/phpcs --standard=PSR1,PSR12 --encoding=UTF-8 --report=full --colors src tests coverage: runs-on: ubuntu-latest name: Code coverage steps: - name: Checkout - uses: actions/checkout@v3 - - name: Set up PHP 8.0 + uses: actions/checkout@v4 + - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' - extensions: xdebug - - name: Composer - run: make deps-install - - name: Code coverage + php-version: "8.3" + coverage: xdebug + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies + run: composer install --prefer-dist + - name: Code coverage build + run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml + - name: Code coverage upload env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: make coverage + run: vendor/bin/php-coveralls -v diff --git a/README.md b/README.md index 69fad5f..a634491 100644 --- a/README.md +++ b/README.md @@ -143,4 +143,5 @@ Phrity\Util\ErrorHandler { | Version | PHP | | | --- | --- | --- | +| `1.1` | `^7.4\|^8.0` | Some improvements | | `1.0` | `^7.2\|^8.0` | Initial version | diff --git a/composer.json b/composer.json index d2f78a7..6b2877c 100644 --- a/composer.json +++ b/composer.json @@ -1,33 +1,33 @@ { - "name": "phrity/util-errorhandler", - "type": "library", - "description": "Inline error handler; catch and resolve errors for code block.", - "homepage": "https://phrity.sirn.se/util-errorhandler", - "keywords": ["error", "warning"], - "license": "MIT", - "authors": [ - { - "name": "Sören Jensen", - "email": "sirn@sirn.se", - "homepage": "https://phrity.sirn.se" + "name": "phrity/util-errorhandler", + "type": "library", + "description": "Inline error handler; catch and resolve errors for code block.", + "homepage": "https://phrity.sirn.se/util-errorhandler", + "keywords": ["error", "warning"], + "license": "MIT", + "authors": [ + { + "name": "Sören Jensen", + "email": "sirn@sirn.se", + "homepage": "https://phrity.sirn.se" + } + ], + "autoload": { + "psr-4": { + "": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "": "tests/" + } + }, + "require": { + "php": "^7.4 | ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0 | ^10.0 | ^11.0", + "php-coveralls/php-coveralls": "^2.0", + "squizlabs/php_codesniffer": "^3.5" } - ], - "autoload": { - "psr-4": { - "": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "": "tests/" - } - }, - "require": { - "php": "^7.2|^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^8.0|^9.0|^10.0", - "php-coveralls/php-coveralls": "^2.0", - "squizlabs/php_codesniffer": "^3.5" - } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8d0b5f2..7a77f4f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,15 +1,13 @@ - - - - - ./tests/ - - - - - - ./src/ - - - \ No newline at end of file + + + + ./src/ + + + + + ./tests/ + + + diff --git a/src/Phrity/Util/ErrorHandler.php b/src/Phrity/Util/ErrorHandler.php index 7eb42bb..ba38462 100644 --- a/src/Phrity/Util/ErrorHandler.php +++ b/src/Phrity/Util/ErrorHandler.php @@ -60,8 +60,9 @@ public function with(callable $callback, $handling = null, int $levels = E_ALL) $result = $callback(); } catch (ErrorException $e) { $error = $this->handle($handling, $e); + } finally { + $this->restore(); } - $this->restore(); return $error ?: $result; }