Skip to content

Commit

Permalink
Merge pull request #474 from def-studio/phpstan-fix
Browse files Browse the repository at this point in the history
phpstan fix
  • Loading branch information
nunomaduro authored Feb 5, 2022
2 parents 8ca4caa + 6f9ebe0 commit 04663e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function sequence(mixed ...$callbacks): Expectation
throw new BadMethodCallException('Expectation value is not iterable.');
}

//@phpstan-ignore-next-line
$value = is_array($this->value) ? $this->value : iterator_to_array($this->value);
$keys = array_keys($value);
$values = array_values($value);
Expand Down
20 changes: 17 additions & 3 deletions src/Support/Backtrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static function testFile(): string
$current = null;

foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) {
assert(array_key_exists(self::FILE, $trace));

if (Str::endsWith($trace[self::FILE], 'overrides/Runner/TestSuiteLoader.php')) {
break;
}
Expand All @@ -45,22 +47,34 @@ public static function testFile(): string
*/
public static function file(): string
{
return debug_backtrace(self::BACKTRACE_OPTIONS)[1][self::FILE];
$trace = debug_backtrace(self::BACKTRACE_OPTIONS)[1];

assert(array_key_exists(self::FILE, $trace));

return $trace[self::FILE];
}

/**
* Returns the dirname that called the current function/method.
*/
public static function dirname(): string
{
return dirname(debug_backtrace(self::BACKTRACE_OPTIONS)[1][self::FILE]);
$trace = debug_backtrace(self::BACKTRACE_OPTIONS)[1];

assert(array_key_exists(self::FILE, $trace));

return dirname($trace[self::FILE]);
}

/**
* Returns the line that called the current function/method.
*/
public static function line(): int
{
return debug_backtrace(self::BACKTRACE_OPTIONS)[1]['line'];
$trace = debug_backtrace(self::BACKTRACE_OPTIONS)[1];

assert(array_key_exists('line', $trace));

return $trace['line'];
}
}

0 comments on commit 04663e0

Please sign in to comment.