Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/PhpParser/Lexer/Emulative.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PhpParser\Lexer\TokenEmulator\AttributeEmulator;
use PhpParser\Lexer\TokenEmulator\EnumTokenEmulator;
use PhpParser\Lexer\TokenEmulator\ExplicitOctalEmulator;
use PhpParser\Lexer\TokenEmulator\FnTokenEmulator;
use PhpParser\Lexer\TokenEmulator\MatchTokenEmulator;
use PhpParser\Lexer\TokenEmulator\NullsafeTokenEmulator;
use PhpParser\Lexer\TokenEmulator\PipeOperatorEmulator;
Expand Down Expand Up @@ -51,6 +52,7 @@ public function __construct(?PhpVersion $phpVersion = null) {
new AsymmetricVisibilityTokenEmulator(),
new PipeOperatorEmulator(),
new VoidCastEmulator(),
new FnTokenEmulator(),
Comment thread
nikic marked this conversation as resolved.
Outdated
];

// Collect emulators that are relevant for the PHP version we're running
Expand Down
19 changes: 19 additions & 0 deletions lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);

namespace PhpParser\Lexer\TokenEmulator;

use PhpParser\PhpVersion;

final class FnTokenEmulator extends KeywordEmulator {
Comment thread
nikic marked this conversation as resolved.
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromString('7.4');
}

public function getKeywordString(): string {
return 'fn';
}

public function getKeywordToken(): int {
return \T_FN;
}
}
21 changes: 21 additions & 0 deletions test/code/parser/stmt/function/fn.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Function with the name fn
-----
<?php
function fn() {}
-----
!!version=7.3
array(
0: Stmt_Function(
attrGroups: array(
)
byRef: false
name: Identifier(
name: fn
)
params: array(
)
returnType: null
stmts: array(
)
)
)