Skip to content

Commit 74a0400

Browse files
committed
1 parent c40d600 commit 74a0400

11 files changed

Lines changed: 119 additions & 0 deletions

fmt.stub.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,11 @@ function tabwriter(array $lines)
17091709
define('T_NAME_RELATIVE', 'namespace');
17101710
}
17111711

1712+
// PHP 7.4
1713+
if (! defined("T_FN")) {
1714+
define("T_FN", "fn");
1715+
}
1716+
17121717
// PHP 8
17131718
if (! defined("T_READONLY")) {
17141719
define("T_READONLY", "readonly");
@@ -7248,6 +7253,18 @@ public function format($source)
72487253
$this->appendCode($text);
72497254
break;
72507255

7256+
case T_FN:
7257+
if (null !== $static) {
7258+
$this->appendCode($static . $this->getSpace());
7259+
$static = null;
7260+
$skipWhitespaces = false;
7261+
}
7262+
$this->appendCode($text);
7263+
$visibility = null;
7264+
$readonly = null;
7265+
$finalOrAbstract = null;
7266+
$type = null;
7267+
break;
72517268
case T_CONST:
72527269
case T_FUNCTION:
72537270
if (empty($classCurlyDepthStack)) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
//version:5.6.0
23
$obj = new StdClass();
34
!$obj->LL || $obj->LL->l(__CLASS__, sprintf("Msg [%d] : %s", $obj2->gs(), $obj2->ge()));
45
!$llll_ttt || $obj->ssss_ttttt($obj3->gv(), $ttttt_ppppppp, ConstantBAG::CONSTANT, $obj2, $dddd_rrr);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
//version:5.6.0
23
$obj = new StdClass();
34
!$obj->LL || $obj->LL->l(__CLASS__, sprintf("Msg [%d] : %s", $obj2->gs(), $obj2->ge()));
45
!$llll_ttt || $obj->ssss_ttttt($obj3->gv(), $ttttt_ppppppp, ConstantBAG::CONSTANT, $obj2, $dddd_rrr);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
//version:7.4.0
3+
4+
class Example {
5+
public Closure $fn;
6+
public function __construct()
7+
{
8+
$this->fn = static fn() => 'fn';
9+
}
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
//version:7.4.0
3+
4+
class Example
5+
{
6+
public Closure $fn;
7+
public function __construct()
8+
{
9+
$this->fn = static fn() => 'fn';
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
//version:7.4.0
3+
4+
class Example {
5+
public function build()
6+
{
7+
$factory = static fn(int $x): int => $x + 1;
8+
$wrapper = static fn() => static fn() => 'ok';
9+
return $factory(1) . $wrapper()();
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
//version:7.4.0
3+
4+
class Example
5+
{
6+
public function build()
7+
{
8+
$factory = static fn(int $x): int => $x + 1;
9+
$wrapper = static fn() => static fn() => 'ok';
10+
return $factory(1) . $wrapper()();
11+
}
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
//version:7.4.0
3+
4+
$fn = static fn() => 'root';
5+
6+
class Example {
7+
public function __construct()
8+
{
9+
$local = static fn() => 'local';
10+
$this->run($local);
11+
}
12+
13+
private function run(Closure $fn)
14+
{
15+
$fn();
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
//version:7.4.0
3+
4+
$fn = static fn() => 'root';
5+
6+
class Example
7+
{
8+
public function __construct()
9+
{
10+
$local = static fn() => 'local';
11+
$this->run($local);
12+
}
13+
14+
private function run(Closure $fn)
15+
{
16+
$fn();
17+
}
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
//version:8.0.0
3+
4+
class Example {
5+
#[SomeAttr]
6+
public function build()
7+
{
8+
return static fn() => 'attr';
9+
}
10+
}

0 commit comments

Comments
 (0)