Skip to content

Commit 17e266b

Browse files
committed
Adding the ability to ignore some functions
1 parent de35604 commit 17e266b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
return [
3+
'array_key_exists'
4+
];

generator/src/Scanner.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ public function getPaths(): array
4040
return $paths;
4141
}
4242

43+
private $functionList;
44+
45+
/**
46+
* Returns the list of functions that must be ignored.
47+
* @return string[]
48+
*/
49+
private function getIgnoredFunctions(): array
50+
{
51+
if ($this->functionList === null) {
52+
$this->functionList = require __DIR__.'/../config/ignoredFunctions.php';
53+
}
54+
return $this->functionList;
55+
}
56+
4357
/**
4458
* @return mixed[]
4559
*/
@@ -49,6 +63,8 @@ public function getMethods(): array
4963
$overloadedFunctions = [];
5064
$paths = $this->getPaths();
5165
$phpStanFunctionMapReader = new PhpStanFunctionMapReader();
66+
$ignoredFunctions = $this->getIgnoredFunctions();
67+
$ignoredFunctions = \array_combine($ignoredFunctions, $ignoredFunctions);
5268
foreach ($paths as $path) {
5369
$module = \basename(\dirname($path, 2));
5470
if (\in_array($module, $this->excludedModules)) {
@@ -62,11 +78,18 @@ public function getMethods(): array
6278
$overloadedFunctions = array_merge($overloadedFunctions, \array_map(function ($functionObject) {
6379
return $functionObject->methodname->__toString();
6480
}, $functionObjects));
81+
$overloadedFunctions = \array_filter($overloadedFunctions, function(string $functionName) use ($ignoredFunctions) {
82+
return !isset($ignoredFunctions[$functionName]);
83+
});
6584
continue;
6685
}
6786
$rootEntity = $docPage->loadAndResolveFile();
6887
foreach ($functionObjects as $functionObject) {
69-
$functions[] = new Method($functionObject, $rootEntity, $docPage->getModule(), $phpStanFunctionMapReader);
88+
$function = new Method($functionObject, $rootEntity, $docPage->getModule(), $phpStanFunctionMapReader);
89+
if (isset($ignoredFunctions[$function->getFunctionName()])) {
90+
continue;
91+
}
92+
$functions[] = $function;
7093
}
7194
}
7295
}

0 commit comments

Comments
 (0)