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