Add stub for FormBuilderInterface::getForm() variadic params#957
Add stub for FormBuilderInterface::getForm() variadic params#957marklabrecque-ab wants to merge 2 commits intomglaman:mainfrom
Conversation
|
I don't think stubs work this way, it only allows enhancing phpdoc and not the actual signatures |
|
Thanks for the contribution! Unfortunately this approach won't work — PHPStan stub files only override PHPDoc annotations, not native method signatures. The The root cause is Drupal 10's use of a comment-style variadic ( Given that Drupal 10 reaches end of life on December 9, 2026, we're going to close this without a fix. In the meantime, you can suppress the error with |
Fixes #892.
Problem
In Drupal 10.x,
FormBuilderInterface::getForm()uses a comment-style variadic parameter (/* , mixed ...$args */) rather than real PHP variadic syntax. PHPStan does not see the extra arguments and reports an error when callinggetForm()with more than one parameter.This has already been fixed in Drupal 11.x where the method signature uses proper
mixed ...$argssyntax.Solution
Add a stub at
stubs/Drupal/Core/Form/FormBuilderInterface.stubthat declares the real variadic signature. The project'sDrupalStubFilesExtensionauto-discovers.stubfiles understubs/, so no additional configuration is needed.