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

View File

@ -81,9 +81,9 @@ class Backtrace
$match = false; $match = false;
if (!empty($frame['class'])) { if (!empty($frame['class'])) {
foreach ($ignoredArgs as $fnSpec) { foreach ($ignoredArgs as $fnSpec) {
if (is_array($fnSpec) && if (is_array($fnSpec)
('*' == $fnSpec[0] || $frame['class'] == $fnSpec[0]) && && self::matchesFilterableClass($frame['class'], $fnSpec[0])
$frame['function'] == $fnSpec[1] && $frame['function'] == $fnSpec[1]
) { ) {
$match = true; $match = true;
break; break;
@ -202,4 +202,13 @@ class Backtrace
} }
return $result; 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);
}
} }