1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Do not report serialize as unused

This commit is contained in:
Vincent Langlet 2022-11-02 22:52:42 +01:00
parent 761d67faa6
commit ef0a17ee11
2 changed files with 28 additions and 0 deletions

View File

@ -518,6 +518,9 @@ class Functions
//gettext
'bindtextdomain',
// serialize
'serialize', 'unserialize'
];
if (in_array(strtolower($function_id), $impure_functions, true)) {

View File

@ -737,6 +737,31 @@ class UnusedCodeTest extends TestCase
new Foo();'
],
'ignoreSerializeAndUnserialize' => [
'<?php
class Foo
{
public function __sleep(): array
{
throw new BadMethodCallException();
}
public function __wakeup(): void
{
throw new BadMethodCallException();
}
}
function test(): bool {
try {
serialize(new Foo());
unserialize("");
} catch (\Throwable) {
return false;
}
return true;
}'
],
'useIteratorMethodsWhenCallingForeach' => [
'<?php
/** @psalm-suppress UnimplementedInterfaceMethod */