nodeFactory = $nodeFactory; $this->phpDocValueToNodeMapper = $phpDocValueToNodeMapper; } /** * @param PhpDocTagNode[] $phpDocTagNodes * @return Expression[] */ public function createFromTagValueNodes(array $phpDocTagNodes, string $methodName) : array { $methodCallExpressions = []; foreach ($phpDocTagNodes as $phpDocTagNode) { $methodCall = $this->createMethodCall($phpDocTagNode, $methodName); $methodCallExpressions[] = new Expression($methodCall); } return $methodCallExpressions; } private function createMethodCall(PhpDocTagNode $phpDocTagNode, string $methodName) : MethodCall { if (!$phpDocTagNode->value instanceof GenericTagValueNode) { throw new ShouldNotHappenException(); } $expr = $this->createExpectedExpr($phpDocTagNode, $phpDocTagNode->value); return $this->nodeFactory->createMethodCall('this', $methodName, [new Arg($expr)]); } private function createExpectedExpr(PhpDocTagNode $phpDocTagNode, GenericTagValueNode $genericTagValueNode) : Expr { if ($phpDocTagNode->name === '@expectedExceptionMessage') { return new String_($genericTagValueNode->value); } return $this->phpDocValueToNodeMapper->mapGenericTagValueNode($genericTagValueNode); } }