Skip to content

Commit

Permalink
Skip verifying callmaps based on name pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Feb 16, 2023
1 parent ab77cfd commit cf739ab
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions tests/Internal/Codebase/InternalCallMapHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
/** @group callmap */
class InternalCallMapHandlerTest extends TestCase
{
/**
* Regex patterns for callmap entries that should be skipped.
*
* These will not be checked against reflection. This prevents a
* large ignore list for extension functions have invalid reflection
* or are not maintained.
*
* @var list<string>
*/
private static array $skippedPatterns = [
'/\'\d$/', // skip alternate signatures
'/^redis/', // redis extension
'/^imagick/', // imagick extension
'/^uopz/', // uopz extension
];

/**
* Specify a function name as value, or a function name as key and
* an array containing the PHP versions in which to ignore this function as values.
Expand Down Expand Up @@ -689,15 +705,6 @@ class InternalCallMapHandlerTest extends TestCase
'uconverter::fromucallback',
'uconverter::reasontext',
'uconverter::transcode',
'uopz_allow_exit',
'uopz_get_mock',
'uopz_get_property',
'uopz_get_return',
'uopz_get_static',
'uopz_set_mock',
'uopz_set_property',
'uopz_set_static',
'uopz_unset_mock',
'xdiff_file_bdiff',
'xdiff_file_bdiff_size',
'xdiff_file_diff',
Expand Down Expand Up @@ -920,6 +927,17 @@ public function callMapEntryProvider(): iterable
);
$callMap = InternalCallMapHandler::getCallMap();
foreach ($callMap as $function => $entry) {
foreach (static::$skippedPatterns as $skipPattern) {
if (preg_match($skipPattern, $function)) {
continue 2;
}
}

// Skip functions with alternate signatures
if (isset($callMap["$function'1"])) {
continue;
}

$classNameEnd = strpos($function, '::');
if ($classNameEnd !== false) {
$className = substr($function, 0, $classNameEnd);
Expand All @@ -930,11 +948,6 @@ public function callMapEntryProvider(): iterable
continue;
}

// Skip functions with alternate signatures
if (isset($callMap["$function'1"]) || preg_match("/\'\d$/", $function)) {
continue;
}
// if ($function != 'fprintf') continue;
yield "$function: " . json_encode($entry) => [$function, $entry];
}
}
Expand Down

0 comments on commit cf739ab

Please sign in to comment.