Skip to content

Commit

Permalink
Use never return typehint (#1654)
Browse files Browse the repository at this point in the history
The `never` return typehint was added in PHP 8.1 and can be used
to indicate that a function will never return.

RFC: https://wiki.php.net/rfc/noreturn_type
  • Loading branch information
hemberger committed Apr 19, 2022
1 parent 2d006a8 commit 14f39fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/Monolog/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ protected function defaultErrorLevelMap(): array
];
}

/**
* @phpstan-return never
*/
private function handleException(\Throwable $e): void
private function handleException(\Throwable $e): never
{
$level = LogLevel::ERROR;
foreach ($this->uncaughtExceptionLevelMap as $class => $candidate) {
Expand Down
4 changes: 1 addition & 3 deletions src/Monolog/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ public static function pcreLastErrorMessage(int $code): string
* @param int $code return code of json_last_error function
* @param mixed $data data that was meant to be encoded
* @throws \RuntimeException
*
* @return never
*/
private static function throwEncodeError(int $code, $data): void
private static function throwEncodeError(int $code, $data): never
{
switch ($code) {
case JSON_ERROR_DEPTH:
Expand Down

0 comments on commit 14f39fe

Please sign in to comment.