-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Psalm support is unclear from README.md #408
Comments
I wrote a plugin that will add all non-safe functions to the forbidden function list. class Plugin implements PluginEntryPointInterface
{
public function __invoke(RegistrationInterface $registration, ?\SimpleXMLElement $config = null): void
{
/** @psalm-suppress InternalClass,InternalMethod */
$config = ProjectAnalyzer::getInstance()->getCodebase()->config;
$forbiddenFunctions = &$config->forbidden_functions;
$deprecatedSafeFunctions = [
'safe\\sprintf' => true,
'safe\\ksort' => true,
'safe\\usort' => true,
'safe\\array_flip' => true,
'safe\\substr' => true,
'safe\\sort' => true,
'safe\\asort' => true,
'safe\\password_hash' => true,
'safe\\sleep' => true,
];
foreach (\get_defined_functions()['user'] as $functionName) {
if (!\str_starts_with($functionName, 'safe\\')) {
continue;
}
if (isset($deprecatedSafeFunctions[$functionName])) {
unset($deprecatedSafeFunctions[$functionName]);
continue;
}
$forbiddenFunctions[\substr($functionName, 5)] = true;
}
if ($deprecatedSafeFunctions !== []) {
throw new \Exception('$deprecatedSafeFunctions has unused keys: ' . \var_export($deprecatedSafeFunctions, true));
}
}
} |
As far as I'm aware nobody on the current maintainer team is using psalm - if it works, that's good, if it doesn't work, we welcome assistance :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a link to PHPStan plugin for for the package, but Psalm support is unclear from the README. What is the status?
The text was updated successfully, but these errors were encountered: