From 4095cdf49c73268c531a4f9a258d3d7e934d0055 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 2 Aug 2019 09:43:07 +0200 Subject: [PATCH] Revert "Simplify" This reverts commit 7b0ef67065443b012bcf43ceff70d5c05913d2c2. --- src/Framework/Error/Deprecation.php | 17 +++++++++++++++++ src/Framework/Error/Notice.php | 17 +++++++++++++++++ src/Framework/Error/Warning.php | 17 +++++++++++++++++ src/Util/ErrorHandler.php | 13 +++++++------ 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 src/Framework/Error/Deprecation.php create mode 100644 src/Framework/Error/Notice.php create mode 100644 src/Framework/Error/Warning.php diff --git a/src/Framework/Error/Deprecation.php b/src/Framework/Error/Deprecation.php new file mode 100644 index 00000000000..f3cff80e948 --- /dev/null +++ b/src/Framework/Error/Deprecation.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework\Error; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class Deprecation extends Error +{ +} diff --git a/src/Framework/Error/Notice.php b/src/Framework/Error/Notice.php new file mode 100644 index 00000000000..71e75bfd8af --- /dev/null +++ b/src/Framework/Error/Notice.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework\Error; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class Notice extends Error +{ +} diff --git a/src/Framework/Error/Warning.php b/src/Framework/Error/Warning.php new file mode 100644 index 00000000000..a2a1bf5fb0d --- /dev/null +++ b/src/Framework/Error/Warning.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework\Error; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class Warning extends Error +{ +} diff --git a/src/Util/ErrorHandler.php b/src/Util/ErrorHandler.php index dd0c7960ae2..30e04ba9456 100644 --- a/src/Util/ErrorHandler.php +++ b/src/Util/ErrorHandler.php @@ -9,7 +9,10 @@ */ namespace PHPUnit\Util; +use PHPUnit\Framework\Error\Deprecation; use PHPUnit\Framework\Error\Error; +use PHPUnit\Framework\Error\Notice; +use PHPUnit\Framework\Error\Warning; final class ErrorHandler { @@ -84,7 +87,7 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil return false; } - break; + throw new Notice($errorString, $errorNumber, $errorFile, $errorLine); case \E_WARNING: case \E_USER_WARNING: @@ -92,7 +95,7 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil return false; } - break; + throw new Warning($errorString, $errorNumber, $errorFile, $errorLine); case \E_DEPRECATED: case \E_USER_DEPRECATED: @@ -100,17 +103,15 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil return false; } - break; + throw new Deprecation($errorString, $errorNumber, $errorFile, $errorLine); default: if (!$this->convertErrorsToExceptions) { return false; } - break; + throw new Error($errorString, $errorNumber, $errorFile, $errorLine); } - - throw new Error($errorString, $errorNumber, $errorFile, $errorLine); } public function register(): void