Skip to content

Commit 17ad5dc

Browse files
committed
Support getMockFromWsdl
1 parent 20235e8 commit 17ad5dc

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/Type/PHPUnit/CreateMockDynamicReturnTypeExtension.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,30 @@
1212
class CreateMockDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension
1313
{
1414

15+
/** @var int[] */
16+
private $methods = [
17+
'createMock' => 0,
18+
'getMockForAbstractClass' => 0,
19+
'getMockFromWsdl' => 1,
20+
];
21+
1522
public static function getClass(): string
1623
{
1724
return \PHPUnit\Framework\TestCase::class;
1825
}
1926

2027
public function isMethodSupported(MethodReflection $methodReflection): bool
2128
{
22-
return in_array(
23-
$methodReflection->getName(),
24-
[
25-
'createMock',
26-
'getMockForAbstractClass',
27-
],
28-
true
29-
);
29+
return array_key_exists($methodReflection->getName(), $this->methods);
3030
}
3131

3232
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
3333
{
34-
if (count($methodCall->args) === 0) {
34+
$argumentIndex = $this->methods[$methodReflection->getName()];
35+
if (!isset($methodCall->args[$argumentIndex])) {
3536
return $methodReflection->getReturnType();
3637
}
37-
$arg = $methodCall->args[0]->value;
38+
$arg = $methodCall->args[$argumentIndex]->value;
3839
if (!($arg instanceof \PhpParser\Node\Expr\ClassConstFetch)) {
3940
return $methodReflection->getReturnType();
4041
}

0 commit comments

Comments
 (0)