Skip to content

Commit 5fcc12f

Browse files
committed
Use unmangled named in property type inheritance error
1 parent 84354c6 commit 5fcc12f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Typed property invariance violation for protected properties
3+
--FILE--
4+
<?php
5+
6+
class A { protected int $x; }
7+
class B extends A { protected $x; }
8+
9+
?>
10+
--EXPECTF--
11+
Fatal error: Type of B::$x must be int (as in class A) in %s on line %d

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ static void emit_incompatible_property_error(
936936
zend_error_noreturn(E_COMPILE_ERROR,
937937
"Type of %s::$%s must be %s%s (as in class %s)",
938938
ZSTR_VAL(child->ce->name),
939-
ZSTR_VAL(child->name),
939+
zend_get_unmangled_property_name(child->name),
940940
ZEND_TYPE_ALLOW_NULL(parent->type) ? "?" : "",
941941
ZEND_TYPE_IS_CLASS(parent->type)
942942
? ZSTR_VAL(ZEND_TYPE_IS_CE(parent->type) ? ZEND_TYPE_CE(parent->type)->name : resolve_class_name(parent->ce, ZEND_TYPE_NAME(parent->type)))

0 commit comments

Comments
 (0)