From b4d5248bddcf28b2c8b3531c5f38544a14959ccd Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Wed, 25 Nov 2026 20:04:48 +0400 Subject: [PATCH 1/3] feat: add PHP 8.6 support test: adapt HtmlRenderer test to PHP 8.6 error message PHP 8.6 no longer includes the file name in the `file()` warning prefix. Psalm does not support PHP 8.6 yet, so the static analysis matrix stays at 8.5. Assisted-By: Claude Opus 5.5 --- .github/workflows/build.yml | 2 +- .github/workflows/composer-dependency-analyser.yml | 2 +- CHANGELOG.md | 1 + README.md | 2 +- composer.json | 4 ++-- tests/Renderer/HtmlRendererTest.php | 8 +++++++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 277e015..4b215cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,4 +30,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4', '8.5'] + ['8.1', '8.2', '8.3', '8.4', '8.5', '8.6'] diff --git a/.github/workflows/composer-dependency-analyser.yml b/.github/workflows/composer-dependency-analyser.yml index 06a8cbe..963a949 100644 --- a/.github/workflows/composer-dependency-analyser.yml +++ b/.github/workflows/composer-dependency-analyser.yml @@ -26,4 +26,4 @@ jobs: uses: yiisoft/actions/.github/workflows/composer-dependency-analyser.yml@master with: php: >- - ['8.1', '8.2', '8.3', '8.4', '8.5'] + ['8.1', '8.2', '8.3', '8.4', '8.5', '8.6'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 070d6c3..bb4b946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Bug #176: Remove unused `ext-dom` dependency (@samdark) - Chg #170: Make all parameters of `ErrorException` constructor required (@vjik) - New #171: Add `$traceFileMap` parameter to `HtmlRenderer` for mapping file paths in trace links (@WarLikeLaux) +- Enh #192: Add PHP 8.6 support (@roxblnfk) ## 4.3.2 January 09, 2026 diff --git a/README.md b/README.md index bd60938..991a683 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The package provides advanced error handling. The features are: ## Requirements -- PHP 8.1 - 8.5. +- PHP 8.1 - 8.6. - `mbstring` PHP extension. ## Installation diff --git a/composer.json b/composer.json index 2bebcaf..793ccfa 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } ], "require": { - "php": "8.1 - 8.5", + "php": "8.1 - 8.6", "ext-mbstring": "*", "alexkart/curl-builder": "^1.0", "cebe/markdown": "^1.2", @@ -54,7 +54,7 @@ "rector/rector": "^2.1.3", "shipmonk/composer-dependency-analyser": "^1.8", "spatie/phpunit-watcher": "^1.24", - "vimeo/psalm": "^5.26.1 || ^6.13.1", + "vimeo/psalm": "^6.21 || ^7.20", "yiisoft/di": "^1.4", "yiisoft/test-support": "^3.0.2" }, diff --git a/tests/Renderer/HtmlRendererTest.php b/tests/Renderer/HtmlRendererTest.php index 6b2f22a..037c5c3 100644 --- a/tests/Renderer/HtmlRendererTest.php +++ b/tests/Renderer/HtmlRendererTest.php @@ -36,6 +36,7 @@ use function sprintf; use const DIRECTORY_SEPARATOR; +use const PHP_VERSION_ID; final class HtmlRendererTest extends TestCase { @@ -402,7 +403,12 @@ static function (int $code, string $message) use (&$errorMessage) { restore_error_handler(); $this->assertSame('', $result); - $this->assertSame('file(not-exist): Failed to open stream: No such file or directory', $errorMessage); + $this->assertSame( + PHP_VERSION_ID >= 80600 + ? 'file(): Failed to open stream: No such file or directory' + : 'file(not-exist): Failed to open stream: No such file or directory', + $errorMessage, + ); } public function testRenderCallStackWithErrorException(): void From c3b89e65426a4a7855fe6da9b22036273906c473 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Wed, 25 Nov 2026 20:16:21 +0400 Subject: [PATCH 2/3] fix: escape cURL command in HTML debug output chore: fix Psalm 7 issues Psalm 7 enables taint analysis, which found that the cURL block in `development.php` printed the command (built from the request or an exception message) without escaping. The other reports are false positives: `ReflectionClass` received an object, the template closure reads its arguments via `func_get_arg()` on purpose, and `ErrorHandler` echoes already rendered output. Assisted-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + src/ErrorHandler.php | 1 + src/Renderer/HtmlRenderer.php | 6 +++--- templates/development.php | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb4b946..d88e404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Chg #170: Make all parameters of `ErrorException` constructor required (@vjik) - New #171: Add `$traceFileMap` parameter to `HtmlRenderer` for mapping file paths in trace links (@WarLikeLaux) - Enh #192: Add PHP 8.6 support (@roxblnfk) +- Bug #192: Escape cURL command in HTML debug output (@roxblnfk) ## 4.3.2 January 09, 2026 diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php index 00dc35a..31e8f5f 100644 --- a/src/ErrorHandler.php +++ b/src/ErrorHandler.php @@ -220,6 +220,7 @@ private function renderThrowableAndTerminate(Throwable $t): void // Set preventive HTTP status code to 500 in case error handling somehow fails and headers are sent. http_response_code(Status::INTERNAL_SERVER_ERROR); + /** @psalm-suppress TaintedInput Escaping the output is the renderer's responsibility. */ echo $this->handle($t); $this->eventDispatcher?->dispatch(new ApplicationError($t)); diff --git a/src/Renderer/HtmlRenderer.php b/src/Renderer/HtmlRenderer.php index e86b1c9..e1097df 100644 --- a/src/Renderer/HtmlRenderer.php +++ b/src/Renderer/HtmlRenderer.php @@ -16,10 +16,10 @@ use Yiisoft\ErrorHandler\ThrowableRendererInterface; use Yiisoft\FriendlyException\FriendlyExceptionInterface; use Yiisoft\Http\Header; -use ReflectionClass; use ReflectionException; use ReflectionFunction; use ReflectionMethod; +use ReflectionObject; use function array_values; use function dirname; @@ -583,7 +583,7 @@ public function removeAnonymous(string $value): string */ private function getThrowableDescription(Throwable $throwable): ?string { - $docComment = (new ReflectionClass($throwable))->getDocComment(); + $docComment = (new ReflectionObject($throwable))->getDocComment(); if ($docComment === false) { return null; } @@ -701,7 +701,7 @@ private function renderTemplate(string $path, array $parameters): string ob_implicit_flush(false); try { - /** @psalm-suppress PossiblyNullFunctionCall */ + /** @psalm-suppress PossiblyNullFunctionCall, TooManyArguments */ $renderer->bindTo($this)($path, $parameters); return (string) ob_get_clean(); } catch (Throwable $e) { diff --git a/templates/development.php b/templates/development.php index e446977..1ff319d 100644 --- a/templates/development.php +++ b/templates/development.php @@ -128,12 +128,12 @@ class="copy-clipboard" renderCurl($request)) !== 'curl'): ?>