psalm / psalm-plugin-symfony

Psalm Plugin for Symfony
MIT License
228 stars 53 forks source link

Override visibility of AbstractController createForm #313

Closed laurentmuller closed 1 year ago

laurentmuller commented 1 year ago

In the stub file AbstractController.stubphp for Symfony 6, the following code is wrong:

public function createForm(string $type, $data = null, array $options = []): FormInterface {}

The visibility of the AbstractController must be protected instead of public.

When we override the function in a controller, pslam complains with the following error:

OverriddenMethodAccess: Method App\Controller\AbstractController::createForm has different access level...

It is simply a matter of changing the visibility in the AbstractController.stubphp file:

protected function createForm(string $type, $data = null, array $options = []): FormInterface {}