Open
Description
Hi!
I'm in the process of upgrading to phpstan 2.
One error that I couldn't find any solution yet is the following.
It was working on the latest 1.x versions
<?php
namespace App\Controller;
use App\Entity\Customer;
use App\Form\CustomerType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
class CustomerController extends AbstractController
{
#[Route('/submit')]
public function submit(Request $request): JsonResponse
{
$form = $this->createForm(CustomerType::class, new Customer());
$form->handleRequest($request);
if ($form->isSubmitted() && !$form->isValid()) {
$errors = [];
/** @var FormError $error */
foreach ($form->getErrors(true) as $error) {
// process and handle errors
}
}
return $this->json([]);
}
}
After phpstan 2 I get the following error:
PHPDoc tag
@var
with type Symfony\Component\Form\FormError is not subtype of native type T of Symfony\Component\Form\FormError|Symfony\Component\Form\FormErrorIterator.
I use the @var
typehint for phpstorm, to have autocompletion. How can I fix this or is this a bug?
Thanks for your help
Metadata
Metadata
Assignees
Labels
No labels