mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-07-21 22:31:16 +02:00
Always use pMaybeMultiline() for function parameters
Closes GH-861.
This commit is contained in:
@@ -622,7 +622,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
return $this->pAttrGroups($node->attrGroups, true)
|
||||
. ($node->static ? 'static ' : '')
|
||||
. 'function ' . ($node->byRef ? '&' : '')
|
||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
||||
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
||||
. (!empty($node->uses) ? ' use (' . $this->pCommaSeparated($node->uses) . ')' : '')
|
||||
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
||||
. ' {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
||||
@@ -644,7 +644,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
return $this->pAttrGroups($node->attrGroups, true)
|
||||
. ($node->static ? 'static ' : '')
|
||||
. 'fn' . ($node->byRef ? '&' : '')
|
||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
||||
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
||||
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
||||
. ' => '
|
||||
. $this->p($node->expr);
|
||||
@@ -813,7 +813,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
protected function pStmt_Function(Stmt\Function_ $node) {
|
||||
return $this->pAttrGroups($node->attrGroups)
|
||||
. 'function ' . ($node->byRef ? '&' : '') . $node->name
|
||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
||||
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
||||
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
||||
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
||||
}
|
||||
|
53
test/code/prettyPrinter/stmt/param_comments.test
Normal file
53
test/code/prettyPrinter/stmt/param_comments.test
Normal file
@@ -0,0 +1,53 @@
|
||||
Comments on function parameters
|
||||
-----
|
||||
<?php
|
||||
|
||||
class Test {
|
||||
function test(
|
||||
// Comment
|
||||
$param
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
function test(
|
||||
// Comment
|
||||
$param
|
||||
) {
|
||||
}
|
||||
|
||||
function(
|
||||
// Comment
|
||||
$param
|
||||
) {
|
||||
};
|
||||
|
||||
fn(
|
||||
// Comment
|
||||
$param
|
||||
) => 42;
|
||||
-----
|
||||
class Test
|
||||
{
|
||||
function test(
|
||||
// Comment
|
||||
$param
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
function test(
|
||||
// Comment
|
||||
$param
|
||||
)
|
||||
{
|
||||
}
|
||||
function (
|
||||
// Comment
|
||||
$param
|
||||
) {
|
||||
};
|
||||
fn(
|
||||
// Comment
|
||||
$param
|
||||
) => 42;
|
Reference in New Issue
Block a user