phpstan-symfony icon indicating copy to clipboard operation
phpstan-symfony copied to clipboard

Missing method in stub Symfony Form FormFactoryInterface

Open Kazadri opened this issue 5 months ago • 1 comments

Hi ! I noticed that the interface FormFactoryInterface define 6 methods, but the current stub only includes two of them. For example, in this snippet:

class MyService
{
	public function __construct(private FormFactoryInterface $formFactory) {}

	/**
	 * @return FormInterface<Foo>
     */
	public function getForm(): FormInterface
	{
		$builder = $this->formFactoryInterface->createBuilder(FormType::class, new Foo());

		// add field(s)
		
		return $builder->getForm();
	}
}

PHPStan reports the following error:

Method MyService::getForm() should return Symfony\Component\Form\FormInterface<Foo> but return Symfony\Component\Form\FormInterface<mixed>.

I'd be happy to help contribute a PR to complete the stub if that's welcome! :)

Kazadri avatar Jun 25 '25 15:06 Kazadri