You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Signature of Method Forms/Container::extensionMethod should respect variable numbers of Arguments #355
PHP Stan reports this error, for Method Forms/Container::extensionMethod
Parameter #2 $callback of static method Nette\Forms\Container::extensionMethod() expects callable(Nette\Forms\Container): mixed, Closure(Nette\Forms\Container, string, string|Stringable|null=, string=): XYZInput given.
💡 Parameter #2 $name of passed callable is required but accepting callable does not have that parameter. It will be called without it.PHPStan[argument.type](https://phpstan.org/error-identifiers/argument.type)
Steps To Reproduce
Create a Nette DI extension e.g.:
class XYZExtension extends CompilerExtension
{
public function afterCompile(ClassType $class): void
{
$class->getMethod('initialize')
->addBody('\XYZExtension::register();');
}
/**
* Register addXYZ() on every form Container.
*/
public static function register(): void
{
Container::extensionMethod(
'addXYZ,
function (
Container $container,
string $name,
string|Stringable|null $label = null,
string $anotherParam = '',
): XYZInput {
$control = new XYZInput($label, $anotherParam);
$container->addComponent($control, $name);
return $control;
}
);
}
}
Expected Behavior
Signature of Method Forms\Container::extensionMethod should respect variable numbers of Arguments
Possible Solution
Possible Signature for Method Forms/Container::extensionMethod can be.
/** @param callable(static, ...mixed): mixed $callback */
public static function extensionMethod(string $name, callable $callback): void
Activity