Skip to content

Commit

Permalink
Remove useless type castings in `ShouldNotHappenException::createDefa…
Browse files Browse the repository at this point in the history
…ultMessageWithLocation()` method (#1678)

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

* Update PHPStan baseline
  • Loading branch information
ste93cry committed Jan 15, 2022
1 parent 80882ad commit 303ecc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/Exception/ShouldNotHappenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ private function createDefaultMessageWithLocation(): string
{
$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;

Expand Down

0 comments on commit 303ecc3

Please sign in to comment.