diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8a4ee0b..5331282 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,24 +1,13 @@ version: 2 updates: - - package-ecosystem: "composer" directory: "/" schedule: interval: "weekly" - commit-message: - include: "scope" - prefix: "composer" - labels: - - "enhancement" versioning-strategy: "widen" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" - commit-message: - include: "scope" - prefix: "github-actions" - labels: - - "enhancement" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..5ac182f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,102 @@ +name: "CI" + +on: + pull_request: + push: + branches: + - "master" + +env: + INI_VALUES: zend.assertions=1,error_reporting=-1 + +jobs: + composer-json-lint: + name: "Lint composer.json" + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.1" + + steps: + - uses: "actions/checkout@v3" + - uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + ini-values: "${{ env.INI_VALUES }}" + tools: composer-normalize,composer-require-checker,composer-unused + - uses: "ramsey/composer-install@v2" + + - run: "composer validate --strict" + - run: "composer-normalize --dry-run" + - run: "composer-require-checker check --config-file=$(realpath composer-require-checker.json)" + - run: "composer-unused" + + tests: + name: "Tests" + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.2" + code-coverage: + - "none" + include: + - php-version: "8.1" + code-coverage: "pcov" + + steps: + - uses: "actions/checkout@v3" + - uses: "shivammathur/setup-php@v2" + with: + coverage: "${{ matrix.code-coverage }}" + php-version: "${{ matrix.php-version }}" + ini-values: "${{ env.INI_VALUES }}" + - uses: "ramsey/composer-install@v2" + + - run: "vendor/bin/phpunit --no-coverage --no-logging" + if: ${{ matrix.code-coverage == 'none' }} + timeout-minutes: 1 + + - run: "vendor/bin/phpunit" + if: ${{ matrix.code-coverage != 'none' }} + timeout-minutes: 1 + + coding-standards: + name: "Coding Standards" + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.1" + + steps: + - uses: "actions/checkout@v3" + - uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + ini-values: "${{ env.INI_VALUES }}" + - uses: "ramsey/composer-install@v2" + + - run: "vendor/bin/php-cs-fixer fix --verbose --dry-run --diff" + + static-analysis: + name: "Static Analysis" + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.1" + + steps: + - uses: "actions/checkout@v3" + - uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + ini-values: "${{ env.INI_VALUES }}" + - uses: "ramsey/composer-install@v2" + + - run: "vendor/bin/phpstan analyse --no-progress --error-format=github" diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml deleted file mode 100644 index 8a56a98..0000000 --- a/.github/workflows/integrate.yaml +++ /dev/null @@ -1,181 +0,0 @@ -name: "Integrate" - -on: - pull_request: - push: - branches: - - "master" - -jobs: - composer-json-lint: - name: "Lint composer.json" - - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.1" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - tools: composer-normalize, composer-require-checker, composer-unused - - - name: "Get composer cache directory" - id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer- - - - name: "Install dependencies" - run: "composer update --no-interaction --no-progress" - - - name: "Validate composer.json" - run: "composer validate --strict" - - - name: "Normalize composer.json" - run: "composer-normalize --dry-run" - - - name: "Check composer.json explicit dependencies" - run: "composer-require-checker check --config-file=$(realpath composer-require-checker.json)" - - - name: "Check composer.json unused dependencies" - run: "composer-unused" - - tests: - name: "Tests" - - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.2" - code-coverage: - - "none" - include: - - php-version: "8.1" - code-coverage: "pcov" - - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "${{ matrix.code-coverage }}" - php-version: "${{ matrix.php-version }}" - ini-values: zend.assertions=1 - - - name: "Get composer cache directory" - id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer- - - - name: "Install dependencies" - run: "composer update --no-interaction --no-progress" - - - name: "Run tests" - if: ${{ matrix.code-coverage == 'none' }} - timeout-minutes: 1 - run: "vendor/bin/phpunit --no-coverage --no-logging" - - - name: "Run tests" - if: ${{ matrix.code-coverage != 'none' }} - timeout-minutes: 1 - run: "vendor/bin/phpunit" - - coding-standards: - name: "Coding Standards" - - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.1" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - - - name: "Get composer cache directory" - id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer- - - - name: "Install dependencies" - run: "composer update --no-interaction --no-progress" - - - name: "Check coding standards" - run: "vendor/bin/php-cs-fixer fix --verbose --dry-run --diff" - - static-analysis: - name: "Static Analysis" - - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.1" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - ini-values: zend.assertions=1 - - - name: "Get composer cache directory" - id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer- - - - name: "Install dependencies" - run: "composer update --no-interaction --no-progress" - - - name: "Run static analysis" - run: "vendor/bin/phpstan analyse --no-progress --error-format=github" diff --git a/.gitignore b/.gitignore index 2f28ed8..77897c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.idea/ -/coverage/ +/.phpunit.cache/ /vendor/ +/coverage/ /.php-cs-fixer.cache /.phpunit.result.cache /composer.lock diff --git a/Makefile b/Makefile index 43345c2..e3f621e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,23 @@ +CSFIX_PHP_BIN=PHP_CS_FIXER_IGNORE_ENV=1 php8.2 +PHP_BIN=php8.2 -d zend.assertions=1 +COMPOSER_BIN=$(shell command -v composer) + all: csfix static-analysis test @echo "Done." vendor: composer.json - composer update - composer bump + $(PHP_BIN) $(COMPOSER_BIN) update + $(PHP_BIN) $(COMPOSER_BIN) bump touch vendor .PHONY: csfix csfix: vendor - vendor/bin/php-cs-fixer fix --verbose + $(CSFIX_PHP_BIN) vendor/bin/php-cs-fixer fix -v $(arg) .PHONY: static-analysis static-analysis: vendor - php -d zend.assertions=1 vendor/bin/phpstan analyse + $(PHP_BIN) vendor/bin/phpstan analyse $(PHPSTAN_ARGS) .PHONY: test test: vendor - php -d zend.assertions=1 vendor/bin/phpunit + $(PHP_BIN) vendor/bin/phpunit $(PHPUNIT_ARGS) diff --git a/README.md b/README.md index e9205f4..a54bc1c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # php-errorhandler-legacy [![Latest Stable Version](https://img.shields.io/packagist/v/slam/php-errorhandler-legacy.svg)](https://packagist.org/packages/slam/php-errorhandler-legacy) -[![Integrate](https://github.com/Slamdunk/php-errorhandler-legacy/workflows/Integrate/badge.svg?branch=master)](https://github.com/Slamdunk/php-errorhandler-legacy/actions) +[![Downloads](https://img.shields.io/packagist/dt/slam/php-errorhandler-legacy.svg)](https://packagist.org/packages/slam/php-errorhandler-legacy) +[![Integrate](https://github.com/Slamdunk/php-errorhandler-legacy/workflows/CI/badge.svg)](https://github.com/Slamdunk/php-errorhandler-legacy/actions) Crappy class to manage errors and exceptions diff --git a/composer.json b/composer.json index 529afa2..036eadd 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,13 @@ "php": "~8.1.0 || ~8.2.0" }, "require-dev": { - "phpstan/phpstan": "^1.9.6", - "phpstan/phpstan-phpunit": "^1.3.3", - "phpstan/phpstan-strict-rules": "^1.4.4", - "phpunit/phpunit": "^9.5.27", + "phpstan/phpstan": "^1.9.17", + "phpstan/phpstan-phpunit": "^1.3.4", + "phpstan/phpstan-strict-rules": "^1.4.5", + "phpunit/phpunit": "^10.0.7", "slam/php-cs-fixer-extensions": "^3.3", "slam/php-debug-r": "^1.7.0", - "symfony/console": "^6.2.3" + "symfony/console": "^6.2.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index a1bb563..354aa8c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,17 +1,17 @@ - ./lib - - + + diff --git a/tests/ErrorHandlerTest.php b/tests/ErrorHandlerTest.php index 097ce6b..a8cd135 100644 --- a/tests/ErrorHandlerTest.php +++ b/tests/ErrorHandlerTest.php @@ -5,6 +5,8 @@ namespace SlamTest\ErrorHandler; use ErrorException; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use RuntimeException; use Slam\ErrorHandler\ErrorHandler; @@ -13,16 +15,13 @@ final class ErrorHandlerTest extends TestCase { private string $backupErrorLog; - private string $errorLog; - private ErrorException $exception; /** * @var array> */ private array $emailsSent = []; - private ErrorHandler $errorHandler; protected function setUp(): void @@ -78,11 +77,8 @@ public function testDefaultConfiguration(): void self::assertSame($memoryStream, $errorHandler->getErrorOutputStream()); } - /** - * @runInSeparateProcess - * - * @preserveGlobalState disabled - */ + #[RunInSeparateProcess] + #[PreserveGlobalState(false)] public function testRegisterBuiltinHandlers(): void { $this->errorHandler->register(); @@ -94,11 +90,8 @@ public function testRegisterBuiltinHandlers(): void $arrayPerVerificaErrori['undefined_index']; } - /** - * @runInSeparateProcess - * - * @preserveGlobalState disabled - */ + #[RunInSeparateProcess] + #[PreserveGlobalState(false)] public function testScream(): void { $scream = [