Add information on expected tokens to syntax errors

This now mimics the error messages provided by PHP itself (pre 5.4).
This commit is contained in:
nikic
2013-01-15 17:26:20 +01:00
parent 222c9612ab
commit fbaa1e5fc3
6 changed files with 69 additions and 11 deletions

View File

@@ -26,4 +26,4 @@ Cannot use the final and abstract modifier at the same time on line 1
-----
<?php abstract final class A { }
-----
Unexpected token T_FINAL on line 1
Syntax error, unexpected T_FINAL, expecting T_CLASS on line 1

View File

@@ -10,7 +10,7 @@ Cannot use "parent" as class name as it is reserved on line 1
-----
<?php class static {}
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING on line 1
-----
<?php class A extends self {}
-----
@@ -22,7 +22,7 @@ Cannot use "parent" as class name as it is reserved on line 1
-----
<?php class A extends static {}
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR on line 1
-----
<?php class A implements self {}
-----
@@ -34,7 +34,7 @@ Cannot use "parent" as interface name as it is reserved on line 1
-----
<?php class A implements static {}
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR on line 1
-----
<?php interface self {}
-----
@@ -46,7 +46,7 @@ Cannot use "parent" as interface name as it is reserved on line 1
-----
<?php interface static {}
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING on line 1
-----
<?php interface A extends self {}
-----
@@ -58,4 +58,4 @@ Cannot use "parent" as interface name as it is reserved on line 1
-----
<?php interface A extends static {}
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR on line 1

View File

@@ -10,7 +10,7 @@ Cannot use "parent" as namespace name as it is reserved on line 1
-----
<?php namespace static;
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NS_SEPARATOR or '{' on line 1
-----
<?php use A as self;
-----
@@ -22,4 +22,4 @@ Cannot use "B" as "parent" because "parent" is a special class name on line 1
-----
<?php use C as static;
-----
Unexpected token T_STATIC on line 1
Syntax error, unexpected T_STATIC, expecting T_STRING on line 1