-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Helper; | ||
|
||
use Yiisoft\Strings\StringHelper; | ||
|
||
use function in_array; | ||
|
||
/** | ||
* `BacktraceMatcher` provides methods to match backtrace items returned by the PHP function `debug_backtrace()`. | ||
* | ||
* @see https://www.php.net/manual/function.debug-backtrace.php | ||
* | ||
* @psalm-type TBacktraceItem = array{ | ||
* file?: string, | ||
* line?: int, | ||
* function?: string, | ||
* class?: class-string, | ||
* object?: object, | ||
* type?: string, | ||
* args?:array, | ||
* } | ||
*/ | ||
final class BacktraceMatcher | ||
{ | ||
/** | ||
* @param string[] $patterns | ||
* @psalm-param TBacktraceItem $backtraceItem | ||
*/ | ||
public static function byFile(array $backtraceItem, array $patterns): bool | ||
{ | ||
$path = $backtraceItem['file'] ?? null; | ||
return $path !== null && StringHelper::matchAnyRegex($path, $patterns); | ||
} | ||
|
||
/** | ||
* @param string[] $classes | ||
* @psalm-param TBacktraceItem $backtraceItem | ||
*/ | ||
public static function byClass(array $backtraceItem, array $classes): bool | ||
{ | ||
$class = $backtraceItem['class'] ?? null; | ||
return $class !== null && in_array($class, $classes, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters