File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,12 @@ $arrowWithUnionReturn = fn($param) : int|true => $param | 10;
119
119
/* testUnionReturnTypeWithFalse */
120
120
$ arrowWithUnionReturn = fn ($ param ) : string |FALSE => $ param | 10 ;
121
121
122
+ /* testIntersectionParamType */
123
+ $ arrowWithUnionParam = fn (Traversable &Countable $ param ) : int => (new SomeClass ($ param ))->getValue ();
124
+
125
+ /* testIntersectionReturnType */
126
+ $ arrowWithUnionReturn = fn ($ param ) : \MyFoo &SomeInterface => new SomeClass ($ param );
127
+
122
128
/* testTernary */
123
129
$ fn = fn ($ a ) => $ a ? /* testTernaryThen */ fn () : string => 'a ' : /* testTernaryElse */ fn () : string => 'b ' ;
124
130
Original file line number Diff line number Diff line change @@ -571,6 +571,38 @@ public function testUnionReturnTypeWithFalse()
571
571
}//end testUnionReturnTypeWithFalse()
572
572
573
573
574
+ /**
575
+ * Test arrow function with an intersection parameter type.
576
+ *
577
+ * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
578
+ *
579
+ * @return void
580
+ */
581
+ public function testIntersectionParamType ()
582
+ {
583
+ $ token = $ this ->getTargetToken ('/* testIntersectionParamType */ ' , T_FN );
584
+ $ this ->backfillHelper ($ token );
585
+ $ this ->scopePositionTestHelper ($ token , 13 , 27 );
586
+
587
+ }//end testIntersectionParamType()
588
+
589
+
590
+ /**
591
+ * Test arrow function with an intersection return type.
592
+ *
593
+ * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
594
+ *
595
+ * @return void
596
+ */
597
+ public function testIntersectionReturnType ()
598
+ {
599
+ $ token = $ this ->getTargetToken ('/* testIntersectionReturnType */ ' , T_FN );
600
+ $ this ->backfillHelper ($ token );
601
+ $ this ->scopePositionTestHelper ($ token , 11 , 19 );
602
+
603
+ }//end testIntersectionReturnType()
604
+
605
+
574
606
/**
575
607
* Test arrow functions used in ternary operators.
576
608
*
You can’t perform that action at this time.
0 commit comments