-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Mockery::mock()
allow to add traits into mocks:
<?php declare(strict_types = 1);
class C {
public function helloClass(): string { return 'hello class'; }
}
trait T {
public function helloTrait(): string { return 'hello trait'; }
}
$mock = Mockery::mock(C::class, T::class);
$mock->makePartial();
\PHPStan\dumpType($mock);
echo $mock->helloTrait();
will output hello trait
. Unfortunately, it is not supported by this extension (and seems phpstan also cannot create intersections with traits?) so the dumped type will be *NEVER*
-> the $mock->helloTrait()
actually not validated at all... :(
Mockery::mock(C::class)->helloUnknown(); // Call to an undefined method C&Mockery\MockInterface::helloUnknown()
Mockery::mock(C::class, T::class)->helloUnknown(); // nothing
If we are on Level 10 and doing something like Mockery::mock(C::class)->getSomething()->method();
we also will get "Cannot call method method() on mixed.".
Metadata
Metadata
Assignees
Labels
No labels