Skip to content

Commit 8502401

Browse files
committed
add more tests
1 parent a65ba61 commit 8502401

File tree

7 files changed

+105
-0
lines changed

7 files changed

+105
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
multiple access modifiers
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
public private class Inner {
8+
}
9+
}
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Multiple access type modifiers are not allowed in %s on line %d
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
invalid inner class
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
int class Inner {
8+
}
9+
}
10+
11+
?>
12+
--EXPECTF--
13+
Parse error: syntax error, unexpected identifier "int", expecting "class" in %s on line %d
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
static access modifiers
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
static class Inner {
8+
}
9+
}
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Cannot use the static modifier on a nested class in %s on line %d
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
public(set) inner class
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
public(set) class Inner {
8+
}
9+
}
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Cannot use the public(set) modifier on a nested class in %s on line %d
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
protected(set) inner class
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
protected(set) class Inner {
8+
}
9+
}
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Cannot use the protected(set) modifier on a nested class in %s on line %d
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
private(set) inner class
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
private(set) class Inner {
8+
}
9+
}
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Cannot use the private(set) modifier on a nested class in %s on line %d
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
abstract inner classes
3+
--FILE--
4+
<?php
5+
6+
class Outer {
7+
public abstract class Inner {}
8+
}
9+
10+
class Extended extends Outer\Inner {}
11+
12+
$extended = new Extended();
13+
14+
var_dump($extended);
15+
$reflection = new ReflectionClass('Outer\Inner');
16+
var_dump($reflection->isAbstract());
17+
new Outer\Inner();
18+
?>
19+
--EXPECTF--
20+
object(Extended)#1 (0) {
21+
}
22+
bool(true)
23+
24+
Fatal error: Uncaught Error: Cannot instantiate abstract class Outer\Inner in %s:%d
25+
Stack trace:
26+
#0 {main}
27+
thrown in %s on line %d

0 commit comments

Comments
 (0)