Skip to content

Commit 039c23e

Browse files
committed
Support string arguments
1 parent cbc048b commit 039c23e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Type/PHPUnit/CreateMockDynamicReturnTypeExtension.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node\Expr\MethodCall;
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\MethodReflection;
8+
use PHPStan\Type\Constant\ConstantStringType;
89
use PHPStan\Type\ObjectType;
910
use PHPStan\Type\Type;
1011
use PHPStan\Type\TypeCombinator;
@@ -41,12 +42,14 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4142
}
4243

4344
$argType = $scope->getType($methodCall->args[$argumentIndex]->value);
44-
if (!($argType instanceof TypeWithClassName)) {
45+
if ($argType instanceof TypeWithClassName) {
46+
$class = $argType->getClassName();
47+
} elseif ($argType instanceof ConstantStringType) {
48+
$class = $argType->getValue();
49+
} else {
4550
return $methodReflection->getReturnType();
4651
}
4752

48-
$class = $argType->getClassName();
49-
5053
return TypeCombinator::intersect(
5154
new ObjectType($class),
5255
$methodReflection->getReturnType()

0 commit comments

Comments
 (0)