Version: 3.3.0
Bug Description
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
PHP runtime version: 8.3.25
PHPStan version: 2.2.8
Version: 3.3.0
Bug Description
PHP Stan reports this error, for Method Forms/Container::extensionMethod
Steps To Reproduce
Create a Nette DI extension e.g.:
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.
PHP runtime version: 8.3.25
PHPStan version: 2.2.8