Skip to content

Commit

Permalink
Add a hidden functions list, fixes #618
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Feb 17, 2025
1 parent 288a30a commit 5f1338b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
1 change: 0 additions & 1 deletion generated/8.4/functionsList.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion generated/8.4/rector-migrate.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion generated/8.5/functionsList.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion generated/8.5/rector-migrate.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions generator/config/hiddenFunctions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/*
* A list of functions which don't really belong in Safe, but our
* unsafe-function-detector detected them by accident, and now we
* don't want to delete them (because that would break the backwards
* compatibility promise implied by Semver), but we also don't want
* to suggest that users should be using them.
*/
return [
'array_all', // false is not an error
];
4 changes: 2 additions & 2 deletions generator/src/Generator/FileCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private function getFunctionsNameList(array $functions): array
$functionNames = array_map(function (Method $function) {
return $function->getFunctionName();
}, $functions);
$specialCases = Scanner::getSpecialCases();
$functionNames = array_merge($functionNames, $specialCases);
$functionNames = array_merge($functionNames, Scanner::getSpecialCases());
$functionNames = array_diff($functionNames, Scanner::getHiddenFunctions());
natcasesort($functionNames);
return $functionNames;
}
Expand Down
14 changes: 13 additions & 1 deletion generator/src/XmlDocParser/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Scanner
/**
* @var string[]
*/
private $ignoredModules;
private ?array $ignoredModules = null;

public function __construct(private readonly string $path)
{
Expand Down Expand Up @@ -74,6 +74,7 @@ private function getIgnoredModules(): array
{
if ($this->ignoredModules === null) {
$this->ignoredModules = require FileCreator::getSafeRootDir() . '/generator/config/ignoredModules.php';
assert(!is_null($this->ignoredModules));
}
return $this->ignoredModules;
}
Expand All @@ -95,6 +96,17 @@ public static function getSpecialCases(): array
return $matches[1];
}

/**
* Get a list of functions defined in special_cases.php so that we
* can ignore them in the main list.
*
* @return string[]
*/
public static function getHiddenFunctions(): array
{
return require FileCreator::getSafeRootDir() . '/generator/config/hiddenFunctions.php';
}

/**
* @param SplFileInfo[] $paths
*/
Expand Down

0 comments on commit 5f1338b

Please sign in to comment.