Skip to content

Commit bcefeb2

Browse files
authored
Merge pull request #451 from PHPCSStandards/backcompat/getdeclarationname-add-extra-tests
[BackCompat|ObjectDeclarations]::get[Declaration]Name(): add extra tests
2 parents 5e4f177 + d3593e2 commit bcefeb2

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

Tests/BackCompat/BCFile/GetDeclarationNameTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ enum Hoo : string
8585
/* testBackedEnumNoSpaceBetweenNameAndColon */
8686
enum Suit: int implements Colorful, CardGame {}
8787

88+
/* testFunctionReturnByRefWithReservedKeywordEach */
89+
function &each() {}
90+
8891
/* testLiveCoding */
8992
// Intentional parse error. This has to be the last test in the file.
9093
function // Comment.

Tests/BackCompat/BCFile/GetDeclarationNameTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ public function dataGetDeclarationName()
192192
'/* testBackedEnumNoSpaceBetweenNameAndColon */',
193193
'Suit',
194194
],
195+
'function-return-by-reference-with-reserved-keyword-each' => [
196+
'/* testFunctionReturnByRefWithReservedKeywordEach */',
197+
'each',
198+
],
195199
];
196200
}
197201
}

Tests/Utils/ObjectDeclarations/GetNameDiffTest.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ interface switch{ // Intentional parse error.
1212
public function someFunction();
1313
}
1414

15+
/* testFunctionReturnByRefWithReservedKeywordParent */
16+
function &parent() {}
17+
18+
/* testFunctionReturnByRefWithReservedKeywordSelf */
19+
function &self() {}
20+
21+
/* testFunctionReturnByRefWithReservedKeywordStatic */
22+
function &static() {}
23+
1524
/* testLiveCoding */
1625
// Intentional parse error. Redundancy testing.
1726
abstract class

Tests/Utils/ObjectDeclarations/GetNameDiffTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ public function dataGetName()
117117
'testMarker' => '/* testInvalidInterfaceName */',
118118
'expected' => 'switch',
119119
],
120+
'function-return-by-reference-with-reserved-keyword-parent' => [
121+
'/* testFunctionReturnByRefWithReservedKeywordParent */',
122+
'parent',
123+
],
124+
'function-return-by-reference-with-reserved-keyword-self' => [
125+
'/* testFunctionReturnByRefWithReservedKeywordSelf */',
126+
'self',
127+
],
128+
'function-return-by-reference-with-reserved-keyword-static' => [
129+
'/* testFunctionReturnByRefWithReservedKeywordStatic */',
130+
'static',
131+
],
120132
];
121133
}
122134
}

0 commit comments

Comments
 (0)