ENH Allow subclasses to be defined for backtrace filtered functions.

This commit is contained in:
Guy Sartorelli 2022-06-23 15:17:33 +12:00
parent 2b0df58176
commit d448622ff4
1 changed files with 12 additions and 3 deletions

View File

@ -81,9 +81,9 @@ class Backtrace
$match = false;
if (!empty($frame['class'])) {
foreach ($ignoredArgs as $fnSpec) {
if (is_array($fnSpec) &&
('*' == $fnSpec[0] || $frame['class'] == $fnSpec[0]) &&
$frame['function'] == $fnSpec[1]
if (is_array($fnSpec)
&& self::matchesFilterableClass($frame['class'], $fnSpec[0])
&& $frame['function'] == $fnSpec[1]
) {
$match = true;
break;
@ -202,4 +202,13 @@ class Backtrace
}
return $result;
}
/**
* Checks if the filterable class is wildcard, of if the class name is the filterable class, or a subclass of it,
* or implements it.
*/
private static function matchesFilterableClass(string $className, string $filterableClass): bool
{
return $filterableClass === '*' || $className === $filterableClass || is_subclass_of($className, $filterableClass);
}
}