A method with a single parameter that is either promoted or has an attribute will have it's signature on multiple lines.
Maybe this is a feature request but the output "looks" wrong to me ☺️. Some might also want the current behaviour, therefor the added configuration flag in the solution suggestion.
Steps To Reproduce
use Nette\PhpGenerator\GlobalFunction;
use Nette\PhpGenerator\PsrPrinter;
$function = new GlobalFunction('foo');
$parameter = $function->addParameter('bar');
$parameter->addAttribute('Baz');
echo (new PsrPrinter())->printFunction($function);
Output
function foo(
#[Baz] $bar,
) {
}
Expected Behavior
Output to be
function foo(#[Baz] $bar)
{
}
Possible Solution
Change the Printer::printParameters() method to check if it's a single parameter and take it into account when checking promoted and attributed.
Version: 4.0.6
Bug Description
A method with a single parameter that is either promoted or has an attribute will have it's signature on multiple lines.
Maybe this is a feature request but the output "looks" wrong to me ☺️. Some might also want the current behaviour, therefor the added configuration flag in the solution suggestion.
Steps To Reproduce
Output
Expected Behavior
Output to be
Possible Solution
Change the
Printer::printParameters()
method to check if it's a single parameter and take it into account when checking promoted and attributed.