mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2527 - no crash when template cannot be resolved
This commit is contained in:
parent
0c7851ae21
commit
d3fb0181cb
@ -1851,7 +1851,7 @@ class TypeAnalyzer
|
||||
}
|
||||
|
||||
if (!$generic_params) {
|
||||
throw new \UnexpectedValueException('$generic_params should not be empty');
|
||||
return false;
|
||||
}
|
||||
|
||||
$input_type_part = new TGenericObject(
|
||||
|
@ -340,7 +340,7 @@ class UnionTemplateHandler
|
||||
}
|
||||
|
||||
if (!$new_generic_params) {
|
||||
throw new \UnexpectedValueException('$new_generic_params should not be empty');
|
||||
return new Atomic\TNamedObject($atomic_input_type->value);
|
||||
}
|
||||
|
||||
return new Atomic\TGenericObject(
|
||||
|
@ -2716,7 +2716,7 @@ class ClassTemplateExtendsTest extends TestCase
|
||||
return trim($v);
|
||||
}
|
||||
}'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -3701,6 +3701,34 @@ class ClassTemplateExtendsTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'InvalidReturnStatement'
|
||||
],
|
||||
'noCrashForTooManyTemplateParams' => [
|
||||
'<?php
|
||||
interface InterfaceA {}
|
||||
|
||||
class ImplemX implements InterfaceA {}
|
||||
|
||||
interface DoStuff {
|
||||
public function stuff(InterfaceA $object): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @implements DoStuff<ImplemX>
|
||||
*/
|
||||
class DoStuffX implements DoStuff {
|
||||
public function stuff(InterfaceA $object): void {}
|
||||
}
|
||||
|
||||
final class Foo {
|
||||
/**
|
||||
* @template A of InterfaceA
|
||||
* @psalm-param DoStuff<A> $stuff
|
||||
*/
|
||||
public function __construct(DoStuff $stuff) {}
|
||||
}
|
||||
|
||||
new Foo(new DoStuffX());',
|
||||
'error_message' => 'InvalidArgument'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user