-
Notifications
You must be signed in to change notification settings - Fork 93
AbstractType generics in psalm but not in phpstan #320
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
Comments
Hi, please show an example of a class that uses |
To be honest I'm not sure about this specific addition, but it sems it raises issues such as the one described in psalm/psalm-plugin-symfony#295 (comment) An example class would be: // ...
use Symfony\Component\Form\AbstractType;
class UserBookType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('title', TextType::class, ['trim' => true])
//
->add('save', SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => UserBookCreateDTO::class,
]);
}
} To then be used in symfony's // ...
$userBookDTO = new UserBookCreateDTO();
$form = $this->createForm(UserBookType::class, $userBookDTO);
$form->handleRequest($request);
// ... |
There already was a PR opened for this #317 And I explained that the stub/generics is currently useless for PHPStan #317 (review) The solution is maybe to write
|
That suggestion isn't going to work. Please before you suggest something, check it with phpstan.org/try. The solution is https://phpstan.org/user-guide/ignoring-errors |
Indeed, it works for param/return type but not for extends Dunno if it's worth enough for a feature request... |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR looks promising #337 |
Hello,
I'm having issues with cross-usage of psalm and phpstan for form type classes extending
AbstractType
:/** @extends AbstractType<mixed> */
(or similar ^^) is needed to avoid gettingMissingTemplate
errorsAbstractType
is not genericI'm a bit lost in this situation, as I guess suppressing psalm's
MissingTemplate
errors is not the good thing to do 😅The text was updated successfully, but these errors were encountered: