From c24cc5d204bc594611239a2793ecfe1424894b65 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Wed, 25 Jan 2023 17:20:23 -0600 Subject: [PATCH] Fixes #7 --- composer.lock | 76 ++++++++++++------------- lib/Catcher.php | 6 +- run | 24 +------- tests/cases/TestCatcher.php | 2 +- tests/cases/TestThrowableController.php | 5 +- tests/docroot/testDispatch.php | 19 ------- 6 files changed, 48 insertions(+), 84 deletions(-) delete mode 100644 tests/docroot/testDispatch.php diff --git a/composer.lock b/composer.lock index 0251e6d..f5d1dba 100644 --- a/composer.lock +++ b/composer.lock @@ -60,30 +60,30 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -110,7 +110,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -126,7 +126,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "eloquent/phony", @@ -452,16 +452,16 @@ }, { "name": "mensbeam/intl", - "version": "0.9.1", + "version": "0.9.2", "source": { "type": "git", "url": "https://github.com/mensbeam/intl.git", - "reference": "07d26e3f45c3a3167eb6389572419d3bda7ff5e1" + "reference": "88dbf8398ab69e71164ac073f9ec011be2baa4ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mensbeam/intl/zipball/07d26e3f45c3a3167eb6389572419d3bda7ff5e1", - "reference": "07d26e3f45c3a3167eb6389572419d3bda7ff5e1", + "url": "https://api.github.com/repos/mensbeam/intl/zipball/88dbf8398ab69e71164ac073f9ec011be2baa4ae", + "reference": "88dbf8398ab69e71164ac073f9ec011be2baa4ae", "shasum": "" }, "require": { @@ -501,9 +501,9 @@ ], "support": { "issues": "https://github.com/mensbeam/intl/issues", - "source": "https://github.com/mensbeam/intl/tree/0.9.1" + "source": "https://github.com/mensbeam/intl/tree/0.9.2" }, - "time": "2021-10-24T14:37:46+00:00" + "time": "2023-01-25T22:12:58+00:00" }, { "name": "mensbeam/mimesniff", @@ -617,16 +617,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.2", + "version": "v4.15.3", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" + "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", - "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/570e980a201d8ed0236b0a62ddf2c9cbb2034039", + "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039", "shasum": "" }, "require": { @@ -667,9 +667,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.3" }, - "time": "2022-11-12T15:38:23+00:00" + "time": "2023-01-16T22:05:37+00:00" }, { "name": "phar-io/manifest", @@ -1102,20 +1102,20 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.27", + "version": "9.5.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" + "reference": "954ca3113a03bf780d22f07bf055d883ee04b65e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/954ca3113a03bf780d22f07bf055d883ee04b65e", + "reference": "954ca3113a03bf780d22f07bf055d883ee04b65e", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -1184,7 +1184,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.28" }, "funding": [ { @@ -1200,7 +1200,7 @@ "type": "tidelift" } ], - "time": "2022-12-09T07:31:23+00:00" + "time": "2023-01-14T12:32:24+00:00" }, { "name": "psr/http-message", @@ -2221,16 +2221,16 @@ }, { "name": "symfony/css-selector", - "version": "v5.4.17", + "version": "v5.4.19", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "052ef49b660f9ad2a3adb311c555c9bc11ba61f4" + "reference": "f4a7d150f5b9e8f974f6f127d8167e420d11fc62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/052ef49b660f9ad2a3adb311c555c9bc11ba61f4", - "reference": "052ef49b660f9ad2a3adb311c555c9bc11ba61f4", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/f4a7d150f5b9e8f974f6f127d8167e420d11fc62", + "reference": "f4a7d150f5b9e8f974f6f127d8167e420d11fc62", "shasum": "" }, "require": { @@ -2267,7 +2267,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.4.17" + "source": "https://github.com/symfony/css-selector/tree/v5.4.19" }, "funding": [ { @@ -2283,7 +2283,7 @@ "type": "tidelift" } ], - "time": "2022-12-23T11:40:44+00:00" + "time": "2023-01-01T08:32:19+00:00" }, { "name": "symfony/polyfill-php80", diff --git a/lib/Catcher.php b/lib/Catcher.php index 0a8e942..d86e741 100644 --- a/lib/Catcher.php +++ b/lib/Catcher.php @@ -179,7 +179,7 @@ class Catcher { * @internal */ public function handleError(int $code, string $message, ?string $file = null, ?int $line = null): bool { - if ($code !== 0 && error_reporting()) { + if ($code && $code & error_reporting()) { $error = new Error($message, $code, $file, $line); if ($this->throwErrors) { // The point of this library is to allow treating of errors as if they were @@ -272,6 +272,10 @@ class Catcher { $this->isShuttingDown = true; if ($error = $this->getLastError()) { if ($this->isErrorFatal($error['type'])) { + $errorReporting = error_reporting(); + if ($this->errorReporting !== null && $this->errorReporting === $errorReporting && !($this->errorReporting & \E_ERROR)) { + error_reporting($errorReporting | \E_ERROR); + } $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); } } else { diff --git a/run b/run index 1d926ef..e94cde2 100755 --- a/run +++ b/run @@ -8,7 +8,7 @@ $testDir = "$cwd/tests"; function help($error = true): void { $help = <<setAccessible(true); $this->assertFalse($p->getValue($c)); + $c->unregister(); $h = Phony::partialMock(Catcher::class, [ new PlainTextHandler([ 'silent' => true ]) ]); $h->getLastError->returns([ @@ -494,6 +495,5 @@ class TestCatcher extends \PHPUnit\Framework\TestCase { $c->handleShutdown(); $h->handleError->called(); $h->handleThrowable->called(); - $c->unregister(); } } \ No newline at end of file diff --git a/tests/cases/TestThrowableController.php b/tests/cases/TestThrowableController.php index 4b289f1..992d5a1 100644 --- a/tests/cases/TestThrowableController.php +++ b/tests/cases/TestThrowableController.php @@ -14,10 +14,7 @@ use MensBeam\Foundation\Catcher\{ ThrowableController }; -/** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ + class TestThrowableController extends \PHPUnit\Framework\TestCase { /** * @covers \MensBeam\Foundation\Catcher\ThrowableController::getErrorType diff --git a/tests/docroot/testDispatch.php b/tests/docroot/testDispatch.php deleted file mode 100644 index 4ddd7f1..0000000 --- a/tests/docroot/testDispatch.php +++ /dev/null @@ -1,19 +0,0 @@ - 200 ])); -trigger_error('Ook!', \E_USER_WARNING); \ No newline at end of file