Skip to content

Commit e96b147

Browse files
committed
shouldReceive() returns CompositeExpectation
1 parent 114fdc4 commit e96b147

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

extension.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ services:
44
tags:
55
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
66

7+
-
8+
class: PHPStan\Mockery\Type\ShouldReceiveDynamicReturnTypeExtension
9+
tags:
10+
- phpstan.broker.dynamicMethodReturnTypeExtension
11+
712
-
813
class: PHPStan\Mockery\PhpDoc\TypeNodeResolverExtension
914
tags:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Mockery\Type;
4+
5+
use PhpParser\Node\Expr\MethodCall;
6+
use PHPStan\Analyser\Scope;
7+
use PHPStan\Reflection\MethodReflection;
8+
use PHPStan\Type\DynamicMethodReturnTypeExtension;
9+
use PHPStan\Type\ObjectType;
10+
use PHPStan\Type\Type;
11+
12+
class ShouldReceiveDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
13+
{
14+
15+
public function getClass(): string
16+
{
17+
return \Mockery\MockInterface::class;
18+
}
19+
20+
public function isMethodSupported(MethodReflection $methodReflection): bool
21+
{
22+
return $methodReflection->getName() === 'shouldReceive';
23+
}
24+
25+
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
26+
{
27+
return new ObjectType(\Mockery\CompositeExpectation::class);
28+
}
29+
30+
}

0 commit comments

Comments
 (0)