Remove useless type castings in ShouldNotHappenException::createDefaultMessageWithLocation() method (#1678)

* Remove useless type castings in `ShouldNotHappenException::createDefaultMessageWithLocation()` method

* Update PHPStan baseline
This commit is contained in:
Stefano Arlandini 2022-01-15 11:24:51 +01:00 committed by GitHub
parent 80882ad175
commit 303ecc342d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -627,3 +627,9 @@ parameters:
# impossible to validate json string is a class-string
- '#Parameter \#1 \$rectorClass of class Rector\\ChangesReporting\\ValueObject\\RectorWithLineChange constructor expects class\-string<Rector\\Core\\Contract\\Rector\\RectorInterface\>\|Rector\\Core\\Contract\\Rector\\RectorInterface, string given#'
# will be solved once https://github.com/phpstan/phpstan-src/pull/914 gets released
-
message: '#sprintf\(\) call mask types does not match provided arguments types#'
paths:
- src/Exception/ShouldNotHappenException.php

View File

@ -26,9 +26,9 @@ final class ShouldNotHappenException extends Exception
{
$debugBacktrace = debug_backtrace();
$class = isset($debugBacktrace[2]['class']) ? (string) $debugBacktrace[2]['class'] : null;
$function = isset($debugBacktrace[2]['function']) ? (string) $debugBacktrace[2]['function'] : '';
$line = isset($debugBacktrace[1]['line']) ? (int) $debugBacktrace[1]['line'] : 0;
$class = $debugBacktrace[2]['class'] ?? null;
$function = $debugBacktrace[2]['function'];
$line = $debugBacktrace[1]['line'] ?? 0;
$method = $class !== null ? ($class . '::' . $function) : $function;