FormConfigBuilderInterface stub update #197

This commit is contained in:
Zeljko Mitic 2021-08-12 15:01:03 +02:00 committed by GitHub
parent d79efd38b6
commit 3b455dd263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View File

@ -6,6 +6,7 @@ use Symfony\Component\Form\Event\PreSetDataEvent;
use Symfony\Component\Form\Event\PreSubmitEvent;
use Symfony\Component\Form\Event\PostSetDataEvent;
use Symfony\Component\Form\Event\SubmitEvent;
use Symfony\Component\Form\Event\PostSubmitEvent;
/**
* @template T
@ -21,7 +22,7 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* @psalm-param FormEvents::* $eventName
*
* @psalm-param callable(PreSetDataEvent<T>)|callable(PostSetDataEvent<T>)|callable(PreSubmitEvent)|callable(SubmitEvent<T>) $listener
* @psalm-param callable(PreSetDataEvent<T>)|callable(PostSetDataEvent<T>)|callable(PreSubmitEvent)|callable(SubmitEvent<T>)|callable(PostSubmitEvent<T>) $listener
*/
public function addEventListener($eventName, $listener, $priority = 0);
}

View File

@ -0,0 +1,15 @@
<?php
namespace Symfony\Component\Form\Event;
use Symfony\Component\Form\FormEvent;
/**
* @template T
*
* @template-extends FormEvent<T>
*/
class PostSubmitEvent extends FormEvent
{
}

View File

@ -12,7 +12,7 @@ Feature: Form config builder
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Event\{PreSubmitEvent, PreSetDataEvent, PostSetDataEvent, SubmitEvent};
use Symfony\Component\Form\Event\{PreSubmitEvent, PreSetDataEvent, PostSetDataEvent, SubmitEvent, PostSubmitEvent};
use Symfony\Component\Form\FormEvents;
/** @extends AbstractType<User> */
@ -40,6 +40,11 @@ Feature: Form config builder
/** @psalm-trace $submitData */
});
$builder->addEventListener(FormEvents::POST_SUBMIT, function(PostSubmitEvent $event) {
$postSubmitData = $event->getData();
/** @psalm-trace $postSubmitData */
});
$config = $builder->getFormConfig();
/** @psalm-trace $config */
}
@ -53,5 +58,6 @@ Feature: Form config builder
| Trace | $postSetData: User\|null |
| Trace | $preSubmitData: array<string, mixed> |
| Trace | $submitData: User\|null |
| Trace | $postSubmitData: User\|null |
And I see no other errors