Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip verifying callmaps based on name pattern #9313

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -687,15 +703,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 @@ -918,6 +925,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 @@ -928,11 +946,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