I use PHP strict types declare(strict_types=1);
and declare types through the project. Also I have enabled PHPDoc inspections in PhpStorm such as Argument PHPDoc missing
, Missing @return tag
and others.
I want PhpStorm not showing warnings regarding PHPDoc when I have explicit return type and parameter type declarations.
Here is valid the sample code in terms of PhpStorm.
/**
* @param Request $request
* @return JsonResponse
* @throws DBALException
*/
public function find(Request $request): JsonResponse
{
$user = $this->repository->find($request->get('id'));
if (!$user) {
throw new NotFoundHttpException();
}
return $this->json($user);
}
As we can see, I have explicit parameter type Request $request
and return type : JsonResponse
declarations, so there is no need to duplicate them in PHPDoc.
I want to exclude this lines from PHPDoc
/**
* @param Request $request
* @return JsonResponse
*/
without warnings from PhpStorm, but only in case I have declared type hints. Nonetheless I want to see warnings when my code doesn't have type hints.
Is it possible to achieve? If no, does some JetBrains ticket exists or is there some plugins/tools to cover my case?
Post answer by myself.
It turned out there are configuration options for PHP inspections (version of PHPStorm 2019.2):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With