Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Stubs/common/Component/Form/FormView.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Symfony\Component\Form;

use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\FormErrorIterator;

/**
* @template T
Expand All @@ -13,11 +14,24 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
* @psalm-suppress MixedArrayAssignment
* @psalm-suppress InvalidArrayOffset
*
* @psalm-var array{value: ?T, attr: array<array-key, mixed>}&array<string, mixed>
* @psalm-var array{value: ?T, attr: array<array-key, mixed>, errors: ?FormErrorIterator, valid: bool, data: ?mixed, required: bool, label_attr: array<array-key, mixed>, help: ?string, help_attr: array<array-key, mixed>, help_html: bool, help_translation_parameters: array<array-key, mixed>, compound: bool, method: string, action: string, submitted: bool}&array<string, mixed>
*/
public array $vars = [
'value' => null,
'attr' => [],
'errors' => null,
'valid' => true,
'data' => null,
'required' => false,
'label_attr' => [],
'help' => null,
'help_attr' => [],
'help_html' => false,
'help_translation_parameters' => [],
'compound' => false,
'method' => 'POST',
'action' => '',
'submitted' => false,
];

/**
Expand Down
57 changes: 57 additions & 0 deletions tests/acceptance/acceptance/forms/FormView.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Feature: Form view

Background:
Given I have Symfony plugin enabled

Scenario: FormView test
Given I have the following code
"""
Expand All @@ -28,6 +29,48 @@ Feature: Form view
$viewData = $view->vars['value'];
/** @psalm-trace $viewData */

$valid = $view->vars['valid'];
/** @psalm-trace $valid */

$errors = $view->vars['errors'];
/** @psalm-trace $errors */

$valid = $view->vars['valid'];
/** @psalm-trace $valid */

$data = $view->vars['data'];
/** @psalm-trace $data */

$required = $view->vars['required'];
/** @psalm-trace $required */

$label_attr = $view->vars['label_attr'];
/** @psalm-trace $label_attr */

$help = $view->vars['help'];
/** @psalm-trace $help */

$help_attr = $view->vars['help_attr'];
/** @psalm-trace $help_attr */

$help_html = $view->vars['help_html'];
/** @psalm-trace $help_html */

$help_translation_parameters = $view->vars['help_translation_parameters'];
/** @psalm-trace $help_translation_parameters */

$compound = $view->vars['compound'];
/** @psalm-trace $compound */

$method = $view->vars['method'];
/** @psalm-trace $method */

$action = $view->vars['action'];
/** @psalm-trace $action */

$submitted = $view->vars['submitted'];
/** @psalm-trace $submitted */

// assert no errors
$view->vars['random'] = new \stdClass();

Expand All @@ -44,6 +87,20 @@ Feature: Form view
| Trace | $parentView: Symfony\Component\Form\FormView\|null |
| Trace | $children: array<string, Symfony\Component\Form\FormView> |
| Trace | $viewData: User\|null |
| Trace | $valid: bool |
| Trace | $errors: Symfony\Component\Form\FormErrorIterator\|null |
| Trace | $attr: array<array-key, mixed> |
| Trace | $valid: bool |
| Trace | $data: mixed\|null |
| Trace | $required: bool |
| Trace | $label_attr: array<array-key, mixed> |
| Trace | $help: string\|null |
| Trace | $help_attr: array<array-key, mixed> |
| Trace | $help_html: bool |
| Trace | $help_translation_parameters: array<array-key, mixed> |
| Trace | $compound: bool |
| Trace | $method: string |
| Trace | $action: string |
| Trace | $submitted: bool |
And I see no other errors