Skip to content

Commit bd4c962

Browse files
committed
Add a hidden functions list, fixes #618
1 parent 288a30a commit bd4c962

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

generated/8.4/functionsList.php

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.4/rector-migrate.php

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.5/functionsList.php

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.5/rector-migrate.php

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/config/hiddenFunctions.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/*
3+
* A list of functions which don't really belong in Safe, but our
4+
* unsafe-function-detector detected them by accident, and now we
5+
* don't want to delete them (because that would break the backwards
6+
* compatibility promise implied by Semver), but we also don't want
7+
* to suggest that users should be using them.
8+
*/
9+
return [
10+
'array_all', // false is not an error
11+
];

generator/src/Generator/FileCreator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ private function getFunctionsNameList(array $functions): array
101101
$functionNames = array_map(function (Method $function) {
102102
return $function->getFunctionName();
103103
}, $functions);
104-
$specialCases = Scanner::getSpecialCases();
105-
$functionNames = array_merge($functionNames, $specialCases);
104+
$functionNames = array_merge($functionNames, Scanner::getSpecialCases());
105+
$functionNames = array_diff($functionNames, Scanner::getHiddenFunctions());
106106
natcasesort($functionNames);
107107
return $functionNames;
108108
}

generator/src/XmlDocParser/Scanner.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Scanner
2323
/**
2424
* @var string[]
2525
*/
26-
private $ignoredModules;
26+
private ?array $ignoredModules = null;
2727

2828
public function __construct(private readonly string $path)
2929
{
@@ -74,6 +74,7 @@ private function getIgnoredModules(): array
7474
{
7575
if ($this->ignoredModules === null) {
7676
$this->ignoredModules = require FileCreator::getSafeRootDir() . '/generator/config/ignoredModules.php';
77+
assert(!is_null($this->ignoredModules));
7778
}
7879
return $this->ignoredModules;
7980
}
@@ -95,6 +96,17 @@ public static function getSpecialCases(): array
9596
return $matches[1];
9697
}
9798

99+
/**
100+
* Get a list of functions defined in special_cases.php so that we
101+
* can ignore them in the main list.
102+
*
103+
* @return string[]
104+
*/
105+
public static function getHiddenFunctions(): array
106+
{
107+
return require FileCreator::getSafeRootDir() . '/generator/config/hiddenFunctions.php';
108+
}
109+
98110
/**
99111
* @param SplFileInfo[] $paths
100112
*/

0 commit comments

Comments
 (0)