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

Add a hidden functions list, fixes #618 #631

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading