Form "has invalid type Symfony\Component\Form\TData" after patch upgrade
Jean85 opened this issue · 0 comments
Jean85 commented
I'm getting the same that arose in #337 after merge during a PHPStan patch upgrade with Renovate:
Package | Type | Update | Change |
---|---|---|---|
phpstan/phpstan | require-dev | patch | 1.10.55 -> 1.10.56 |
phpstan/phpstan-symfony | require-dev | patch | 1.3.6 -> 1.3.7 |
Before I used @template-extends AbstractType<void>
, now it fails every time, with or without the annotation.
Code example:
<?php
declare(strict_types=1);
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints\File;
/**
* @template-extends AbstractType<mixed>
*/
class UploadFileType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add(
'file',
FileType::class,
[
'label' => 'Zip',
'required' => true,
'constraints' => [
new File([
'mimeTypes' => [
'application/zip',
],
'mimeTypesMessage' => 'Please upload a valid zip file',
]),
],
]
);
$builder->add('submit', SubmitType::class, ['attr' => ['class' => 'btn-primary'], 'label' => 'Save']);
$builder->setMethod(Request::METHOD_POST);
parent::buildForm($builder, $options);
}
}
Error:
$ vendor/bin/phpstan analyze src/Form/UploadFileType.php
Note: Using configuration file /var/www/***/***/phpstan.neon.
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ ------------------------------------------------------------------------------------------
Line UploadFileType.php
------ ------------------------------------------------------------------------------------------
19 Parameter $builder of method AppBundle\Form\UploadFileType::buildForm() has invalid type
Symfony\Component\Form\TData.
------ ------------------------------------------------------------------------------------------
[ERROR] Found 1 error