-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary/incorrect Symfony Form stubs #322
Comments
I made these, and if it is a problem, I am OK with removing form stubs; another repo is fine. To explain the reasoning: primary use case for templating extensions are form events and can be /** @extends AbstractTypeExtension<AbstractUser> */
class PasswordExtension extends AbstractTypeExtension
{
// I have 2 different forms, for 2 different entities, both extending AbstractUser (table inheritance in Doctrine)
public static function getExtendedTypes(): iterable
{
yield DoctorType::class;
yield PatientType::class;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (PreSetDataEvent $event) {
$user = $event->getData(); // <--- psalm knows this is null|AbstractUser
$this->addRepeatedPasswords($event->getForm(), $user);
});
}
private function addRepeatedPasswords(FormInterface $form, ?AbstractUser $user): void
{
// the rest of code: add repeated passwords, validation etc...
}
} In above example, I could have used |
Hey @zmitic thanks for your note! I'll try to find some time to create basic examples. In the meantime, this explanation may shed some context: https://symfony-devs.slack.com/archives/C8SFXTD2M/p1696508243405699 |
@pps1 I can't access this. Can you paste most important bits that are relevant to this? |
6.3.5
5.15.0
5.0.3
The plugin adds generics stubs for Symfony form components, specifically:
./vendor/psalm/plugin-symfony/src/Stubs/common/Component/Form/AbstractType.stubphp
./vendor/psalm/plugin-symfony/src/Stubs/common/Component/Form/AbstractTypeExtension.stubphp
./vendor/psalm/plugin-symfony/src/Stubs/common/Component/Form/Form.stubphp
These stubs are incorrect as these artifact interfaces do not exchange generics.
Sample psalm validation errors:
Should these stubs be removed?
The text was updated successfully, but these errors were encountered: