Skip to content

Commit c7ded35

Browse files
committed
Added anonymous class tests
1 parent 66763e8 commit c7ded35

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Immediate constant access on new anonymous class object
3+
--FILE--
4+
<?php
5+
6+
echo new class {
7+
const C = 'constant';
8+
}::C;
9+
10+
?>
11+
--EXPECT--
12+
constant
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate invocation of new anonymous class object
3+
--FILE--
4+
<?php
5+
6+
new class {
7+
public function __invoke()
8+
{
9+
echo 'invoked';
10+
}
11+
}();
12+
13+
?>
14+
--EXPECT--
15+
invoked
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate method call on new anonymous class object
3+
--FILE--
4+
<?php
5+
6+
new class {
7+
public function test()
8+
{
9+
echo 'called';
10+
}
11+
}->test();
12+
13+
?>
14+
--EXPECT--
15+
called
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Immediate property access on new anonymous class object
3+
--FILE--
4+
<?php
5+
6+
echo new class {
7+
public $property = 'property';
8+
}->property;
9+
10+
?>
11+
--EXPECT--
12+
property
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate static method call on new anonymous class object
3+
--FILE--
4+
<?php
5+
6+
new class {
7+
public function test()
8+
{
9+
echo 'called';
10+
}
11+
}->test();
12+
13+
?>
14+
--EXPECT--
15+
called
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Immediate static property access on new anonymous class object
3+
--FILE--
4+
<?php
5+
6+
echo new class {
7+
public static $staticProperty = 'staticProperty';
8+
}::$staticProperty;
9+
10+
?>
11+
--EXPECT--
12+
staticProperty

0 commit comments

Comments
 (0)