diff --git a/src/ControllerMethod.php b/src/ControllerMethod.php index 83474d1..f2b5480 100644 --- a/src/ControllerMethod.php +++ b/src/ControllerMethod.php @@ -70,12 +70,12 @@ public static function parse(string $context, array $definitions, ClassMethod $m if ($docNode->value instanceof ReturnTagValueNode) { $type = $docNode->value->type; - $responses = array_merge($responses, ResponseType::resolve($context, $type)); + $responses = array_merge($responses, ResponseType::resolve($context . ': @return', $type)); } if ($docNode->value instanceof ThrowsTagValueNode) { $type = $docNode->value->type; - $statusCode = StatusCodes::resolveException($context, $type); + $statusCode = StatusCodes::resolveException($context . ': @throws', $type); if ($statusCode != null) { if (!$allowMissingDocs && $docNode->value->description == "" && $statusCode < 500) { Logger::error($context, "Missing description for exception '" . $type . "'"); @@ -117,7 +117,7 @@ public static function parse(string $context, array $definitions, ClassMethod $m } elseif ($docParameterType == "@psalm-param") { $psalmParamTag = $docParameter; } else { - Logger::panic($context, "Unknown param type " . $docParameterType); + Logger::panic($context . ': @param', "Unknown param type " . $docParameterType); } } } @@ -136,7 +136,7 @@ public static function parse(string $context, array $definitions, ClassMethod $m try { $type = OpenApiType::resolve( - $context, + $context . ': @param: ' . $psalmParamTag->parameterName, $definitions, new ParamTagValueNode( $psalmParamTag->type, @@ -150,7 +150,7 @@ public static function parse(string $context, array $definitions, ClassMethod $m Logger::debug($context, "Unable to parse parameter " . $methodParameterName . ": " . $e->message . "\n" . $e->getTraceAsString()); // Fallback to the @param annotation $type = OpenApiType::resolve( - $context, + $context . ': @param: ' . $psalmParamTag->parameterName, $definitions, new ParamTagValueNode( $paramTag->type, @@ -164,10 +164,10 @@ public static function parse(string $context, array $definitions, ClassMethod $m $param = new ControllerMethodParameter($context, $definitions, $methodParameterName, $methodParameter, $type); } elseif ($psalmParamTag !== null) { - $type = OpenApiType::resolve($context, $definitions, $psalmParamTag); + $type = OpenApiType::resolve($context . ': @param: ' . $methodParameterName, $definitions, $psalmParamTag); $param = new ControllerMethodParameter($context, $definitions, $methodParameterName, $methodParameter, $type); } elseif ($paramTag !== null) { - $type = OpenApiType::resolve($context, $definitions, $paramTag); + $type = OpenApiType::resolve($context . ': @param: ' . $methodParameterName, $definitions, $paramTag); $param = new ControllerMethodParameter($context, $definitions, $methodParameterName, $methodParameter, $type); } elseif ($allowMissingDocs) { $param = new ControllerMethodParameter($context, $definitions, $methodParameterName, $methodParameter, null); @@ -177,7 +177,7 @@ public static function parse(string $context, array $definitions, ClassMethod $m } if (!$allowMissingDocs && $param->type->description == "") { - Logger::error($context, "Missing description for parameter '" . $methodParameterName . "'"); + Logger::error($context . ': @param: ' . $methodParameterName, "Missing description"); continue; } diff --git a/src/ControllerMethodParameter.php b/src/ControllerMethodParameter.php index 340854f..33c8a55 100644 --- a/src/ControllerMethodParameter.php +++ b/src/ControllerMethodParameter.php @@ -11,7 +11,7 @@ public function __construct(string $context, array $definitions, public string $ if ($docType != null) { $this->type = $this->docType; } else { - $this->type = OpenApiType::resolve($context, $definitions, $methodParameter->type); + $this->type = OpenApiType::resolve($context . ': @param: ' . $name, $definitions, $methodParameter->type); } if ($methodParameter->default != null) { try {