Skip to content

Commit 89363fa

Browse files
committed
Added no constructor parentheses tests
1 parent 379b8f2 commit 89363fa

5 files changed

+86
-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+
--EXPECTF--
15+
Parse error: syntax error, unexpected identifier "C", expecting variable or "$" in %s on line %d
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+
--EXPECTF--
18+
Parse error: syntax error, unexpected token "->" in %s on line %d
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+
--EXPECTF--
15+
Parse error: syntax error, unexpected token "->", expecting "," or ";" in %s on line %d
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+
--EXPECTF--
18+
Parse error: syntax error, unexpected identifier "test", expecting variable or "$" in %s on line %d
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Immediate static property access on new object with ctor parentheses
3+
--FILE--
4+
<?php
5+
6+
class B
7+
{
8+
}
9+
10+
class A
11+
{
12+
public static $prop = B::class;
13+
}
14+
15+
var_dump(new A::$prop);
16+
17+
?>
18+
--EXPECT--
19+
object(B)#1 (0) {
20+
}

0 commit comments

Comments
 (0)