Skip to content

Commit 9460dbe

Browse files
committed
Fix lineno for constructor property promotion errors
Fixes GH-19081 Closes GH-19100
1 parent 46213f8 commit 9460dbe

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ PHP NEWS
8383
(DanielEScherzer)
8484
. Do not use RTLD_DEEPBIND if dlmopen is available. (Daniil Gentili)
8585
. Make `clone()` a function. (timwolla, edorian)
86+
. Fixed bug GH-19081 (Wrong lineno in property error with constructor property
87+
promotion). (ilutov)
8688

8789
- Curl:
8890
. Added curl_multi_get_handles(). (timwolla)

Zend/tests/ctor_promotion/ctor_promotion_callable_type.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ Type of promoted property may not be callable
44
<?php
55

66
class Test {
7-
public function __construct(public callable $callable) {}
7+
public function __construct(
8+
public callable $callable
9+
) {}
810
}
911

1012
?>
1113
--EXPECTF--
12-
Fatal error: Property Test::$callable cannot have type callable in %s on line %d
14+
Fatal error: Property Test::$callable cannot have type callable in %s on line 5

Zend/zend_compile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7698,6 +7698,8 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
76987698
uint32_t property_flags = param_ast->attr & (ZEND_ACC_PPP_MASK | ZEND_ACC_PPP_SET_MASK | ZEND_ACC_READONLY | ZEND_ACC_FINAL);
76997699
bool is_promoted = property_flags || hooks_ast;
77007700

7701+
CG(zend_lineno) = param_ast->lineno;
7702+
77017703
znode var_node, default_node;
77027704
uint8_t opcode;
77037705
zend_op *opline;

0 commit comments

Comments
 (0)