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:
parent
761d67faa6
commit
ef0a17ee11
@ -518,6 +518,9 @@ class Functions
|
||||
|
||||
//gettext
|
||||
'bindtextdomain',
|
||||
|
||||
// serialize
|
||||
'serialize', 'unserialize'
|
||||
];
|
||||
|
||||
if (in_array(strtolower($function_id), $impure_functions, true)) {
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user