-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Description
Code snippet that reproduces the problem
class MockObject
{
public function checkExpectations() : void
{
}
}
/**
* @template RequestedType
* @param class-string<RequestedType> $className
* @return RequestedType&MockObject
*/
function mock(string $className)
{
$instance = eval("there be dragons");
return $instance;
}
class A {
public function foo() : void {}
}
/**
* @template UnknownType
* @param class-string<UnknownType> $className
*/
function useMockTemplated(string $className) : void
{
mock($className)->checkExpectations();
}
mock(A::class)->foo(); // good
mock(A::class)->checkExpectations(); // good
mock(A::class)->notFoo(); // badExpected output
Method (A&MockObject)::notFoo does not exist
Actual output
No issues
Reactions are currently unavailable