Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PHPCSUtils/Utils/ObjectDeclarations.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static function getName(File $phpcsFile, $stackPtr)
$exclude = Tokens::$emptyTokens;
$exclude[] = \T_OPEN_PARENTHESIS;
$exclude[] = \T_OPEN_CURLY_BRACKET;
$exclude[] = \T_BITWISE_AND;

$nameStart = $phpcsFile->findNext($exclude, ($stackPtr + 1), $stopPoint, true);
if ($nameStart === false) {
Expand Down
6 changes: 6 additions & 0 deletions Tests/BackCompat/BCFile/GetDeclarationNameTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ $class = new class extends SomeClass {
/* testFunction */
function functionName() {}

/* testFunctionReturnByRef */
function & functionNameByRef();

/* testClass */
abstract class ClassName {
/* testMethod */
public function methodName() {}

/* testAbstractMethod */
abstract protected function abstractMethodName();

/* testMethodReturnByRef */
private function &MethodNameByRef();
}

/* testExtendedClass */
Expand Down
8 changes: 8 additions & 0 deletions Tests/BackCompat/BCFile/GetDeclarationNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public function dataGetDeclarationName()
'/* testFunction */',
'functionName',
],
'function-return-by-reference' => [
'/* testFunctionReturnByRef */',
'functionNameByRef',
],
'class' => [
'/* testClass */',
'ClassName',
Expand All @@ -145,6 +149,10 @@ public function dataGetDeclarationName()
'/* testAbstractMethod */',
'abstractMethodName',
],
'method-return-by-reference' => [
'/* testMethodReturnByRef */',
'MethodNameByRef',
],
'extended-class' => [
'/* testExtendedClass */',
'ExtendedClass',
Expand Down