mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-07-22 06:41:21 +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)
|
return $this->pAttrGroups($node->attrGroups, true)
|
||||||
. ($node->static ? 'static ' : '')
|
. ($node->static ? 'static ' : '')
|
||||||
. 'function ' . ($node->byRef ? '&' : '')
|
. 'function ' . ($node->byRef ? '&' : '')
|
||||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
||||||
. (!empty($node->uses) ? ' use (' . $this->pCommaSeparated($node->uses) . ')' : '')
|
. (!empty($node->uses) ? ' use (' . $this->pCommaSeparated($node->uses) . ')' : '')
|
||||||
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
||||||
. ' {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
. ' {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
||||||
@@ -644,7 +644,7 @@ class Standard extends PrettyPrinterAbstract
|
|||||||
return $this->pAttrGroups($node->attrGroups, true)
|
return $this->pAttrGroups($node->attrGroups, true)
|
||||||
. ($node->static ? 'static ' : '')
|
. ($node->static ? 'static ' : '')
|
||||||
. 'fn' . ($node->byRef ? '&' : '')
|
. 'fn' . ($node->byRef ? '&' : '')
|
||||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
||||||
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
||||||
. ' => '
|
. ' => '
|
||||||
. $this->p($node->expr);
|
. $this->p($node->expr);
|
||||||
@@ -813,7 +813,7 @@ class Standard extends PrettyPrinterAbstract
|
|||||||
protected function pStmt_Function(Stmt\Function_ $node) {
|
protected function pStmt_Function(Stmt\Function_ $node) {
|
||||||
return $this->pAttrGroups($node->attrGroups)
|
return $this->pAttrGroups($node->attrGroups)
|
||||||
. 'function ' . ($node->byRef ? '&' : '') . $node->name
|
. 'function ' . ($node->byRef ? '&' : '') . $node->name
|
||||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
. '(' . $this->pMaybeMultiline($node->params) . ')'
|
||||||
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
. (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '')
|
||||||
. $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}';
|
. $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