nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.

Home Page:https://doc.nette.org/php-generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing possibility to add variadic parameter to a method

Eydamos opened this issue · comments

Simple example:

$method = $class->addMethod('count')
                ->addParameter('entities')
                ->setType('object ...');

Would result in the following:

function count(object ... $entities)
{
}

The space between the variadic operator ... and the variable name $entities is not allowed by PSR12 standard.
A method like setVariadic(bool $state = true): self; on the Nette\PhpGenerator\Parameter could help with that.

Use setVariadic() on method.

Ok thank you. Would not have expected that on the method as the parameter is a variadic and not the method. But good that it is possible.
Would be cool if you could add this to the documentation on https://doc.nette.org/

If you can sent PR to documentation, it would be best.

https://github.com/nette/docs/blob/doc-3.1/en/php-generator.texy