Skip to content

Add FormTypeExtensionInterface stub #108

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

Merged

Conversation

pscheit-lillydoo
Copy link
Contributor

Since it implements nearly the same interface, but isn't typehinted either ($options missing iterable type)

How can I test that?

@pscheit-lillydoo
Copy link
Contributor Author

Thank you for writing phpstan!

I accept the code of conduct in phpstan/phpstan-src

Greetings

@ondrejmirtes
Copy link
Member

Hi, what kind of bug this solves? Thank you.

@pscheit-lillydoo
Copy link
Contributor Author

pscheit-lillydoo commented Oct 22, 2020

use \Symfony\Component\Form\FormTypeExtensionInterface;

Class MyTypeExtension implements FormTypeExtensionInterface
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
    }
\

phpstan would say:

$options type has no value type specified in iterable type array

its the same case as the FormTypeInterface Stub

@ondrejmirtes
Copy link
Member

How does the $options array going into these methods usually looks like?

@pscheit-lillydoo
Copy link
Contributor Author

e.g. for a collection type

 [
    'entry_type' => EmailType::class,
    'entry_options' => [
        'attr' => ['class' => 'email-box'],
    ],
]);

basically everything mentioned here https://symfony.com/doc/current/reference/forms/types.html#other-fields
listed as options of the form types.
But could be custom options, too, depends on the formType (if it is a custom one, too)

@ondrejmirtes
Copy link
Member

So is it array<string, mixed>?

@pscheit-lillydoo
Copy link
Contributor Author

yes sir, exactly as stated in the stub

interface FormTypeExtensionInterface
{
/**
* @param array<mixed> $options
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the correct type

@ondrejmirtes
Copy link
Member

Nope, your stub says array<mixed>.

@pscheit-lillydoo
Copy link
Contributor Author

pscheit-lillydoo commented Oct 22, 2020

arg, right 👍

but then its the same case as for
stubs/FormTypeInterface.stub

should I create a PR to fix it there, too?

@ondrejmirtes
Copy link
Member

Push the fix here in this PR, thanks.

@pscheit-lillydoo pscheit-lillydoo force-pushed the form-type-extension-stub branch from 48cf529 to 5a1e3f3 Compare October 22, 2020 10:25
@ondrejmirtes ondrejmirtes merged commit 675703d into phpstan:master Oct 22, 2020
@ondrejmirtes
Copy link
Member

Thank you, tagged as 0.12.10.

@pscheit-lillydoo pscheit-lillydoo deleted the form-type-extension-stub branch October 22, 2020 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants