Skip to content

Commit

Permalink
Fix: Wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed May 8, 2020
1 parent d7952a9 commit 0b7ee4e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/PhpDoc/ObjectProphecy/TypeNodeResolverExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ public function resolve(PhpDocParser\Ast\Type\TypeNode $typeNode, Analyser\NameS
}

if (null !== $objectProphecyType && null !== $prophesizedType) {
return new Type\Generic\GenericObjectType(Prophecy\ObjectProphecy::class, [$prophesizedType]);
return new Type\Generic\GenericObjectType(
Prophecy\ObjectProphecy::class,
[
$prophesizedType,
]
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public function getTypeFromMethodCall(

$returnType = $parametersAcceptor->getReturnType();

if (!$calledOnType instanceof Type\Generic\GenericObjectType || Prophecy\ObjectProphecy::class !== $calledOnType->getClassName()) {
if (
!$calledOnType instanceof Type\Generic\GenericObjectType
|| Prophecy\ObjectProphecy::class !== $calledOnType->getClassName()
) {
return $returnType;
}

Expand Down Expand Up @@ -83,8 +86,16 @@ public function getTypeFromMethodCall(
$className = $scope->getClassReflection()->getName();
}

$mockTypeIntersection = Type\TypeCombinator::intersect(new Type\ObjectType($className), ...$calledOnType->getTypes());
$mockTypeIntersection = Type\TypeCombinator::intersect(
new Type\ObjectType($className),
...$calledOnType->getTypes()
);

return new Type\Generic\GenericObjectType(Prophecy\ObjectProphecy::class, [$mockTypeIntersection]);
return new Type\Generic\GenericObjectType(
Prophecy\ObjectProphecy::class,
[
$mockTypeIntersection,
]
);
}
}
12 changes: 10 additions & 2 deletions src/Type/Prophet/ProphesizeDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public function getTypeFromMethodCall(
$returnType = $parametersAcceptor->getReturnType();

if (0 === \count($methodCall->args)) {
return new Type\Generic\GenericObjectType(Prophecy\ObjectProphecy::class, []);
return new Type\Generic\GenericObjectType(
Prophecy\ObjectProphecy::class,
[]
);
}

$argumentType = $scope->getType($methodCall->args[0]->value);
Expand All @@ -75,6 +78,11 @@ public function getTypeFromMethodCall(
$className = $scope->getClassReflection()->getName();
}

return new Type\Generic\GenericObjectType(Prophecy\ObjectProphecy::class, [new Type\ObjectType($className)]);
return new Type\Generic\GenericObjectType(
Prophecy\ObjectProphecy::class,
[
new Type\ObjectType($className),
]
);
}
}

0 comments on commit 0b7ee4e

Please sign in to comment.