Skip to content

Commit bc057c1

Browse files
committed
Fix lineno for all constant expressions
Fixes GH-8821
1 parent 3663f76 commit bc057c1

17 files changed

+102
-24
lines changed

Zend/tests/bug41633_2.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ echo Foo::A."\n";
1010
--EXPECTF--
1111
Fatal error: Uncaught Error: Undefined constant self::B in %s:%d
1212
Stack trace:
13-
#0 {main}
13+
#0 %s(%d): [constant expression]()
14+
#1 {main}
1415
thrown in %sbug41633_2.php on line 3

Zend/tests/bug41633_3.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ echo Foo::A;
1111
--EXPECTF--
1212
Fatal error: Uncaught Error: Cannot declare self-referencing constant Foo::B in %s:%d
1313
Stack trace:
14-
#0 {main}
14+
#0 %s(%d): [constant expression]()
15+
#1 {main}
1516
thrown in %sbug41633_3.php on line %d

Zend/tests/bug47572.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ $foo = new Foo();
1616
--EXPECTF--
1717
Fatal error: Uncaught Error: Undefined constant "FOO" in %s:%d
1818
Stack trace:
19-
#0 {main}
19+
#0 %s(%d): [constant expression]()
20+
#1 {main}
2021
thrown in %s on line %d

Zend/tests/bug74657.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ var_dump((new C)->options);
2121
--EXPECTF--
2222
Fatal error: Uncaught Error: Undefined constant I::FOO in %s:%d
2323
Stack trace:
24-
#0 {main}
24+
#0 %s(%d): [constant expression]()
25+
#1 {main}
2526
thrown in %sbug74657.php on line %d

Zend/tests/constant_expressions_self_referencing_array.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ var_dump(A::FOO);
1111
--EXPECTF--
1212
Fatal error: Uncaught Error: Cannot declare self-referencing constant self::BAR in %s:%d
1313
Stack trace:
14-
#0 {main}
14+
#0 %s(%d): [constant expression]()
15+
#1 {main}
1516
thrown in %s on line %d

Zend/tests/enum/offsetGet-in-const-expr.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ var_dump(X::FOO_BAR);
2525
--EXPECTF--
2626
Fatal error: Uncaught Error: Cannot use [] on objects in constant expression in %s:%d
2727
Stack trace:
28-
#0 {main}
28+
#0 %s(%d): [constant expression]()
29+
#1 {main}
2930
thrown in %s on line %d

Zend/tests/gh7771_1.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ new Foo();
1111
--EXPECTF--
1212
Fatal error: Uncaught Error: Class "NonExistent" not found in %sgh7771_1_definition.inc:4
1313
Stack trace:
14-
#0 {main}
14+
#0 %sgh7771_1.php(5): [constant expression]()
15+
#1 {main}
1516
thrown in %sgh7771_1_definition.inc on line 4

Zend/tests/gh7771_2.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ new Foo();
1111
--EXPECTF--
1212
Fatal error: Uncaught Error: Class "NonExistent" not found in %sgh7771_2_definition.inc:6
1313
Stack trace:
14-
#0 {main}
14+
#0 %sgh7771_2.php(5): [constant expression]()
15+
#1 {main}
1516
thrown in %sgh7771_2_definition.inc on line 6

Zend/tests/gh8821.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-8821: Fix reported line number of constant expression
3+
--FILE--
4+
<?php
5+
6+
enum Alpha {
7+
case Foo;
8+
}
9+
10+
class Bravo {
11+
public const C = [Alpha::Foo => 3];
12+
}
13+
14+
new Bravo();
15+
16+
?>
17+
--EXPECTF--
18+
Fatal error: Uncaught TypeError: Illegal offset type in %sgh8821.php:8
19+
Stack trace:
20+
#0 %sgh8821.php(11): [constant expression]()
21+
#1 {main}
22+
thrown in %sgh8821.php on line 8

Zend/tests/type_declarations/typed_properties_022.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ $foo = new Foo();
1111
--EXPECTF--
1212
Fatal error: Uncaught Error: Class "BAR" not found in %s:%d
1313
Stack trace:
14-
#0 {main}
14+
#0 %s(%d): [constant expression]()
15+
#1 {main}
1516
thrown in %s on line %d

0 commit comments

Comments
 (0)