diff --git a/src/Exception/Failure/FailureConverter.php b/src/Exception/Failure/FailureConverter.php index d7344c74..099f2385 100644 --- a/src/Exception/Failure/FailureConverter.php +++ b/src/Exception/Failure/FailureConverter.php @@ -351,10 +351,9 @@ private static function generateStackTraceString(\Throwable $e, bool $skipIntern return \implode("\n", $result); } - private static function renderTraceAttributes(?array $args): string + private static function renderTraceAttributes(array $args): string { - /** @psalm-suppress RiskyTruthyFalsyComparison */ - if (empty($args)) { + if ($args === []) { return ''; } diff --git a/tests/Unit/Exception/FailureConverterTestCase.php b/tests/Unit/Exception/FailureConverterTestCase.php index 8cb76a9a..6772d3e8 100644 --- a/tests/Unit/Exception/FailureConverterTestCase.php +++ b/tests/Unit/Exception/FailureConverterTestCase.php @@ -32,7 +32,7 @@ public function testApplicationFailureCanTransferData(): void $this->assertSame(123, $restoredDetails->getValue(1)); } - public function testShouldSetStackTraceStringForAdditionalContext(): void + public function testStackTraceStringForAdditionalContext(): void { $trace = FailureConverter::mapExceptionToFailure( new Exception(), @@ -40,7 +40,7 @@ public function testShouldSetStackTraceStringForAdditionalContext(): void )->getStackTrace(); self::assertStringContainsString( - 'Temporal\Tests\Unit\Exception\FailureConverterTestCase->testShouldSetStackTraceStringForAdditionalContext()', + 'Temporal\Tests\Unit\Exception\FailureConverterTestCase->testStackTraceStringForAdditionalContext()', $trace, ); @@ -50,14 +50,19 @@ public function testShouldSetStackTraceStringForAdditionalContext(): void ); } - public function testShouldSetStackTraceStringForAdditionalContextEvenWhenClassIsNotPresented(): void + public function testStackTraceStringForAdditionalContextEvenWhenClassIsNotPresented(): void { + $previous = \ini_get('zend.exception_ignore_args'); \ini_set('zend.exception_ignore_args', 'Off'); - $trace = FailureConverter::mapExceptionToFailure( - call_user_func(fn () => new Exception()), - DataConverter::createDefault(), - )->getStackTrace(); + try { + $trace = FailureConverter::mapExceptionToFailure( + call_user_func(fn () => new Exception()), + DataConverter::createDefault(), + )->getStackTrace(); + } finally { + \ini_set('zend.exception_ignore_args', $previous); + } self::assertStringContainsString( '[internal function]', @@ -79,4 +84,24 @@ public function testShouldSetStackTraceStringForAdditionalContextEvenWhenClassIs $trace, ); } + + public function testStackTraceStringWithoutExceptionArgs(): void + { + $previous = \ini_get('zend.exception_ignore_args'); + \ini_set('zend.exception_ignore_args', 'On'); + + try { + $trace = FailureConverter::mapExceptionToFailure( + call_user_func(static fn() => new Exception()), + DataConverter::createDefault(), + )->getStackTrace(); + } finally { + \ini_set('zend.exception_ignore_args', $previous); + } + + self::assertStringContainsString( + 'call_user_func()', + $trace, + ); + } }