Skip to content

Commit 66763e8

Browse files
committed
Added tests
1 parent d34556c commit 66763e8

18 files changed

+309
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate constant access on new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
const C = 'constant';
9+
}
10+
11+
echo new A()::C;
12+
13+
?>
14+
--EXPECT--
15+
constant
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Immediate invocation of new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public function __invoke(): void
9+
{
10+
echo 'invoked';
11+
}
12+
}
13+
14+
new A()();
15+
16+
?>
17+
--EXPECT--
18+
invoked
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Immediate method call on new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public function test(): void
9+
{
10+
echo 'called';
11+
}
12+
}
13+
14+
new A()->test();
15+
16+
?>
17+
--EXPECT--
18+
called
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate property access on new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public $prop = 'property';
9+
}
10+
11+
echo new A()->prop;
12+
13+
?>
14+
--EXPECT--
15+
property
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Immediate static method call on new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public static function test(): void
9+
{
10+
echo 'called';
11+
}
12+
}
13+
14+
new A()::test();
15+
16+
?>
17+
--EXPECT--
18+
called
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate static property access on new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public static $prop = 'property';
9+
}
10+
11+
echo new A()::$prop;
12+
13+
?>
14+
--EXPECT--
15+
property
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate constant access on new object with ctor parentheses created from expr
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
const C = 'constant';
9+
}
10+
11+
echo new (trim(' A '))()::C;
12+
13+
?>
14+
--EXPECT--
15+
constant
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Immediate invocation of new object with ctor parentheses created from expr
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public function __invoke(): void
9+
{
10+
echo 'invoked';
11+
}
12+
}
13+
14+
new (trim(' A '))()();
15+
16+
?>
17+
--EXPECT--
18+
invoked
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Immediate method call on new object with ctor parentheses created from expr
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public function test(): void
9+
{
10+
echo 'called';
11+
}
12+
}
13+
14+
new (trim(' A '))()->test();
15+
16+
?>
17+
--EXPECT--
18+
called
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate property access on new object with ctor parentheses created from expr
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public $prop = 'property';
9+
}
10+
11+
echo new (trim(' A '))()->prop;
12+
13+
?>
14+
--EXPECT--
15+
property
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Immediate static method call on new object with ctor parentheses created from expr
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public static function test(): void
9+
{
10+
echo 'called';
11+
}
12+
}
13+
14+
new (trim(' A '))()::test();
15+
16+
?>
17+
--EXPECT--
18+
called
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Immediate static property access on new object with ctor parentheses created from expr
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public static $prop = 'property';
9+
}
10+
11+
echo new (trim(' A '))()::$prop;
12+
13+
?>
14+
--EXPECT--
15+
property
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Immediate constant access on new object with ctor parentheses created from var
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
const C = 'constant';
9+
}
10+
11+
$class = A::class;
12+
13+
echo new $class()::C;
14+
15+
?>
16+
--EXPECT--
17+
constant
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Immediate invocation of new object with ctor parentheses created from var
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public function __invoke(): void
9+
{
10+
echo 'invoked';
11+
}
12+
}
13+
14+
$class = A::class;
15+
16+
new $class()();
17+
18+
?>
19+
--EXPECT--
20+
invoked
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Immediate method call on new object with ctor parentheses created from var
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public function test(): void
9+
{
10+
echo 'called';
11+
}
12+
}
13+
14+
$class = A::class;
15+
16+
new $class()->test();
17+
18+
?>
19+
--EXPECT--
20+
called
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Immediate property access on new object with ctor parentheses created from var
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public $prop = 'property';
9+
}
10+
11+
$class = A::class;
12+
13+
echo new $class()->prop;
14+
15+
?>
16+
--EXPECT--
17+
property
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Immediate static method call on new object with ctor parentheses created from var
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public static function test(): void
9+
{
10+
echo 'called';
11+
}
12+
}
13+
14+
$class = A::class;
15+
16+
new $class()::test();
17+
18+
?>
19+
--EXPECT--
20+
called
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Immediate static property access on new object with ctor parentheses created from var
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
public static $prop = 'property';
9+
}
10+
11+
$class = A::class;
12+
13+
echo new $class()::$prop;
14+
15+
?>
16+
--EXPECT--
17+
property

0 commit comments

Comments
 (0)