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 @@ -113,6 +113,12 @@ $arrowWithUnionReturn = fn($param) : int|true => $param | 10;
113113/* testUnionReturnTypeWithFalse */
114114$ arrowWithUnionReturn = fn ($ param ) : string |FALSE => $ param | 10 ;
115115
116+ /* testIntersectionParamType */
117+ $ arrowWithUnionParam = fn (Traversable &Countable $ param ) : int => (new SomeClass ($ param ))->getValue ();
118+
119+ /* testIntersectionReturnType */
120+ $ arrowWithUnionReturn = fn ($ param ) : \MyFoo &SomeInterface => new SomeClass ($ param );
121+
116122/* testTernary */
117123$ fn = fn ($ a ) => $ a ? /* testTernaryThen */ fn () : string => 'a ' : /* testTernaryElse */ fn () : string => 'b ' ;
118124
Original file line number Diff line number Diff line change @@ -515,6 +515,38 @@ public function testUnionReturnTypeWithFalse()
515515 }//end testUnionReturnTypeWithFalse()
516516
517517
518+ /**
519+ * Test arrow function with an intersection parameter type.
520+ *
521+ * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
522+ *
523+ * @return void
524+ */
525+ public function testIntersectionParamType ()
526+ {
527+ $ token = $ this ->getTargetToken ('/* testIntersectionParamType */ ' , T_FN );
528+ $ this ->backfillHelper ($ token );
529+ $ this ->scopePositionTestHelper ($ token , 13 , 27 );
530+
531+ }//end testIntersectionParamType()
532+
533+
534+ /**
535+ * Test arrow function with an intersection return type.
536+ *
537+ * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
538+ *
539+ * @return void
540+ */
541+ public function testIntersectionReturnType ()
542+ {
543+ $ token = $ this ->getTargetToken ('/* testIntersectionReturnType */ ' , T_FN );
544+ $ this ->backfillHelper ($ token );
545+ $ this ->scopePositionTestHelper ($ token , 12 , 20 );
546+
547+ }//end testIntersectionReturnType()
548+
549+
518550 /**
519551 * Test arrow functions used in ternary operators.
520552 *
You can’t perform that action at this time.
0 commit comments