@@ -23,16 +23,50 @@ final class IsReferenceTest extends AbstractMethodUnitTest
2323 /**
2424 * Test that false is returned when a non-"bitwise and" token is passed.
2525 *
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+ *
2631 * @return void
2732 */
28- public function testNotBitwiseAndToken ()
33+ public function testNotBitwiseAndToken ($ testMarker , $ targetTokens )
2934 {
30- $ target = $ this ->getTargetToken ('/* testBitwiseAndA */ ' , T_STRING );
35+ $ targetTokens [] = T_BITWISE_AND ;
36+
37+ $ target = $ this ->getTargetToken ($ testMarker , $ targetTokens );
3138 $ this ->assertFalse (self ::$ phpcsFile ->isReference ($ target ));
3239
3340 }//end testNotBitwiseAndToken()
3441
3542
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+
3670 /**
3771 * Test correctly identifying whether a "bitwise and" token is a reference or not.
3872 *
@@ -338,6 +372,10 @@ public static function dataIsReference()
338372 'testMarker ' => '/* testBitwiseAndArrowFunctionInDefault */ ' ,
339373 'expected ' => false ,
340374 ],
375+ 'reference: param pass by ref in arrow function ' => [
376+ 'testMarker ' => '/* testParamPassByReference */ ' ,
377+ 'expected ' => true ,
378+ ],
341379 'issue-1284-short-list-directly-after-close-curly-control-structure ' => [
342380 'testMarker ' => '/* testTokenizerIssue1284PHPCSlt280A */ ' ,
343381 'expected ' => true ,
0 commit comments