Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -40,6 +41,7 @@ public function __construct(?PhpVersion $phpVersion = null) {
$this->hostPhpVersion = PhpVersion::getHostVersion();

$emulators = [
new FnTokenEmulator(),
new MatchTokenEmulator(),
new NullsafeTokenEmulator(),
new AttributeEmulator(),
Expand Down
20 changes: 20 additions & 0 deletions lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);

namespace PhpParser\Lexer\TokenEmulator;

use PhpParser\PhpVersion;

// Retained for reverse emulation support only.
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(
)
)
)
Loading