mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
parent
4f87cca55b
commit
74a34f066c
@ -785,6 +785,7 @@ class ArgumentAnalyzer
|
||||
foreach ($param_type->getAtomicTypes() as $param_type_part) {
|
||||
if ($param_type_part instanceof TClassString
|
||||
&& $input_expr instanceof PhpParser\Node\Scalar\String_
|
||||
&& !$param_type->getLiteralStrings()
|
||||
) {
|
||||
if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName(
|
||||
$statements_analyzer,
|
||||
|
@ -520,6 +520,35 @@ class ConditionalReturnTypeTest extends TestCase
|
||||
return $c->get("t", null);
|
||||
}'
|
||||
],
|
||||
'literalStringIsNotAClassString' => [
|
||||
'<?php
|
||||
interface SerializerInterface
|
||||
{
|
||||
/**
|
||||
* Deserializes the given data to the specified type.
|
||||
*
|
||||
* @psalm-template TClass
|
||||
* @psalm-template TType as \'array\'|class-string<TClass>
|
||||
* @psalm-param TType $type
|
||||
* @psalm-return (
|
||||
* TType is \'array\'
|
||||
* ? array
|
||||
* : TClass
|
||||
* )
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function deserialize(string $data, string $type);
|
||||
}
|
||||
|
||||
function foo(SerializerInterface $i, string $data): Exception {
|
||||
return $i->deserialize($data, Exception::class);
|
||||
}
|
||||
|
||||
function bar(SerializerInterface $i, string $data): array {
|
||||
return $i->deserialize($data, \'array\');
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user