@@ -23,16 +23,50 @@ final class IsReferenceTest extends AbstractMethodUnitTest
23
23
/**
24
24
* Test that false is returned when a non-"bitwise and" token is passed.
25
25
*
26
+ * @param string $testMarker Comment which precedes the test case.
27
+ * @param array<int|string> $targetTokens Type of tokens to look for.
28
+ *
29
+ * @dataProvider dataNotBitwiseAndToken
30
+ *
26
31
* @return void
27
32
*/
28
- public function testNotBitwiseAndToken ()
33
+ public function testNotBitwiseAndToken ($ testMarker , $ targetTokens )
29
34
{
30
- $ target = $ this ->getTargetToken ('/* testBitwiseAndA */ ' , T_STRING );
35
+ $ targetTokens [] = T_BITWISE_AND ;
36
+
37
+ $ target = $ this ->getTargetToken ($ testMarker , $ targetTokens );
31
38
$ this ->assertFalse (self ::$ phpcsFile ->isReference ($ target ));
32
39
33
40
}//end testNotBitwiseAndToken()
34
41
35
42
43
+ /**
44
+ * Data provider.
45
+ *
46
+ * @see testNotBitwiseAndToken()
47
+ *
48
+ * @return array<string, array<string, string|array<int|string>>>
49
+ */
50
+ public static function dataNotBitwiseAndToken ()
51
+ {
52
+ return [
53
+ 'Not ampersand token at all ' => [
54
+ 'testMarker ' => '/* testBitwiseAndA */ ' ,
55
+ 'targetTokens ' => [T_STRING ],
56
+ ],
57
+ 'ampersand in intersection type ' => [
58
+ 'testMarker ' => '/* testIntersectionIsNotReference */ ' ,
59
+ 'targetTokens ' => [T_TYPE_INTERSECTION ],
60
+ ],
61
+ 'ampersand in DNF type ' => [
62
+ 'testMarker ' => '/* testDNFTypeIsNotReference */ ' ,
63
+ 'targetTokens ' => [T_TYPE_INTERSECTION ],
64
+ ],
65
+ ];
66
+
67
+ }//end dataNotBitwiseAndToken()
68
+
69
+
36
70
/**
37
71
* Test correctly identifying whether a "bitwise and" token is a reference or not.
38
72
*
@@ -338,6 +372,10 @@ public static function dataIsReference()
338
372
'testMarker ' => '/* testBitwiseAndArrowFunctionInDefault */ ' ,
339
373
'expected ' => false ,
340
374
],
375
+ 'reference: param pass by ref in arrow function ' => [
376
+ 'testMarker ' => '/* testParamPassByReference */ ' ,
377
+ 'expected ' => true ,
378
+ ],
341
379
'issue-1284-short-list-directly-after-close-curly-control-structure ' => [
342
380
'testMarker ' => '/* testTokenizerIssue1284PHPCSlt280A */ ' ,
343
381
'expected ' => true ,
0 commit comments