Skip to content

Commit 285f465

Browse files
committed
Tokenizer/PHP: add support for static return type to arrow function tokenization
Includes unit test.
1 parent 5b0b6ab commit 285f465

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/Tokenizers/PHP.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,7 @@ protected function processAdditional()
18291829
T_CALLABLE => T_CALLABLE,
18301830
T_PARENT => T_PARENT,
18311831
T_SELF => T_SELF,
1832+
T_STATIC => T_STATIC,
18321833
];
18331834

18341835
$closer = $this->tokens[$x]['parenthesis_closer'];

tests/Core/Tokenizer/BackfillFnTokenTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ fn(callable $a) : callable => $a;
7575
/* testArrayReturnType */
7676
fn(array $a) : array => $a;
7777

78+
/* testStaticReturnType */
79+
fn(array $a) : static => $a;
80+
7881
/* testTernary */
7982
$fn = fn($a) => $a ? /* testTernaryThen */ fn() : string => 'a' : /* testTernaryElse */ fn() : string => 'b';
8083

tests/Core/Tokenizer/BackfillFnTokenTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function testNullableNamespace()
466466

467467

468468
/**
469-
* Test arrow functions that use self/parent/callable return types.
469+
* Test arrow functions that use self/parent/callable/array/static return types.
470470
*
471471
* @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
472472
*
@@ -481,6 +481,7 @@ public function testKeywordReturnTypes()
481481
'Parent',
482482
'Callable',
483483
'Array',
484+
'Static',
484485
];
485486

486487
foreach ($testMarkers as $marker) {

0 commit comments

Comments
 (0)