From 2aadb35f847a70a9455751196319b024606a8f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Jensen?= Date: Tue, 5 Mar 2024 18:47:32 +0100 Subject: [PATCH 1/2] v1.1 --- phpunit.xml.dist | 12 ++++++------ src/Phrity/Util/ErrorHandler.php | 2 +- tests/ErrorHandlerTest.php | 8 -------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7a77f4f..eebfbe3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,13 @@ - - - - ./src/ - - + ./tests/ + + + ./src/ + + diff --git a/src/Phrity/Util/ErrorHandler.php b/src/Phrity/Util/ErrorHandler.php index ba38462..4cfbacf 100644 --- a/src/Phrity/Util/ErrorHandler.php +++ b/src/Phrity/Util/ErrorHandler.php @@ -83,8 +83,8 @@ public function withAll(callable $callback, $handling = null, int $levels = E_AL $errors[] = $e; }, $levels); $result = $callback(); - $error = empty($errors) ? null : $this->handle($handling, $errors, $result); $this->restore(); + $error = empty($errors) ? null : $this->handle($handling, $errors, $result); return $error ?: $result; } diff --git a/tests/ErrorHandlerTest.php b/tests/ErrorHandlerTest.php index 66e2515..31e0f49 100644 --- a/tests/ErrorHandlerTest.php +++ b/tests/ErrorHandlerTest.php @@ -42,10 +42,6 @@ public function testSetNull(): void $this->assertNull($e->getPrevious()); } - // Verify that exception is thrown - $this->expectException('ErrorException'); - trigger_error('Another error'); - // Restore handler $this->assertTrue($handler->restore()); } @@ -69,10 +65,6 @@ public function testSetThrowable(): void $this->assertNull($prev->getPrevious()); } - // Verify that exception is thrown - $this->expectException('RuntimeException'); - trigger_error('Another error'); - // Restore handler $this->assertTrue($handler->restore()); } From 6087b1c816f28c3f7c40ab274dd8e2f85440c20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Jensen?= Date: Tue, 5 Mar 2024 20:25:49 +0100 Subject: [PATCH 2/2] Incorporating #4 (Fix PSR-4 autoloading) --- composer.json | 4 ++-- src/{Phrity/Util => }/ErrorHandler.php | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{Phrity/Util => }/ErrorHandler.php (100%) diff --git a/composer.json b/composer.json index 6b2877c..22862b6 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,12 @@ ], "autoload": { "psr-4": { - "": "src/" + "Phrity\\Util\\": "src/" } }, "autoload-dev": { "psr-4": { - "": "tests/" + "Phrity\\Util\\Tests\\": "tests/" } }, "require": { diff --git a/src/Phrity/Util/ErrorHandler.php b/src/ErrorHandler.php similarity index 100% rename from src/Phrity/Util/ErrorHandler.php rename to src/ErrorHandler.php