Skip to content
Permalink
Browse files

Ignore serialize/unserialize methods

Fixes #2511
  • Loading branch information
muglug committed Dec 31, 2019
1 parent cbdf6ad commit 02fd1659ef74a41e6c4a7dcbf52df60fe43862ea
Showing with 19 additions and 1 deletion.
  1. +6 −0 src/Psalm/Internal/Codebase/ClassLikes.php
  2. +13 −1 tests/UnusedCodeTest.php
@@ -1773,6 +1773,12 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth

$has_parent_references = false;

if ($codebase->classImplements($classlike_storage->name, 'Serializable')
&& ($method_name === 'serialize' || $method_name === 'unserialize')
) {
continue;
}

$has_variable_calls = $codebase->analyzer->hasMixedMemberName(strtolower($method_name))
|| $codebase->analyzer->hasMixedMemberName(strtolower($classlike_storage->name . '::'));

@@ -656,7 +656,19 @@ function getArg(string $method) : void {
break;
}
}'
]
],
'ignoreSerializerSerialize' => [
'<?php
class Foo implements Serializable {
public function serialize() : string {
return "";
}
public function unserialize($_serialized) : void {}
}
new Foo();'
],
];
}

0 comments on commit 02fd165

Please sign in to comment.
You can’t perform that action at this time.